Skip to content

[Console] router:match and expression language's condition breaks when using request variable #16968

@ymarillet

Description

@ymarillet

Hi there

Having a route defined like this

class MyController extends Controller
{
    /**
     * @Route(
     *     "/mycontroller/{type}",
     *     name="my_route",
     *     condition="service('myservice').isKnownType(request.get('type'))"
     * )
     */
    public function testAction($type)
    {
        //do something here
    }
}

Makes the router:match to go crazy because the Request object is unknown to the command line

app/console router:matches /mycontroller/supertype

[RuntimeException]
Unable to get a property on a non-object.

I believe that a request object should be created here. This is also a very simple example that could have a workaround, but this is not a discussion about that.

Note: the service function used in the expression language is an implementation of a custom expression language function, which is just returning a defined service
ya rly

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions