コード例 #1
0
ファイル: WorkflowManager.php プロジェクト: xamin123/platform
 /**
  * Perform reset of workflow item data - set $workflowItem and $workflowStep references into null
  * and remove workflow item. If active workflow definition has a start step,
  * then active workflow will be started automatically.
  *
  * @param WorkflowItem $workflowItem
  * @return WorkflowItem|null workflowItem for workflow definition with a start step, null otherwise
  * @throws \Exception
  */
 public function resetWorkflowItem(WorkflowItem $workflowItem)
 {
     $activeWorkflowItem = null;
     $entity = $workflowItem->getEntity();
     /** @var EntityManager $em */
     $em = $this->registry->getManagerForClass('OroWorkflowBundle:WorkflowItem');
     $em->beginTransaction();
     try {
         $this->getWorkflow($workflowItem)->resetWorkflowData($entity);
         $em->remove($workflowItem);
         $em->flush();
         $activeWorkflow = $this->getApplicableWorkflow($entity);
         if ($activeWorkflow->getStepManager()->hasStartStep()) {
             $activeWorkflowItem = $this->startWorkflow($activeWorkflow->getName(), $entity);
         }
         $em->commit();
     } catch (\Exception $e) {
         $em->rollback();
         throw $e;
     }
     return $activeWorkflowItem;
 }
コード例 #2
0
 public function testEntity()
 {
     $entity = new \stdClass();
     $this->assertSame($this->workflowItem, $this->workflowItem->setEntity($entity));
     $this->assertEquals($entity, $this->workflowItem->getEntity());
 }