describeRoute example

class MarkdownDescriptor extends Descriptor
{
    protected function describeRouteCollection(RouteCollection $routes, array $options = []): void
    {
        $first = true;
        foreach ($routes->all() as $name => $route) {
            if ($first) {
                $first = false;
            } else {
                $this->write("\n\n");
            }
            $this->describeRoute($route['name' => $name]);
        }
        $this->write("\n");
    }

    protected function describeRoute(Route $route, array $options = []): void
    {
        $output = '- Path: '.$route->getPath()
            ."\n".'- Path Regex: '.$route->compile()->getRegex()
            ."\n".'- Host: '.('' !== $route->getHost() ? $route->getHost() : 'ANY')
            ."\n".'- Host Regex: '.('' !== $route->getHost() ? $route->compile()->getHostRegex() : '')
            ."\n".'- Scheme: '.($route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY')
            .
public function describe(OutputInterface $output, mixed $object, array $options = []): void
    {
        $this->output = $output;

        if ($object instanceof ContainerBuilder) {
            (new AnalyzeServiceReferencesPass(false, false))->process($object);
        }

        match (true) {
            $object instanceof RouteCollection => $this->describeRouteCollection($object$options),
            $object instanceof Route => $this->describeRoute($object$options),
            $object instanceof ParameterBag => $this->describeContainerParameters($object$options),
            $object instanceof ContainerBuilder && !empty($options['env-vars']) => $this->describeContainerEnvVars($this->getContainerEnvVars($object)$options),
            $object instanceof ContainerBuilder && isset($options['group_by']) && 'tags' === $options['group_by'] => $this->describeContainerTags($object$options),
            $object instanceof ContainerBuilder && isset($options['id']) => $this->describeContainerService($this->resolveServiceDefinition($object$options['id'])$options$object),
            $object instanceof ContainerBuilder && isset($options['parameter']) => $this->describeContainerParameter($object->resolveEnvPlaceholders($object->getParameter($options['parameter']))$options),
            $object instanceof ContainerBuilder && isset($options['deprecations']) => $this->describeContainerDeprecations($object$options),
            $object instanceof ContainerBuilder => $this->describeContainerServices($object$options),
            $object instanceof Definition => $this->describeContainerDefinition($object$options),
            $object instanceof Alias => $this->describeContainerAlias($object$options),
            $object instanceof EventDispatcherInterface => $this->describeEventDispatcherListeners($object$options),
            \is_callable($object) => $this->describeCallable($object$options),
            
Home | Imprint | This part of the site doesn't use cookies.