コード例 #1
0
ファイル: Router.php プロジェクト: rgr-rgr/volkszaehler.org
 /**
  * Processes the request
  *
  * Example: http://sub.domain.local/middleware.php/channel/550e8400-e29b-11d4-a716-446655440000/data.json?operation=edit&title=New Title
  */
 public function run()
 {
     $operation = self::getOperation($this->view->request);
     $context = explode('/', substr($this->pathInfo, 1, strrpos($this->pathInfo, '.') - 1));
     // parse pathinfo
     if (!array_key_exists($context[0], self::$controllerMapping)) {
         if (empty($context[0])) {
             throw new \Exception('Missing context');
         } else {
             throw new \Exception('Unknown context: \'' . $context[0] . '\'');
         }
     }
     $class = self::$controllerMapping[$context[0]];
     $controller = new $class($this->view, $this->em);
     $result = $controller->run($operation, array_slice($context, 1));
     $this->view->add($result);
 }