symfony - Is it possible to add custom routes during compilation passes? -


i prepare external bundle , add routes during compilation passes. routes created on main app/config/config.yml settings.

i trying router containerbuilder in customcompilerpass via:

$definition = $container->getdefinition('router'); 

, got the service definition "router" not exist.

is possible add custom routes during compilation passes?

there's no way add routes @ compiler passes.
in order dynamicly load routes (aware of container parameters) i'd use custom route loader given in previous example

class myloader extends loader {     protected $params;      public function __construct($params)     {         $this->params = $params;     }      public function supports($resource, $type = null)     {         return $type === 'custom' && $this->params == 'yourlogic';     }      public function load($resource, $type = null)     {         // method called if suits parameters         $routes   = new routecollection;         $resource = '@acmefoobundle/resources/config/dynamic_routing.yml';         $type     = 'yaml';          $routes->addcollection($this->import($resource, $type));          return $routes;     } } 

routing.yml

_custom_routes:     resource: .     type:     custom 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -