/**
  * {@inheritDoc}     
  */
 public function injectResources(SagaInterface $saga)
 {
     $reflectionClass = ReflectionUtils::getClass($saga);
     foreach (ReflectionUtils::getMethods($reflectionClass) as $reflectionMethod) {
         if (null !== ($annotation = $this->reader->getMethodAnnotation($reflectionMethod, Inject::class))) {
             $service = $this->container->get($annotation->service);
             $reflectionMethod->invokeArgs($saga, array($service));
         }
     }
 }
 /**
  * {@inheritDoc}
  */
 public function injectResources(SagaInterface $saga)
 {
     $reflectionClass = ReflectionUtils::getClass($saga);
     foreach (ReflectionUtils::getMethods($reflectionClass) as $reflectionMethod) {
         if (null !== ($annotation = $this->reader->getMethodAnnotation($reflectionMethod, Inject::class))) {
             if (!array_key_exists($annotation->service, $this->resources)) {
                 throw new \RuntimeException(sprintf("Resource id \"%s\" is not registered", $annotation->service));
             }
             $reflectionMethod->invokeArgs($saga, array($this->resources[$annotation->service]));
         }
     }
 }
 public function getMessageHandlers(EventMessageInterface $event)
 {
     $found = array();
     $reflectionClass = ReflectionUtils::getClass($this->targetSaga);
     foreach (ReflectionUtils::getMethods($reflectionClass) as $method) {
         $annot = $this->reader->getMethodAnnotation($method, SagaEventHandler::class);
         if (null === $annot) {
             continue;
         }
         if (0 === count($method->getParameters())) {
             throw new \RuntimeException(sprintf("Invalid method signature detected of %s::%s. " . "Methods annotated with @SagaEventHandler must have exatly one parameter with the type of the message they handle. ", $reflectionClass->name, $method->name));
         }
         $parameter = current($method->getParameters());
         if (null !== $parameter->getClass() && $parameter->getClass()->name === $event->getPayloadType()) {
             $found[] = SagaMethodMessageHandler::getInstance($event, $method, $annot);
         }
     }
     return $found;
 }
 /**
  * @param $targetObject
  */
 public function __construct($targetObject)
 {
     $this->targetObject = $targetObject;
     $this->reader = new AnnotationReader();
     $this->reflectionClass = ReflectionUtils::getClass($this->targetObject);
 }