Loading src/Controller/Forwarder.php +2 −2 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ final class Forwarder extends ControllerBase { /** * The name of the query string parameter containing the URI. * * @param string * @var string */ private $uriParamName; Loading Loading @@ -53,7 +53,7 @@ final class Forwarder extends ControllerBase { * The response object. */ public function forward(HttpApiInterface $api_proxy, Request $request): Response { // TODO: This belongs to the routing system. // @todo This belongs to the routing system. $account = $this->currentUser(); $cache_contexts = [ 'url.query_args:' . $this->uriParamName, Loading src/EventSubscriber/OptionsRequestSubscriber.php +3 −4 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ namespace Drupal\api_proxy\EventSubscriber; use Drupal\api_proxy\Controller\Forwarder; use Drupal\api_proxy\Plugin\HttpApiPluginBase; use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Cache\CacheableResponse; Loading Loading @@ -36,7 +35,7 @@ class OptionsRequestSubscriber implements EventSubscriberInterface { /** * The name of the query string parameter containing the URI. * * @param string * @var string */ private $uriParamName; Loading @@ -45,7 +44,7 @@ class OptionsRequestSubscriber implements EventSubscriberInterface { * * @param \Symfony\Cmf\Component\Routing\RouteProviderInterface $route_provider * The route provider. * @param \Symfony\Component\EventDispatcher\EventSubscriberInterface * @param \Symfony\Component\EventDispatcher\EventSubscriberInterface $subject * The decorated service. * @param string $uri_param_name * The name of the query string parameter containing the URI. Loading Loading @@ -117,7 +116,7 @@ class OptionsRequestSubscriber implements EventSubscriberInterface { * @return \Drupal\Core\Config\ImmutableConfig * The immutable configuration object. * * @todo: use dependency injection to pass the configFactory. * @todo use dependency injection to pass the configFactory. */ private function config(string $config_id): ImmutableConfig { return \Drupal::config($config_id); Loading src/Form/SettingsForm.php +1 −1 Original line number Diff line number Diff line Loading @@ -109,7 +109,7 @@ final class SettingsForm extends ConfigFormBase { $message = $this->t('Settings saved for plugin(s): %names', [ '%names' => implode(', ', array_map(function (HttpApiPluginBase $api_proxy) { return $api_proxy->getPluginDefinition()['label']; }, $api_proxies)) }, $api_proxies)), ]); $this->messenger()->addStatus($message); } Loading src/ParamConverter/HttpApiProxyConverter.php +0 −1 Original line number Diff line number Diff line Loading @@ -3,7 +3,6 @@ namespace Drupal\api_proxy\ParamConverter; use Drupal\api_proxy\Plugin\HttpApiInterface; use Drupal\api_proxy\Plugin\HttpApiPluginBase; use Drupal\api_proxy\Plugin\HttpApiPluginManager; use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Http\Exception\CacheableNotFoundHttpException; Loading src/Plugin/HttpApiInterface.php +38 −0 Original line number Diff line number Diff line Loading @@ -10,16 +10,54 @@ use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; /** * {@inheritdoc} */ interface HttpApiInterface extends PluginInspectionInterface { /** * {@inheritdoc} */ public function getBaseUrl(): string; /** * {@inheritdoc} */ public function shouldForwardHeaders(): bool; /** * {@inheritdoc} */ public function getAdditionalHeaders(): array; /** * {@inheritdoc} */ public function isCacheForced(): int; /** * {@inheritdoc} */ public function getForcedCacheTtl(): int; /** * {@inheritdoc} */ public function preprocessIncoming(string $method, string $uri, HeaderBag $headers, ParameterBag $query): array; /** * {@inheritdoc} */ public function postprocessOutgoing(Response $response): Response; /** * {@inheritdoc} */ public function forward(Request $request, string $uri): Response; /** * {@inheritdoc} */ public function corsResponse(Request $request): CacheableResponse; /** Loading Loading
src/Controller/Forwarder.php +2 −2 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ final class Forwarder extends ControllerBase { /** * The name of the query string parameter containing the URI. * * @param string * @var string */ private $uriParamName; Loading Loading @@ -53,7 +53,7 @@ final class Forwarder extends ControllerBase { * The response object. */ public function forward(HttpApiInterface $api_proxy, Request $request): Response { // TODO: This belongs to the routing system. // @todo This belongs to the routing system. $account = $this->currentUser(); $cache_contexts = [ 'url.query_args:' . $this->uriParamName, Loading
src/EventSubscriber/OptionsRequestSubscriber.php +3 −4 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ namespace Drupal\api_proxy\EventSubscriber; use Drupal\api_proxy\Controller\Forwarder; use Drupal\api_proxy\Plugin\HttpApiPluginBase; use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Cache\CacheableResponse; Loading Loading @@ -36,7 +35,7 @@ class OptionsRequestSubscriber implements EventSubscriberInterface { /** * The name of the query string parameter containing the URI. * * @param string * @var string */ private $uriParamName; Loading @@ -45,7 +44,7 @@ class OptionsRequestSubscriber implements EventSubscriberInterface { * * @param \Symfony\Cmf\Component\Routing\RouteProviderInterface $route_provider * The route provider. * @param \Symfony\Component\EventDispatcher\EventSubscriberInterface * @param \Symfony\Component\EventDispatcher\EventSubscriberInterface $subject * The decorated service. * @param string $uri_param_name * The name of the query string parameter containing the URI. Loading Loading @@ -117,7 +116,7 @@ class OptionsRequestSubscriber implements EventSubscriberInterface { * @return \Drupal\Core\Config\ImmutableConfig * The immutable configuration object. * * @todo: use dependency injection to pass the configFactory. * @todo use dependency injection to pass the configFactory. */ private function config(string $config_id): ImmutableConfig { return \Drupal::config($config_id); Loading
src/Form/SettingsForm.php +1 −1 Original line number Diff line number Diff line Loading @@ -109,7 +109,7 @@ final class SettingsForm extends ConfigFormBase { $message = $this->t('Settings saved for plugin(s): %names', [ '%names' => implode(', ', array_map(function (HttpApiPluginBase $api_proxy) { return $api_proxy->getPluginDefinition()['label']; }, $api_proxies)) }, $api_proxies)), ]); $this->messenger()->addStatus($message); } Loading
src/ParamConverter/HttpApiProxyConverter.php +0 −1 Original line number Diff line number Diff line Loading @@ -3,7 +3,6 @@ namespace Drupal\api_proxy\ParamConverter; use Drupal\api_proxy\Plugin\HttpApiInterface; use Drupal\api_proxy\Plugin\HttpApiPluginBase; use Drupal\api_proxy\Plugin\HttpApiPluginManager; use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Http\Exception\CacheableNotFoundHttpException; Loading
src/Plugin/HttpApiInterface.php +38 −0 Original line number Diff line number Diff line Loading @@ -10,16 +10,54 @@ use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; /** * {@inheritdoc} */ interface HttpApiInterface extends PluginInspectionInterface { /** * {@inheritdoc} */ public function getBaseUrl(): string; /** * {@inheritdoc} */ public function shouldForwardHeaders(): bool; /** * {@inheritdoc} */ public function getAdditionalHeaders(): array; /** * {@inheritdoc} */ public function isCacheForced(): int; /** * {@inheritdoc} */ public function getForcedCacheTtl(): int; /** * {@inheritdoc} */ public function preprocessIncoming(string $method, string $uri, HeaderBag $headers, ParameterBag $query): array; /** * {@inheritdoc} */ public function postprocessOutgoing(Response $response): Response; /** * {@inheritdoc} */ public function forward(Request $request, string $uri): Response; /** * {@inheritdoc} */ public function corsResponse(Request $request): CacheableResponse; /** Loading