コード例 #1
0
ファイル: Router.php プロジェクト: akinyeleolubodun/PhireCMS2
 /**
  * Traverse the controllers based on the path
  *
  * @param  array $controllers
  * @param  int $depth
  * @return string
  */
 protected function traverseControllers($controllers, $depth = 0)
 {
     $next = $depth + 1;
     // If the path stem exists in the controllers, the traverse it
     if ($this->request->getPath($depth) != '' && array_key_exists('/' . $this->request->getPath($depth), $controllers)) {
         $this->basePath .= '/' . $this->request->getPath($depth);
         // If the next level is an array, traverse it
         if (is_array($controllers['/' . $this->request->getPath($depth)])) {
             return $this->traverseControllers($controllers['/' . $this->request->getPath($depth)], $next);
             // Else, return the controller class name
         } else {
             return isset($controllers['/' . $this->request->getPath($depth)]) ? $controllers['/' . $this->request->getPath($depth)] : null;
         }
         // Else check for the root '/' path
     } else {
         if (array_key_exists('/', $controllers)) {
             $this->basePath .= '/';
             // If the next level is an array, traverse it
             if (is_array($controllers['/'])) {
                 return $this->traverseControllers($controllers['/'], $next);
                 // Else, return the controller class name
             } else {
                 return isset($controllers['/']) ? $controllers['/'] : null;
             }
         }
     }
 }
コード例 #2
0
ファイル: RequestTest.php プロジェクト: nicksagona/PopPHP
 public function testGetPath()
 {
     $r = new Request();
     $r->setRequestUri('/test/something', '/admin');
     $this->assertEquals('test', $r->getPath(0));
     $this->assertEquals(2, count($r->getPath()));
 }