Esempio n. 1
0
 public function testMuxGetId()
 {
     $mux = new \Pux\Mux();
     $id = $mux->getId();
     ok(is_integer($id));
     is($id, $mux->getId());
 }
Esempio n. 2
0
File: Mux.php Progetto: number0/Pux
 public function mount($pattern, $mux, $options = array())
 {
     if ($mux instanceof \Pux\Controller) {
         $mux = $mux->expand();
     } else {
         if ((!is_object($mux) || !$mux instanceof Mux) && is_callable($mux)) {
             $mux($mux = new Mux());
         }
     }
     if ($this->expand) {
         $pcre = strpos($pattern, ':') !== false;
         // rewrite submux routes
         foreach ($mux->routes as $route) {
             // process for pcre
             if ($route[0] || $pcre) {
                 $newPattern = $pattern . ($route[0] ? $route[3]['pattern'] : $route[1]);
                 $routeArgs = PatternCompiler::compile($newPattern, array_merge_recursive($route[3], $options));
                 $this->appendPCRERoute($routeArgs, $route[2]);
             } else {
                 $this->routes[] = array(false, $pattern . $route[1], $route[2], isset($route[3]) ? array_merge($options, $route[3]) : $options);
             }
         }
     } else {
         $muxId = $mux->getId();
         $this->add($pattern, $muxId, $options);
         $this->submux[$muxId] = $mux;
     }
 }
Esempio n. 3
0
 public function testMuxId()
 {
     $mux = new Mux();
     $mux->add('/hello/:name', ['IndexController', 'indexAction']);
     ok($mux->getId());
 }