public function onRoute(MvcEvent $e) { $routeMatch = $e->getRouteMatch(); if (!$routeMatch) { return; } $config = $e->getApplication()->getServiceManager()->get('Config'); if (!isset($config['router'], $config['router']['routes'])) { return; } $config = (array) $config['router']['routes']; $routeName = $routeMatch->getMatchedRouteName(); if (false !== strpos($routeName, self::CHILD_ROUTE_TOKEN)) { $part = strtok($routeName, self::CHILD_ROUTE_TOKEN); while ($part !== false) { if (isset($config[$part])) { $config = (array) $config[$part]; } else { if (isset($config['child_routes'], $config['child_routes'][$part])) { $config = (array) $config['child_routes'][$part]; } else { return; } } $part = strtok(self::CHILD_ROUTE_TOKEN); } } else { if (isset($config[$routeName])) { $config = (array) $config[$routeName]; } else { return; } } if (!isset($config[Config::CONFIG_NAMESPACE])) { return; } $config = $config[Config::CONFIG_NAMESPACE]; $this->config->merge($config); }