예제 #1
0
 public function __call($action, array $context = [])
 {
     if (!method_exists($this, $action)) {
         Exception::toss('The action "%s" is not defined in the controller "%s".', $action, get_class($this));
     }
     $class = new ClassReflector($this);
     $method = $class->getMethod($action);
     $this->applyClassFilters($class, $method, $context);
     $this->applyActionFilters($class, $method, $context);
     return $method->invokeArgs($this, $context);
 }
 public function resolveConstructorParams(Reflection\ClassReflector $class)
 {
     $params = [];
     $container = $this->getContainer();
     if ($container && $class->hasMethod('__construct')) {
         foreach ($class->getMethod('__construct')->getParameters() as $param) {
             $params[] = $container($param->getName());
         }
     }
     return $params;
 }
예제 #3
0
 private function invoke($action)
 {
     if (!method_exists($this, $action)) {
         if (method_exists($this, '__call')) {
             return $this->__call($action, $this->request()->getParams());
         } else {
             Exception::toss('The action "%s" is not defined in the controller "%s" and "__call" was not defined to catch it.', $action, get_class($this));
         }
     }
     $class = new ClassReflector($this);
     $method = $class->getMethod($action);
     $params = $this->request->getParams();
     if ($this->filter) {
         $this->applyClassFilters($class, $method);
         $this->applyActionFilters($class, $method);
     }
     return $method->invokeArgs($this, $this->request->getParams());
 }