You are here

class SubrequestSubscriber in GraphQL 8.3

Same name and namespace in other branches
  1. 8.4 src/EventSubscriber/SubrequestSubscriber.php \Drupal\graphql\EventSubscriber\SubrequestSubscriber

Remap artificial requests to subrequest extraction controller.

Hierarchy

  • class \Drupal\graphql\EventSubscriber\SubrequestSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of SubrequestSubscriber

1 string reference to 'SubrequestSubscriber'
graphql.services.yml in ./graphql.services.yml
graphql.services.yml
1 service uses SubrequestSubscriber
graphql.subrequest_subscriber in ./graphql.services.yml
Drupal\graphql\EventSubscriber\SubrequestSubscriber

File

src/EventSubscriber/SubrequestSubscriber.php, line 12

Namespace

Drupal\graphql\EventSubscriber
View source
class SubrequestSubscriber implements EventSubscriberInterface {

  /**
   * Handle kernel request events.
   *
   * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
   *   The kernel event object.
   */
  public function onKernelRequest(GetResponseEvent $event) {
    $request = $event
      ->getRequest();
    if ($request->attributes
      ->has('_graphql_subrequest')) {
      $request->attributes
        ->set('_graphql_controller', $request->attributes
        ->get('_controller'));
      $request->attributes
        ->set('_controller', '\\Drupal\\graphql\\Controller\\SubrequestExtractionController:extract');
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    return [
      KernelEvents::REQUEST => 'onKernelRequest',
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SubrequestSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
SubrequestSubscriber::onKernelRequest public function Handle kernel request events.