コード例 #1
0
 public function testCurrentStepName()
 {
     $this->assertNull($this->workflowItem->getCurrentStep());
     $value = $this->getMockBuilder('Oro\\Bundle\\WorkflowBundle\\Entity\\WorkflowStep')->disableOriginalConstructor()->getMock();
     $this->workflowItem->setCurrentStep($value);
     $this->assertEquals($value, $this->workflowItem->getCurrentStep());
 }
コード例 #2
0
ファイル: AclManager.php プロジェクト: Maksold/platform
 /**
  * @param WorkflowItem $workflowItem
  * @return WorkflowItem
  * @throws WorkflowException
  */
 public function updateAclIdentities(WorkflowItem $workflowItem)
 {
     $workflow = $this->workflowRegistry->getWorkflow($workflowItem->getWorkflowName());
     $definition = $workflowItem->getDefinition();
     $currentStepName = $workflowItem->getCurrentStep()->getName();
     $aclIdentities = array();
     foreach ($definition->getEntityAcls() as $entityAcl) {
         if ($entityAcl->getStep()->getName() == $currentStepName) {
             $attributeName = $entityAcl->getAttribute();
             $attribute = $workflow->getAttributeManager()->getAttribute($attributeName);
             $entity = $workflowItem->getData()->get($attributeName);
             if (!$entity) {
                 continue;
             }
             if (!is_object($entity)) {
                 throw new WorkflowException(sprintf('Value of attribute "%s" must be an object', $attributeName));
             }
             $aclIdentity = new WorkflowEntityAclIdentity();
             $aclIdentity->setAcl($entityAcl)->setEntityClass($attribute->getOption('class'))->setEntityId($this->doctrineHelper->getSingleEntityIdentifier($entity));
             $aclIdentities[] = $aclIdentity;
         }
     }
     $workflowItem->setAclIdentities($aclIdentities);
     return $workflowItem;
 }
コード例 #3
0
ファイル: Workflow.php プロジェクト: ramunasd/platform
 /**
  * Get transitions for existing workflow item.
  *
  * @param WorkflowItem $workflowItem
  * @return Collection|Transition[]
  * @throws UnknownStepException
  */
 public function getTransitionsByWorkflowItem(WorkflowItem $workflowItem)
 {
     $currentStepName = $workflowItem->getCurrentStep()->getName();
     $currentStep = $this->stepManager->getStep($currentStepName);
     if (!$currentStep) {
         throw new UnknownStepException($currentStepName);
     }
     $transitions = new ArrayCollection();
     $transitionNames = $currentStep->getAllowedTransitions();
     foreach ($transitionNames as $transitionName) {
         $transition = $this->transitionManager->extractTransition($transitionName);
         $transitions->add($transition);
     }
     return $transitions;
 }