Ejemplo n.º 1
0
 /**
  * @param $name
  * @return Controller
  * @throws BitException
  */
 protected static function createController($name)
 {
     $controller = Inflector::camelcase($name) . 'Controller';
     if (!class_exists($controller)) {
         throw new BitException("Controller class {$controller} not found.");
     }
     return new $controller();
 }
Ejemplo n.º 2
0
 /**
  * Execute and dispatch action
  * @param $name
  * @throws BitException
  */
 public function execute($name)
 {
     try {
         $name = !$name ? 'index' : $name;
         $action = Inflector::camelcase($name . '_action', true);
         $method = new \ReflectionMethod($this, $action);
         if (!$method->isPublic()) {
             throw new BitException(sprintf('Access to method %s::%s is not allowed', get_class($this), $method->getName()));
         }
         $this->view->render($name);
         $method->invoke($this);
     } catch (\Exception $e) {
         throw new BitException($e->getMessage());
     }
 }