Esempio n. 1
0
 /**
  * Execute endpoint and return it's result.
  *
  * @param ServerRequestInterface $request
  * @param ResponseInterface      $response
  * @return mixed
  */
 protected function execute(ServerRequestInterface $request, ResponseInterface $response)
 {
     if ($this->target instanceof \Closure) {
         $reflection = new \ReflectionFunction($this->target);
         return $reflection->invokeArgs($this->container->resolveArguments($reflection, compact('request', 'response')));
     }
     //Calling pipeline target (do we need reflection here?)
     return call_user_func($this->target, $request, $response);
 }
Esempio n. 2
0
 /**
  * @param ContainerInterface $container
  */
 public function __construct(ContainerInterface $container)
 {
     $this->container = $container;
     if (method_exists($this, SaturableInterface::SATURATE_METHOD) && !$this instanceof SaturableInterface) {
         $method = new \ReflectionMethod($this, SaturableInterface::SATURATE_METHOD);
         //Executing init method
         call_user_func_array([$this, SaturableInterface::SATURATE_METHOD], $container->resolveArguments($method));
     }
 }
Esempio n. 3
0
 /**
  * @final For my own reasons (i have some ideas), please use SaturableInterface and init method.
  * @param InputManager       $input
  * @param ContainerInterface $container
  */
 public final function __construct(InputManager $input, ContainerInterface $container)
 {
     $this->input = $input;
     foreach ($this->schema as $field => $source) {
         list($source, $origin) = $this->parseSource($field, $source);
         if (!method_exists($input, $source)) {
             throw new FilterException("Undefined source '{$source}'.");
         }
         //Receiving value as result of InputManager method
         $this->setField($field, call_user_func([$input, $source], $origin), true);
     }
     if (method_exists($this, SaturableInterface::SATURATE_METHOD) && !$this instanceof SaturableInterface) {
         $method = new \ReflectionMethod($this, SaturableInterface::SATURATE_METHOD);
         //Executing init method
         call_user_func_array([$this, SaturableInterface::SATURATE_METHOD], $container->resolveArguments($method));
     }
 }
Esempio n. 4
0
 /**
  * {@inheritdoc}
  *
  * Pass execution to "perform" method using container to resolve method dependencies.
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $reflection = new \ReflectionMethod($this, 'perform');
     $reflection->setAccessible(true);
     return $reflection->invokeArgs($this, $this->container->resolveArguments($reflection, compact('input', 'output')));
 }