You are here

class RoutingDataCollector in Devel 8.3

Same name and namespace in other branches
  1. 8 webprofiler/src/DataCollector/RoutingDataCollector.php \Drupal\webprofiler\DataCollector\RoutingDataCollector
  2. 8.2 webprofiler/src/DataCollector/RoutingDataCollector.php \Drupal\webprofiler\DataCollector\RoutingDataCollector
  3. 4.x webprofiler/src/DataCollector/RoutingDataCollector.php \Drupal\webprofiler\DataCollector\RoutingDataCollector

Provides a data collector which shows all available routes.

Hierarchy

Expanded class hierarchy of RoutingDataCollector

1 string reference to 'RoutingDataCollector'
webprofiler.services.yml in webprofiler/webprofiler.services.yml
webprofiler/webprofiler.services.yml
1 service uses RoutingDataCollector
webprofiler.routing in webprofiler/webprofiler.services.yml
Drupal\webprofiler\DataCollector\RoutingDataCollector

File

webprofiler/src/DataCollector/RoutingDataCollector.php, line 15

Namespace

Drupal\webprofiler\DataCollector
View source
class RoutingDataCollector extends DataCollector implements DrupalDataCollectorInterface {
  use StringTranslationTrait, DrupalDataCollectorTrait;

  /**
   * The route profiler.
   *
   * @var \Drupal\Core\Routing\RouteProviderInterface
   */
  protected $routeProvider;

  /**
   * Constructs a new RoutingDataCollector.
   *
   * @param \Drupal\Core\Routing\RouteProviderInterface $routeProvider
   *   The route provider.
   */
  public function __construct(RouteProviderInterface $routeProvider) {
    $this->routeProvider = $routeProvider;
  }

  /**
   * {@inheritdoc}
   */
  public function collect(Request $request, Response $response, \Exception $exception = NULL) {
    $this->data['routing'] = [];
    foreach ($this->routeProvider
      ->getAllRoutes() as $route_name => $route) {

      // @TODO Find a better visual representation.
      $this->data['routing'][] = [
        'name' => $route_name,
        'path' => $route
          ->getPath(),
      ];
    }
  }

  /**
   * @return int
   */
  public function getRoutesCount() {
    return count($this
      ->routing());
  }

  /**
   * Twig callback for displaying the routes.
   */
  public function routing() {
    return $this->data['routing'];
  }

  /**
   * {@inheritdoc}
   */
  public function getTitle() {
    return $this
      ->t('Routing');
  }

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

  /**
   * {@inheritdoc}
   */
  public function getPanelSummary() {
    return $this
      ->t('Defined routes: @route', [
      '@route' => $this
        ->getRoutesCount(),
    ]);
  }

  /**
   * {@inheritdoc}
   */
  public function getIcon() {
    return 'iVBORw0KGgoAAAANSUhEUgAAABUAAAAcCAYAAACOGPReAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAPxJREFUeNrkVsERREAQ7D0koXwlIAISkIGXvwAkoJSfHITg5SMUVR4eMuCxZ1xxV+5uuTL30lV8bPX09PSuFVJKcOOGP+DipLrrusoFdV1Lz/NgmiaKosC0XrAopYT0fc/f/jAMa41Pj23bkrpi9bRpGmRZ9lRKFSzLkl9UHMI4jijLcuaaSZMkQdd1fNMn5r0EHIFhGEjTlDenYRjCcZyHUnqRwXEcz77sYepM+Z1yTOEXZEFVVYcUba2iItsNcbr9IAiw5HMd1CJZtU1VpG3bIooi3gPF933keY43pb9gb1Bskdrap58luMjvRNO04wcK18RfIa59mbgLMAASuWsKAyoEhgAAAABJRU5ErkJggg==';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DrupalDataCollectorInterface::getData public function 8
DrupalDataCollectorInterface::getDrupalSettings public function 1
DrupalDataCollectorInterface::getLibraries public function Returns the libraries needed in detail panel. 2
DrupalDataCollectorInterface::hasPanel public function Returns true if this datacollector has a detail panel. 2
RoutingDataCollector::$routeProvider protected property The route profiler.
RoutingDataCollector::collect public function Collects data for the given Request and Response.
RoutingDataCollector::getIcon public function Returns the collector icon in base64 format. Overrides DrupalDataCollectorInterface::getIcon
RoutingDataCollector::getName public function Returns the name of the collector. Overrides DrupalDataCollectorInterface::getName
RoutingDataCollector::getPanelSummary public function Returns the string used in vertical tab summary. Overrides DrupalDataCollectorInterface::getPanelSummary
RoutingDataCollector::getRoutesCount public function
RoutingDataCollector::getTitle public function Returns the datacollector title. Overrides DrupalDataCollectorInterface::getTitle
RoutingDataCollector::routing public function Twig callback for displaying the routes.
RoutingDataCollector::__construct public function Constructs a new RoutingDataCollector.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.