Symfony2 combines the same routing

I have two packages in sf2, each of which has the same route. Example: / blog

Bundle A

user_blog: pattern: /blog defaults: { _controller: UserBlogBundle:Default:blog } 

Bundle b

 team_blog: pattern: /blog defaults: { _controller: TeamBlogBundle:Default:blog } 

and with the session parameter I find out which of the packages will run the request

excuse me,

I want to run the correct package according to the session parameter

Example

 {{ if($Parameter ='A') run user_blog else run team_blog }} 

I'm doing it:

 //src/project/TestBundle use Symfony\Component\Routing\RouteCollection; $collection = new RouteCollection(); $req = $this->getRequest(); if($req->server->get('SERVER_NAME') == 'www.domainA.com') $collection->addCollection($loader->import("@BundleABundle/Resources/config/routing.php")); else $collection->addCollection($loader->import("@BundleBBundle/Resources/config/routing.php")); return $collection; 

is this common

+4
source share
2 answers

This solution is host version 2.2 version

http://symfony.com/doc/master/components/routing/hostname_pattern.html

 Bundle A user_blog: pattern: /blog host: a.example.com defaults: { _controller: UserBlogBundle:Default:blog } Bundle B team_blog: pattern: /blog host: b.example.com defaults: { _controller: TeamBlogBundle:Default:blog } 
0
source

In my opinion, each route should be unique. You must create your application with this in mind. Otherwise, I think you might get some random behavior when accessing these routes.

0
source

All Articles