prismicio / SymfonyBundle

Inntegrates the http://prismic.io php-kit with the Symfony Framework
http://prismic.io
8 stars 11 forks source link

Link resolver as a service #11

Open robinvdvleuten opened 10 years ago

robinvdvleuten commented 10 years ago

The link resolver instance is now injected as a service for easier overwriting from other bundles through for example compiler passes.

CHH commented 9 years ago

:+1:

CHH commented 9 years ago

@erwan What would need to be done to get that merged?

This would make setup for previews much easier. Currently I've to make my own DefaultController to use my custom link resolver to resolve previews. With this PR I can simply configure my link resolver as the default.

erwan commented 9 years ago

Hi,

I'm not an expert at Symfony, are you positive it's something that everyone would want to use or is there some downside to it?

CHH commented 9 years ago

Hi,

I've custom templates for every document type and collection in Prismic. The templates are handled by custom controllers and actions, because they need some other data, or do some filtering as well. Therefore I need a custom link resolver so every link links to the right custom controllers/actions. I also need my custom link resolver to resolve the preview links to my custom controllers/actions (when clicking preview in Prismic).

I think this is a good idea because:

  1. It's something that's generally a good idea to do in Symfony. The link resolver is an extension point of the SDK, so it should be extendable in the bundle. And you can only do that through a compiler pass or the services.yml if it's a service.
  2. I would say as long as this bundle doesn't provide a more elaborate defined structure (e.g. one template per document type, collection templates) users will need to do their own custom controllers and templates. Therefore they need a custom link resolver to override the routes.

Does that make sense?