Exemplo n.º 1
0
 public function create_route($module)
 {
     $route = new routing\routes\route($module, MODULES_PATH);
     $datas = func_get_args();
     $routing = $datas[1];
     $route->handler->default->configure($routing);
     // configuring the constructor with things it can get
     $first_pattern = array_key_exists('first_pattern', $routing) ? $routing['first_pattern'] : false;
     if ($first_pattern !== false) {
         $f = new routing\pattern();
         $f->add_regex($first_pattern);
         $route->set_first_pattern($f);
     }
     if (array_key_exists('pattern', $routing)) {
         if (is_array($routing['pattern'])) {
             foreach ($routing['pattern'] as $pattern) {
                 if (is_array($pattern)) {
                     $route->create_pattern_from_array($pattern);
                 } else {
                     $route->create_pattern($pattern, array(), false);
                 }
             }
         } else {
             $route->create_pattern($routing['pattern'], array(), array());
         }
     }
     $this->router->add_route($route);
 }
Exemplo n.º 2
0
 public function create_pattern($pattern, $params = array(), $permission = false, $overrides = false)
 {
     $p = new \routing\pattern();
     if ($overrides) {
         $p->set_override(true);
     }
     if (is_array($pattern)) {
         foreach ($pattern as $pa) {
             $p->add_regex($pa);
         }
     } else {
         $p->add_regex($pattern);
     }
     if ($permission != false) {
         $p->add_permission($permission);
     }
     $p->handler->default->configure($params);
     $this->patterns[] =& $p;
     return $p;
 }