Beispiel #1
0
 public static function create($a, $name, $inPattern = false)
 {
     if (is_string($a) && !$inPattern) {
         return new \Pattern($a);
     } elseif (is_string($a) && $inPattern) {
         return $a;
     } elseif (is_array($a)) {
         $pattern = new \Pattern();
         if (array_key_exists('get', $a)) {
             $pattern->set_get_options($a['get']);
         }
         if (array_key_exists('pattern', $a)) {
             if (is_array($a['pattern'])) {
                 foreach ($a['pattern'] as $p) {
                     $pattern->add_pattern(\Pattern::create($p, $name, true));
                 }
             } elseif (is_string($a['pattern'])) {
                 $pattern->add_pattern(\Pattern::create($a['pattern'], $name, true));
             }
         }
         if (array_key_exists('couple', $a)) {
             $pattern->handler->set_default_loader(\Loaders\Module::create($a, $name, true));
         }
         return $pattern;
     }
 }
Beispiel #2
0
 public static function create($a)
 {
     if (array_key_exists('module', $a)) {
         $route = new \Route($a['module']);
         if (array_key_exists('couple', $a)) {
             $route->handler->set_default_loader(\Loaders\Module::create($a, $a['module']));
         }
         if (array_key_exists('pattern', $a)) {
             $route->add_pattern($a['pattern']);
         }
         if (array_key_exists('first_pattern', $a)) {
             $route->set_first_pattern($a['first_pattern']);
         }
         return $route;
     }
 }