Skip to content

Support Route attribute when extended #2559

@CxDevLead

Description

@CxDevLead

In your controllers, when you use the #[Route] attribute, the plugin marks the method as used, and adds a green arrow icon.:
Image

Symfony has added the ability to extend routes, which enables a user to pre-define properties, for example:

<?php

declare(strict_types=1);

namespace Common\Route;

use Attribute;
use Common\HttpMethod;
use Symfony\Component\Routing\Attribute\Route;

#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_CLASS | Attribute::TARGET_METHOD)]
class RoutePut extends Route
{
    public function __construct(
        string|array|null $path = null,
        ?string           $name = null,
        array             $requirements = [],
        array             $options = [],
        array             $defaults = [],
        ?string           $host = null,
        array|string      $schemes = [],
        ?string           $condition = null,
        ?int              $priority = null,
        ?string           $locale = null,
        ?string           $format = null,
        ?bool             $utf8 = null,
        ?bool             $stateless = null,
        ?string           $env = null,
    )
    {
        parent::__construct(
            $path,
            $name,
            $requirements,
            $options,
            $defaults,
            $host,
            HttpMethod::Put,
            $schemes,
            $condition,
            $priority,
            $locale,
            $format,
            $utf8,
            $stateless,
            $env,
        );
    }
}

This extends the Route and restricted the http methods to 'PUT'.

However, the extension does not identify the controller method as a route, as 'RoutePut' is not identified as a valid route, even though it is.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions