protected function mergeRouteGroups()
{
$routes = $this->routes->all();
foreach ($this->routeGroups as $key => $group) {
// Spin through every route and merge the group filters onto the route.
foreach ($group->getRoutes() as $route) {
// If the group is nested within other groups we need to spin over those
// groups and merge in those filters as well. This allows a filter
// applied to an outer group be used on all routes within that
// group, even if they are within other groups.
if ($group->getGroupDepth() > 0) {
for ($i = count($this->routeGroups) - $group->getGroupDepth(); $i < count($this->routeGroups); ++$i) {
$this->mergeGroupFilters($route, $this->routeGroups[$i]);
}
}
// After any outer group filters have been applied we can merge the
// filters from the immediate parent group of the route. This is
// so that outer group filters are run first, since they are
// technically the first filters that are applied.
$this->mergeGroupFilters($route, $group);
}
$routes = array_merge($routes, $group->getRoutes());
}
$this->routes = new RouteCollection();
foreach ($routes as $name => $route) {
$this->routes->add($name, $route);
}
$this->routeGroups = array();
}