Esempio n. 1
0
 /**
  * Resolve logic from callable
  *
  * @param string $name
  * @param $callable
  * @return Logic
  */
 public static function resolve($name, $callable)
 {
     $invokable = Resolver::of($callable);
     $annotations = $invokable->annotations();
     $annotations['method'] = $invokable;
     return new Logic($name, $annotations);
 }
Esempio n. 2
0
 /**
  * Resolve invokable
  *
  * @param callable $resource
  * @param array $params
  * @return Runtime\Invokable
  *
  * @throws NotImplementedException
  */
 protected function resolve($resource, array $params = [])
 {
     $invokable = Runtime\Resolver::of($resource);
     if (!$invokable) {
         throw new NotImplementedException();
     }
     $invokable->params = $params;
     return $invokable;
 }
Esempio n. 3
0
 /**
  * Resolve logic method
  *
  * @param Context $context
  * @return Context
  *
  * @throws NotImplementedException
  */
 protected function resolve(Context $context)
 {
     $this->logger->debug('kernel.resolve: logic method resolving');
     // resolve invokable
     if (!$context->logic->method instanceof \Closure and !$context->logic->method instanceof Invokable) {
         $invokable = Resolver::of($context->logic->method);
         if (!$invokable) {
             throw new NotImplementedException('Invalid method for #' . $context->logic->name);
         }
         $context->logic->method = $invokable;
         $context->logic->override($invokable->annotations());
         $this->logger->debug('kernel.resolve: #' . $context->logic->name . ' method resolved');
     }
     return $context;
 }