You are here

class RouterDataCollector in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-kernel/DataCollector/RouterDataCollector.php \Symfony\Component\HttpKernel\DataCollector\RouterDataCollector

RouterDataCollector.

@author Fabien Potencier <fabien@symfony.com>

Hierarchy

Expanded class hierarchy of RouterDataCollector

File

vendor/symfony/http-kernel/DataCollector/RouterDataCollector.php, line 24

Namespace

Symfony\Component\HttpKernel\DataCollector
View source
class RouterDataCollector extends DataCollector {
  protected $controllers;
  public function __construct() {
    $this->controllers = new \SplObjectStorage();
    $this->data = array(
      'redirect' => false,
      'url' => null,
      'route' => null,
    );
  }

  /**
   * {@inheritdoc}
   */
  public function collect(Request $request, Response $response, \Exception $exception = null) {
    if ($response instanceof RedirectResponse) {
      $this->data['redirect'] = true;
      $this->data['url'] = $response
        ->getTargetUrl();
      if ($this->controllers
        ->contains($request)) {
        $this->data['route'] = $this
          ->guessRoute($request, $this->controllers[$request]);
      }
    }
    unset($this->controllers[$request]);
  }
  protected function guessRoute(Request $request, $controller) {
    return 'n/a';
  }

  /**
   * Remembers the controller associated to each request.
   *
   * @param FilterControllerEvent $event The filter controller event
   */
  public function onKernelController(FilterControllerEvent $event) {
    $this->controllers[$event
      ->getRequest()] = $event
      ->getController();
  }

  /**
   * @return bool Whether this request will result in a redirect
   */
  public function getRedirect() {
    return $this->data['redirect'];
  }

  /**
   * @return string|null The target URL
   */
  public function getTargetUrl() {
    return $this->data['url'];
  }

  /**
   * @return string|null The target route
   */
  public function getTargetRoute() {
    return $this->data['route'];
  }

  /**
   * {@inheritdoc}
   */
  public function getName() {
    return 'router';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DataCollector::$data protected property
DataCollector::$valueExporter private property
DataCollector::serialize public function 1
DataCollector::unserialize public function 1
DataCollector::varToString protected function Converts a PHP variable to a string.
RouterDataCollector::$controllers protected property
RouterDataCollector::collect public function Collects data for the given Request and Response. Overrides DataCollectorInterface::collect
RouterDataCollector::getName public function Returns the name of the collector. Overrides DataCollectorInterface::getName
RouterDataCollector::getRedirect public function
RouterDataCollector::getTargetRoute public function
RouterDataCollector::getTargetUrl public function
RouterDataCollector::guessRoute protected function
RouterDataCollector::onKernelController public function Remembers the controller associated to each request.
RouterDataCollector::__construct public function