/**
  * @param Workflow $workflow
  * @param string $currentStepName
  * @return WorkflowItem
  */
 protected function createWorkflowItem(Workflow $workflow, $currentStepName = null)
 {
     $result = new WorkflowItem();
     $result->setCurrentStepName($currentStepName);
     $result->setWorkflowName($workflow->getName());
     return $result;
 }
 /**
  * @param Workflow $workflow
  * @param string $attributeName
  * @return \Oro\Bundle\WorkflowBundle\Model\Attribute
  * @throws SerializerException If attribute not found
  */
 protected function getAttribute(Workflow $workflow, $attributeName)
 {
     $attribute = $workflow->getAttributeManager()->getAttribute($attributeName);
     if (!$attribute) {
         throw new SerializerException(sprintf('Workflow "%s" has no attribute "%s"', $workflow->getName(), $attributeName));
     }
     return $attribute;
 }
 /**
  * @param Workflow $workflow
  * @throws AssemblerException
  */
 protected function validateWorkflow(Workflow $workflow)
 {
     $startTransitions = $workflow->getTransitionManager()->getTransitions()->filter(function (Transition $transition) {
         return $transition->isStart();
     });
     if (!$startTransitions->count()) {
         throw new AssemblerException(sprintf('Workflow "%s" does not contains neither start step nor start transitions', $workflow->getName()));
     }
     if ($workflow->getType() == Workflow::TYPE_ENTITY) {
         /** @var Step $step */
         foreach ($workflow->getStepManager()->getSteps() as $step) {
             if ($step->getFormOptions()) {
                 throw new AssemblerException(sprintf('Workflow "%s" has type "entity" and cannot support form options in step "%s"', $workflow->getName(), $step->getName()));
             }
         }
     }
 }
 /**
  * Returns EntityManager for entity.
  *
  * @param Workflow $workflow
  * @param Attribute $attribute
  * @return EntityManager
  * @throws SerializerException
  */
 protected function getEntityManager(Workflow $workflow, Attribute $attribute)
 {
     $entityClass = $attribute->getOption('class');
     $result = $this->registry->getManagerForClass($entityClass);
     if (!$result) {
         throw new SerializerException(sprintf('Attribute "%s" of workflow "%s" contains object of "%s", but it\'s not managed entity class', $attribute->getName(), $workflow->getName(), $entityClass));
     }
     return $result;
 }
Ejemplo n.º 5
0
 /**
  * @param string|Workflow|WorkflowItem|WorkflowDefinition $workflowIdentifier
  */
 public function activateWorkflow($workflowIdentifier)
 {
     if ($workflowIdentifier instanceof WorkflowDefinition) {
         $entityClass = $workflowIdentifier->getRelatedEntity();
         $workflowName = $workflowIdentifier->getName();
     } else {
         $workflow = $this->getWorkflow($workflowIdentifier);
         $entityClass = $workflow->getDefinition()->getRelatedEntity();
         $workflowName = $workflow->getName();
     }
     $this->setActiveWorkflow($entityClass, $workflowName);
 }
Ejemplo n.º 6
0
 /**
  * @param Workflow $workflow
  * @throws AssemblerException
  */
 protected function validateWorkflow(Workflow $workflow)
 {
     $startTransitions = $workflow->getTransitionManager()->getTransitions()->filter(function (Transition $transition) {
         return $transition->isStart();
     });
     if (!$startTransitions->count()) {
         throw new AssemblerException(sprintf('Workflow "%s" does not contains neither start step nor start transitions', $workflow->getName()));
     }
 }