B
B
BonBon Slick2018-05-06 19:37:58
symfony
BonBon Slick, 2018-05-06 19:37:58

Generalize rules for routes?

<route id="logout" methods="GET" schemes="HTTPS" path="logout"  />

    <route id="login" methods="POST|GET" schemes="HTTPS" path="{_locale}/login"
           controller="here_goes_some_very_long_path_to_controller_LogInController::authenticate"/>

    <route id="dashboard" methods="GET" schemes="HTTPS" path="{_locale}/"
           controller="here_goes_some_very_long_path_to_controller_DashboardController::index"/>

    <route id="dashboard_default" methods="GET" schemes="HTTPS" path="/"
           controller="here_goes_some_very_long_path_to_controller_DashboardController::index"/>

First, I would like to create a group, all routes in a file or group are HTTPS only.
Also generalize the path to the controllers, what namespace or what is it, otherwise the full paths are too long.
All routes must contain the locale in the regexp path, that is, @#[email protected]!# is not a locale at all, if not, set the default one, and not from yml configs, but from the database. Then it would be possible to check whether there is such a locale, and set the default one.
Perhaps what other goodies could be done, or are not documented?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
voronkovich, 2018-05-06
@BonBonSlick

If you need to apply the configuration to a group of routes, you need to put them in a separate file and import them. You can see an example in the demo application (there is YAML, but everything is exactly the same for XML): https://github.com/symfony/demo/blob/master/config... Shortening
paths to controllers in a simple way will not work. However, you can try creating your own route loader: https://symfony.com/doc/current/routing/custom_rou...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question