Skip to content

[Routing] optimize static requirement on compile #6838

Closed
@Tobion

Description

@Tobion

I sometimes see route definitions like the following where a requirement for a variable is no real regex but static text:

export:
    path: /export.{_format}
    defaults: { _controller: "Acme:Action:export" }
    requirements:
        _format: csv

This is equivalent to

export:
    path: /export.csv
    defaults: { _controller: "Acme:Action:export", _format: csv }

It can be optimized at compile time and would safe subpattern or even a complete regex match as in this case because the path is static now.
I already know how to implement this. This is just a reminder for me. ^^
Use if (preg_quote($requirement) === $requirement) for detection.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions