Пример #1
0
 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));
 }
 public function __construct($id, $parameterName = null, $parameterDefault = null, $parameterPattern = null)
 {
     parent::__construct($id);
     $this->parameterName = $parameterName ? $parameterName : $id;
     $this->parameterPattern = $parameterDefault;
     $this->parameterDefault = $parameterPattern;
 }
 public function configure(NestedRoute $nestedRoute)
 {
     $path = $nestedRoute->getParentPath();
     if ($path) {
         $re = "/^(.*?)\\.(.*)\$|^(.*?)\$/m";
         preg_match($re, $path, $matches);
         if (isset($matches[3])) {
             $admin = $matches[3];
             $child = null;
         } else {
             $admin = $matches[1];
             $child = $matches[2];
         }
         $parentRoute = $this->nRouteManager->getNestedRoute($admin, $child);
         if ($parentRoute) {
             $parentRoute->addChild($nestedRoute);
         }
     }
 }
 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"];
 }
 public function __construct($id)
 {
     parent::__construct($id);
 }