public function __invoke() { $that = new ClassReflector($this); foreach ($that->getMethods() as $method) { if ($this->isValidMethod($method)) { $method->invokeArgs($this, func_get_args()); } } return $this; }
public function bootstrap() { $that = new ClassReflector($this); foreach ($that->getMethods() as $method) { if ($this->isValidMethod($method)) { $method->invoke($this); } } return $this; }
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; }
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 getIterator() { $class = new ClassReflector($this); $this->methods = new ArrayIterator(); foreach ($class->getMethods() as $method) { if ($method->isInherited() || $method->isMagic()) { continue; } $this->methods[$method->getName()] = $method->getClosure($this); } return $this->methods; }
public function configure(ContainerInterface $container) { $class = new ClassReflector($this); foreach ($class->getMethods() as $method) { if ($this->isValidMethod($method)) { $this->applyAliases($container, $method); $this->applyDependencies($container, $method); $this->applyTransient($container, $method); $this->applyTypes($container, $method); $container->set($method->getName(), $method->getClosure($this)); } } return $this; }
public function __invoke(ContainerInterface $container) { $class = new Reflection\ClassReflector($this); foreach ($class->getMethods() as $method) { if ($this->isValidMethod($method)) { $this->applyAliases($container, $method); $this->applyTransient($container, $method); $this->applyTypes($container, $method); $container->register($method->getName(), $method->getClosure($this)); } } if (method_exists($this, self::METHOD_INIT)) { $this->{self::METHOD_INIT}($container); } return $this; }
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()); }