Skip to content

[Routing][ServiceRouterLoader] Use a private service #30402

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

Closed
fancyweb opened this issue Feb 27, 2019 · 3 comments
Closed

[Routing][ServiceRouterLoader] Use a private service #30402

fancyweb opened this issue Feb 27, 2019 · 3 comments

Comments

@fancyweb
Copy link
Contributor

When using a service router loader (type: service), the service has to be public. It would be nice if it was not mandatory (to follow Symfony good practices).

The implementation I thought of would be to tag custom router loader services with a new tag, to be able to inject them in the ServiceRouterLoader service in a second "private" service locator. Creating another loader for private services would be bad for DX.

The proposed implementation might be bad for DX actually since it forces developers to add a tag. However, that would works great if there was a concrete interface to implement for service router loader because it could be autoconfigured.

I also thought that we could parse all routes config files before compilation to get the referenced services, but I think that would involve a lot of code and probably be overkill.

Is the whole thing overkill ? Does anyone have a better / easier implementation idea ? @Tobion @nicolas-grekas @stof

@chalasr
Copy link
Member

chalasr commented Apr 6, 2019

👍 for the intend. IIUC the steps needed are:

  • Add the tag (+ autoconfiguration interface perhaps)
  • Update ServiceRouteLoader so that it takes a ServiceLocator as 2nd constructor arg (the locator contains only tagged route loaders)
  • Update getServiceObject to make it trigger a deprecation notice in case the new locator doesn't know about the given $id + use the DIC as fallback
  • Stop using the DIC in 5.0 (removing it from the constructor)

@symfony/deciders any blocker?

@nicolas-grekas
Copy link
Member

Looks good to me, let's remove the container.

@fancyweb
Copy link
Contributor Author

fancyweb commented Apr 6, 2019

Alright I'm gonna work on it this week-end!

@fabpot fabpot closed this as completed Aug 9, 2019
fabpot added a commit that referenced this issue Aug 9, 2019
…rs (fancyweb)

This PR was merged into the 4.4 branch.

Discussion
----------

[FrameworkBundle][Routing] Private service route loaders

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #30402
| License       | MIT
| Doc PR        | symfony/symfony-docs#11337

Continuation of #30926.

~Please review only the 2nd commit, I'm building this on top of #32582

Commits
-------

64aa2c8 [FrameworkBundle][Routing] Private service route loaders
symfony-splitter pushed a commit to symfony/framework-bundle that referenced this issue Aug 9, 2019
…rs (fancyweb)

This PR was merged into the 4.4 branch.

Discussion
----------

[FrameworkBundle][Routing] Private service route loaders

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | symfony/symfony#30402
| License       | MIT
| Doc PR        | symfony/symfony-docs#11337

Continuation of symfony/symfony#30926.

~Please review only the 2nd commit, I'm building this on top of symfony/symfony#32582

Commits
-------

64aa2c8529 [FrameworkBundle][Routing] Private service route loaders
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants