-
Notifications
You must be signed in to change notification settings - Fork 76
Description
I started to work on a simple multi site bundle. The main idea is to have the sites direclty below /cms and have routes, content etc. as descendants of each site. For menu repository and route repository I can set the prefix based on the site (which is selected based on the host in a listener).
But this does not work for the IdPrefixListener when you want to generate Urls cross-site (the routes of the other site would have the wrong id prefix!).
So first I came up with referencing the site in each Route but realised that it is already (indirectly referenced through the parent). Currently I use this code, which would make the IdPrefixListener obsolete in all cases (not only multi site):
public function getStaticPrefix()
{
return $this->generateStaticPrefix($this->id, $this->getRoutesRoot()->getId());
}
/**
* return the first parent that is not instance of a route
*/
protected function getRoutesRoot()
{
$root = $this;
while ($root && $root instanceof \Symfony\Component\Routing\Route) {
$root = $root->getParent();
}
return $root;
}
If we used a "RouteDirectory" document as discussed before the class check could check for that document.