hello
I am working on a project where we will provide a site with its own
routes depending on the incoming hostname,
so to make best use of the caching it is important for each site to
have its own routing cache file, I have implemented
this by extending the `Router` and overriding the getCacheFile() method:
public function getCacheFile($class, $extension = 'php')
{
return
$this->options['cache_dir'].'/'.$class.'.site-'.$this->getSiteManager()->getSite()->get('id').'.'.$extension;
}
and then manually overriding the router in the DIC config to add the
method to inject the "SiteManager":
$container->register('router', 'yProx\CmsBundle\Site\Routing\SiteRouter')
->addMethodCall('setSiteManager', array(new
Reference('yprox.site.manager')))
->addArgument(new Reference('routing.loader'))
->addArgument('%routing.resource%')
->addArgument(array(
"cache_dir" => "%kernel.cache_dir%",
"debug" => "%kernel.debug%",
"generator_class" => "%router.options.generator_class%",
"generator_base_class" =>
"%router.options.generator_base_class%",
"generator_dumper_class" =>
"%router.options.generator_dumper_class%",
"generator_cache_class" =>
"%kernel.name%_%kernel.environment%UrlGenerator",
"matcher_class" => "%router.options.matcher_class%",
"matcher_base_class" => "%router.options.matcher_base_class%",
"matcher_dumper_class" =>
"%router.options.matcher_dumper_class%",
"matcher_cache_class" =>
"%kernel.name%_%kernel.environment%UrlMatcher",
));
This is a bit cumbersome and really all I want to do is add the
"setSiteManager" method call to the existing
router definition, the problem is that the definition does not exist
at that moment. So it would have to be added
in a second pass --
- Is it possible to schedule a method call to be added to a
Definition that hasnt been defined yet?
- and/or is there a better way to override the routing
cache_dir/filename bearing in mind that I dont know the Site context
until the request is being processed?
Many thanks
dan
--
Dan Leech
Web Developer
www.dantleech.com
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en