You are here

class FilterControllerEvent in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/http-kernel/Event/FilterControllerEvent.php \Symfony\Component\HttpKernel\Event\FilterControllerEvent

Allows filtering of a controller callable.

You can call getController() to retrieve the current controller. With setController() you can set a new controller that is used in the processing of the request.

Controllers should be callables.

@author Bernhard Schussek <bschussek@gmail.com>

Hierarchy

Expanded class hierarchy of FilterControllerEvent

6 files declare their use of FilterControllerEvent
EarlyRenderingControllerWrapperSubscriber.php in core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php
Contains \Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.
HttpKernel.php in vendor/symfony/http-kernel/HttpKernel.php
PathSubscriber.php in core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php
Contains \Drupal\Core\EventSubscriber\PathSubscriber.
RequestDataCollector.php in vendor/symfony/http-kernel/DataCollector/RequestDataCollector.php
RequestDataCollectorTest.php in vendor/symfony/http-kernel/Tests/DataCollector/RequestDataCollectorTest.php

... See full list

File

vendor/symfony/http-kernel/Event/FilterControllerEvent.php, line 28

Namespace

Symfony\Component\HttpKernel\Event
View source
class FilterControllerEvent extends KernelEvent {

  /**
   * The current controller.
   */
  private $controller;
  public function __construct(HttpKernelInterface $kernel, $controller, Request $request, $requestType) {
    parent::__construct($kernel, $request, $requestType);
    $this
      ->setController($controller);
  }

  /**
   * Returns the current controller.
   *
   * @return callable
   */
  public function getController() {
    return $this->controller;
  }

  /**
   * Sets a new controller.
   *
   * @param callable $controller
   *
   * @throws \LogicException
   */
  public function setController($controller) {

    // controller must be a callable
    if (!is_callable($controller)) {
      throw new \LogicException(sprintf('The controller must be a callable (%s given).', $this
        ->varToString($controller)));
    }
    $this->controller = $controller;
  }
  private function varToString($var) {
    if (is_object($var)) {
      return sprintf('Object(%s)', get_class($var));
    }
    if (is_array($var)) {
      $a = array();
      foreach ($var as $k => $v) {
        $a[] = sprintf('%s => %s', $k, $this
          ->varToString($v));
      }
      return sprintf('Array(%s)', implode(', ', $a));
    }
    if (is_resource($var)) {
      return sprintf('Resource(%s)', get_resource_type($var));
    }
    if (null === $var) {
      return 'null';
    }
    if (false === $var) {
      return 'false';
    }
    if (true === $var) {
      return 'true';
    }
    return (string) $var;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Event::$dispatcher private property
Event::$name private property
Event::$propagationStopped private property
Event::getDispatcher Deprecated public function Returns the EventDispatcher that dispatches this Event.
Event::getName Deprecated public function Gets the event's name.
Event::isPropagationStopped public function Returns whether further event listeners should be triggered.
Event::setDispatcher Deprecated public function Stores the EventDispatcher that dispatches this Event.
Event::setName Deprecated public function Sets the event's name property.
Event::stopPropagation public function Stops the propagation of the event to further event listeners.
FilterControllerEvent::$controller private property The current controller.
FilterControllerEvent::getController public function Returns the current controller.
FilterControllerEvent::setController public function Sets a new controller.
FilterControllerEvent::varToString private function
FilterControllerEvent::__construct public function Overrides KernelEvent::__construct
KernelEvent::$kernel private property The kernel in which this event was thrown.
KernelEvent::$request private property The request the kernel is currently processing.
KernelEvent::$requestType private property The request type the kernel is currently processing. One of HttpKernelInterface::MASTER_REQUEST and HttpKernelInterface::SUB_REQUEST.
KernelEvent::getKernel public function Returns the kernel in which this event was thrown.
KernelEvent::getRequest public function Returns the request the kernel is currently processing.
KernelEvent::getRequestType public function Returns the request type the kernel is currently processing.
KernelEvent::isMasterRequest public function Checks if this is a master request.