Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

routing loader does not resolve parameters? #13793

Closed
cordoval opened this issue Feb 25, 2015 · 7 comments
Closed

routing loader does not resolve parameters? #13793

cordoval opened this issue Feb 25, 2015 · 7 comments

Comments

@cordoval
Copy link
Contributor

I know in DI container things such as services get resolved like with parameters %kernel.root_dir%

however on routing.yml

assign_routes:
   resource: "Vendor\\Application\\Frontend\\CaseManagement\\Controller\\AssignController"
   type: "annotation"

This needs to happen because:

assign_routes:
   resource: "%kernel.root_dir%/../src/Vendor/Application/Frontend/CaseManagement/Controller"
   type: "annotation"

wouldn't work (notice is not a bundle).

I checked on the loader but cannot see where exactly I need to wire things in order to make things work.

Is this a limitation of symfony? perhaps we can discuss ways to support this in 2.6+?

👴

@cordoval
Copy link
Contributor Author

@javiereguiluz
Copy link
Member

@cordoval this is indeed a limitation of the way parameters are resolved. See symfony/symfony-docs#4207

@wouterj
Copy link
Member

wouterj commented Mar 1, 2015

@javiereguiluz the issue you linked to is about DI configuration imports. In such cases, the parameters are not yet all loaded and that means it's not possible to use them for the imports.

However, when the routes are loaded, the container is full build and the parameter bag is frozen. This means it should be possible to use parameters in the imports. According to @cordoval, this feature does not yet exist.

I'm not sure if I do want it to exist for routing. As it'll then confuse many people: it doesn't work and will never work for container config, but it does work for routing?

@cordoval
Copy link
Contributor Author

cordoval commented Mar 1, 2015

perhaps a work around would be to include a routing.php ? i am trying to think of options as this limitation is weird, if it is possible it will enable arbitrary folders which today's development is desirable for more comfortable folder structure.

@SoboLAN
Copy link

SoboLAN commented Mar 1, 2015

Please note that something like this:

assign_routes:
    resource: "Vendor\\Application\\Frontend\\CaseManagement\\Controller\\AssignController"
    type: "annotation"
    prefix: /%kernel.debug%/some/path/here

does work (I just tried it a few minutes ago on 2.6.4, to be sure).

So, at this point, all parameters are indeed already loaded and they can be used (I also tried it with parameters that are NOT part of the kernel).

(Just wanted to make sure this is known by the future people who will wander on this page...)

@wouterj
Copy link
Member

wouterj commented Mar 1, 2015

This is quite a hard one to solve though. Parameters on the path (prefix) are quite simple, as they can be integrated by a router (before matching, first resolve the parameters in a path). This can be done on framework level (https://github.com/symfony/FrameworkBundle/blob/master/Routing/Router.php) and keeps the Routing component pure.

However, this loading is handled by the loaders inside the Routing component. If this functionality has to be implemented there, it means the FrameworkBundle has to overwrite all file loaders in order to make them parameters aware (the import syntaxes are different per format).

I'm afraid it won't be nice or very simple. Besides that, I still think that being inconsistent isn't great (not being able to use it in imports is already inconsistent, but making it possible for routing and not for DI is even more consistent). It may be clear that I'm leaning a bit towards the -1 side (fortunately for you, I don't have any voting priveleges, just wanted to share my opinion).

@cordoval
Copy link
Contributor Author

cordoval commented Mar 2, 2015

thanks @SoboLAN straight to the point

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants