/**
  * {@inheritdoc}
  *
  * @throws \Exception If something went wrong during action execution.
  */
 public function transit()
 {
     $this->guardValidated();
     $this->transactionHandler->begin();
     try {
         $this->listener->onPreTransit($this->getWorkflow(), $this->getItem(), $this->getContext(), $this->getTransition()->getName());
         $state = $this->executeTransition();
         $this->stateRepository->add($state);
         $this->entityRepository->add($this->getItem()->getEntity());
     } catch (\Exception $e) {
         $this->transactionHandler->rollback();
         throw $e;
     }
     $this->transactionHandler->commit();
     $this->listener->onPostTransit($this->getWorkflow(), $this->getItem(), $this->getContext(), $state);
     return $state;
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function createItem(EntityId $entityId, $entity)
 {
     $stateHistory = $this->stateRepository->find($entityId);
     return Item::reconstitute($entityId, $entity, $stateHistory);
 }
Exemplo n.º 3
0
 function it_creates_an_item(EntityId $entityId, EntityId $entityId, StateRepository $stateRepository, State $state)
 {
     $stateRepository->find($entityId)->willReturn(array($state));
     $this->createItem($entityId, static::$entity)->shouldHaveType('Netzmacht\\Workflow\\Flow\\Item');
 }