Exemplo n.º 1
0
 /**
  * Loads a known Saga instance by its unique identifier. Returned Sagas must be {@link #commit(Saga) committed}
  * after processing.
  * Due to the concurrent nature of Sagas, it is not unlikely for a Saga to have ceased to exist after it has been
  * found based on associations. Therefore, a repository should return <code>null</code> in case a Saga doesn't
  * exists, as opposed to throwing an exception.
  *
  * @param string $sagaIdentifier The unique identifier of the Saga to load
  * @return SagaInterface The Saga instance, or <code>null</code> if no such saga exists
  */
 public function load($sagaIdentifier)
 {
     $dbSaga = $this->mongoTemplate->sagaCollection()->findOne(SagaEntry::queryByIdentifier($sagaIdentifier));
     if (null === $dbSaga) {
         return null;
     }
     $serializedSaga = new SimpleSerializedObject($dbSaga[SagaEntry::SERIALIZED_SAGA], new SimpleSerializedType($dbSaga[SagaEntry::SAGA_TYPE]));
     $saga = $this->serializer->deserialize($serializedSaga);
     if (null !== $this->injector) {
         $this->injector->injectResources($saga);
     }
     return $saga;
 }
 public function load($sagaId)
 {
     try {
         $result = $this->entityManager->createQuery("SELECT se FROM Governor\\Framework\\Saga\\Repository\\Orm\\SagaEntry se WHERE se.sagaId = :sagaId")->setParameter(":sagaId", $sagaId)->getSingleResult();
         $serializedSaga = new SerializedSaga($result->getSerializedSaga(), new SimpleSerializedType($result->getSagaType(), $result->getRevision()));
         $loadedSaga = $this->serializer->deserialize($serializedSaga);
         if (null !== $this->injector) {
             $this->injector->injectResources($loadedSaga);
         }
         $this->logger->debug("Loaded saga id [{id}] of type [{type}]", array('id' => $sagaId, 'type' => get_class($loadedSaga)));
         return $loadedSaga;
     } catch (NoResultException $ex) {
         return null;
     }
 }