public function load(NestedRoute $nestedRoute) { $filename = $this->cacheFolder . '/route_' . md5($nestedRoute->getId()); $cache = new ConfigCache($filename, $this->debug); if (!$cache->isFresh()) { $resources = array(); $reflection = new ReflectionObject($nestedRoute); $resources[] = new FileResource($reflection->getFileName()); $cache->write(serialize($this->flattenRouteFactory->getFlattenRoutes($nestedRoute)), $resources); } return unserialize(file_get_contents($filename)); }
private function _buildRouteStruct(NestedRoute $nestedRoute, $data = array(), &$structs = array()) { $definition = $this->getDefinition($nestedRoute->getNestedType()); foreach ($definition['functions'] as $function) { call_user_func_array(array($this, 'b' . $function), array($nestedRoute, &$data)); } $struct = array_merge_recursive($data, array('class' => $definition['flatten'], 'enabled' => $nestedRoute->isEnabled(), 'slug' => $nestedRoute->getId(), 'children' => array())); foreach ($nestedRoute->getChildren() as $nestedChild) { $struct['children'][] = $this->_buildRouteStruct($nestedChild, $data, $structs); } $class = $struct["class"]; if ($nestedRoute->getNestedType() == 'NestedEntityRoute') { $flattenRoute = new $class($this->router, $this->flattenRouteManager, $this->em, $struct); } else { $flattenRoute = new $class($this->router, $this->flattenRouteManager, $struct); } $struct["flatten_route"] = $flattenRoute; $structs[$struct["id"]] = $struct; return $struct["id"]; }