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

Add Twig functions for cmf_document_path and cmf_document_url #90

Closed
benglass opened this issue Dec 16, 2013 · 4 comments
Closed

Add Twig functions for cmf_document_path and cmf_document_url #90

benglass opened this issue Dec 16, 2013 · 4 comments

Comments

@benglass
Copy link
Member

Currently there is support for generating URLs for cmf documents using the symfony path and url twig functions but it would be nice to have a dedicated function that only generates CMF-based routes for the following reasons:

  1. It might be better NOT to throw a RouteNotFoundException for these kind of routes because they are volatile (user's can often edit them and move them) and having this throw exceptions to the template is not desired
  2. In a multi-domain situation these functions would ensure that routes being generated for a site other than the current one would always be generated as absolute although this logic would perhaps live in a DomainAwareGenerator

There is discussion happening around this here symfony-cmf/routing-bundle#178 but there is nothing stopping us from creating these functions using the current route generator rather than the chain route generator and also implementing the don't throw exceptions approach.

How should exceptions be handled? You could have a $throw boolean method in the constructor for the twig extension that is set based on the kernel.debug parameter (so it would throw exceptions in dev but not production. This might not be ideal because it would make it hard to work on a page that was throwing exceptions. Perhaps it could just log these exceptions in dev as critical errors.

Also not sure if this should be in Routing or RoutingBundle. Its not symfony specific so I put it here.

@dbu
Copy link
Member

dbu commented Dec 17, 2013

i think route generation should always work outside the current domain context, and we need a separate generator for that, as discussed in symfony-cmf/symfony-cmf#182

i think it makes sense to have these functions, still go through the normal chain router when generating but catch all exceptions and log them on a configurable level. maybe you want to know even in prod so you can fix things occasionally. for dev, if you want to get fancy we can also (later) add a feature to the debug toolbar.

the support for uuid + path to make editing links more stable should just go into the cmf route generator and not be specific to these twig functions.

@dbu
Copy link
Member

dbu commented Apr 15, 2014

@benglass do you want to do a PR for those functions?

@dbu
Copy link
Member

dbu commented Apr 15, 2014

btw, this should be on RoutingBundle as here in the component we don't know about twig.

@benglass
Copy link
Member Author

Moved to symfony-cmf/routing-bundle#239

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

2 participants