0 follower

Final Class Yiisoft\Router\Debug\RouterCollector

InheritanceYiisoft\Router\Debug\RouterCollector
ImplementsYiisoft\Yii\Debug\Collector\SummaryCollectorInterface
Uses TraitsYiisoft\Yii\Debug\Collector\CollectorTrait

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( \Psr\Container\ContainerInterface $container )
$container \Psr\Container\ContainerInterface

                public function __construct(private ContainerInterface $container)
{
}

            
collect() public method

public void collect ( float $matchTime )
$matchTime float

                public function collect(float $matchTime): void
{
    if (!$this->isActive()) {
        return;
    }
    $this->matchTime = $matchTime;
}

            
getCollected() public method

public array getCollected ( )

                public function getCollected(): array
{
    if (!$this->isActive()) {
        return [];
    }
    /**
     * @var RouteCollectionInterface|null $routeCollection
     */
    $routeCollection = $this->container->has(RouteCollectionInterface::class)
        ? $this->container->get(RouteCollectionInterface::class)
        : null;
    $currentRoute = $this->getCurrentRoute();
    $route = $this->getRouteByCurrentRoute($currentRoute);
    [$middlewares, $action] = $this->getMiddlewaresAndAction($route);
    $result = [
        'currentRoute' => null,
    ];
    if ($currentRoute !== null && $route !== null) {
        $result['currentRoute'] = [
            'matchTime' => $this->matchTime,
            'name' => $route->getData('name'),
            'pattern' => $route->getData('pattern'),
            'arguments' => $currentRoute->getArguments(),
            'host' => $route->getData('host'),
            'uri' => (string) $currentRoute->getUri(),
            'action' => $action,
            'middlewares' => $middlewares,
        ];
    }
    if ($routeCollection !== null) {
        $result['routesTree'] = $routeCollection->getRouteTree();
        $result['routes'] = $routeCollection->getRoutes();
        $result['routeTime'] = $this->matchTime;
    }
    return $result;
}

            
getSummary() public method

public array getSummary ( )

                public function getSummary(): array
{
    if (!$this->isActive()) {
        return [];
    }
    $currentRoute = $this->getCurrentRoute();
    $route = $this->getRouteByCurrentRoute($currentRoute);
    if ($currentRoute === null || $route === null) {
        return [];
    }
    [$middlewares, $action] = $this->getMiddlewaresAndAction($route);
    return [
        'matchTime' => $this->matchTime,
        'name' => $route->getData('name'),
        'pattern' => $route->getData('pattern'),
        'arguments' => $currentRoute->getArguments(),
        'host' => $route->getData('host'),
        'uri' => (string) $currentRoute->getUri(),
        'action' => $action,
        'middlewares' => $middlewares,
    ];
}