Please, how to dynamically add route base paths

86 views
Skip to first unread message

Bruno Reis

unread,
Aug 10, 2015, 9:49:23 PM8/10/15
to symfony-...@googlegroups.com
I need to enable some dynamically created nodes to work as route base paths. 

I tried to extend RoutingBundle\Doctrine\Phpcr\RouteProvider and change the class of the RouteProvider to add new prefixes to prefixCandidate, but prefixCandidate is private. 

I tried using "brute force and added all my candidates on the return of getCandidates, but then I got an error saying: "Can not determine the prefix. Either this is a new, unpersisted document or the listener that calls setPrefix is not set up correctly."

I tried to use other sub class for PrefixCandidate, but had no success and got a circular reference error (weird). 

I looked at the events but the only extend work on matched routes, not on the candidates.

Please, how do I add a dynamic route_basepath? 

David Buchmann

unread,
Aug 12, 2015, 2:58:29 AM8/12/15
to symfony-...@googlegroups.com
why do you need dynamic base paths? multisite?

one thing could be to look into expression language.

but if there is a good use case, we can also alter the provider to allow
to customize this. the reason to make things private is just to avoid
tight coupling - when there are good arguments to make something
overwriteable we can do it.

Bruno Reis

unread,
Aug 12, 2015, 8:15:30 PM8/12/15
to symfony-...@googlegroups.com
Where can I look into expression language? If there is one, this would probably solve my problem. 

I'm creating multiple "subsites" and I want the structure to be like: 

subsites
    subsite1 
        content
           contenttree
        menus
        extrastuff
    subsite2 
        content
           contenttree
        menus
        extrastuff
    
the content are also the routes. 

So I need to either: 

- make each content as a basepath and start the content tree with a "subsiteN" node

- make "subsites" the basepath, but skip the "contenttree" in the route generation


Thanks.

 


--
You received this message because you are subscribed to the Google Groups "symfony-cmf-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to symfony-cmf-us...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Buchmann

unread,
Aug 13, 2015, 2:55:28 AM8/13/15
to symfony-...@googlegroups.com
expression language is a way to make symfony configuration more dynamic
at runtime:

http://symfony.com/doc/current/components/expression_language/index.html

but not sure if that is enough in your case. what you want to look at is
probably the
Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\PrefixCandidates class.
you can probably extend that class to support your multi domain
scenario, overwriting getCandidates to first update the prefixes based
on the domain before calling the original getCandidates method.

why do you have content > contenttree? i would have expected to have
content | menus | routes | extrastuff all on the same level of the tree.
then you can restrict the prefix to /subsites/subsite1/routes

cheers,david

On 13.08.2015 02:15, Bruno Reis wrote:
> Where can I look into expression language? If there is one, this would
> probably solve my problem.
>
> I'm creating multiple "subsites" and I want the structure to be like:
>
> subsites
> subsite1
> content
> contenttree
> menus
> extrastuff
> subsite2
> content
> contenttree
> menus
> extrastuff
>
> the content are also the routes.
>
> So I need to either:
>
> - make each content as a basepath and start the content tree with a
> "subsiteN" node
>
> - make "subsites" the basepath, but skip the "contenttree" in the route
> generation
>
>
> Thanks.
>
>
>
> 2015-08-12 3:58 GMT-03:00 David Buchmann <da...@liip.ch
> <mailto:da...@liip.ch>>:
>
> why do you need dynamic base paths? multisite?
>
> one thing could be to look into expression language.
>
> but if there is a good use case, we can also alter the provider to allow
> to customize this. the reason to make things private is just to avoid
> tight coupling - when there are good arguments to make something
> overwriteable we can do it.
>
> --
> You received this message because you are subscribed to the Google
> Groups "symfony-cmf-users" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to symfony-cmf-us...@googlegroups.com
> <mailto:symfony-cmf-users%2Bunsu...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "symfony-cmf-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to symfony-cmf-us...@googlegroups.com
> <mailto:symfony-cmf-us...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

--
Liip AG // Agile Web Development // T +41 43 500 39 80
CH-8005 Zurich // PGP 0xA581808B // www.liip.ch
Reply all
Reply to author
Forward
0 new messages