public function testDefinition() { $this->assertNull($this->workflowItem->getDefinition()); $value = new WorkflowDefinition(); $this->workflowItem->setDefinition($value); $this->assertEquals($value, $this->workflowItem->getDefinition()); }
/** * @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; }
public function testPrePersist() { $entity = new WorkflowItem(); $entity->setWorkflowName('test_workflow'); $workflowDefinition = new WorkflowDefinition(); $workflowDefinition->setName('test_workflow'); $em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->setMethods(array('find'))->disableOriginalConstructor()->getMock(); $em->expects($this->once())->method('find')->with('OroWorkflowBundle:WorkflowDefinition', 'test_workflow')->will($this->returnValue($workflowDefinition)); $this->subscriber->prePersist(new LifecycleEventArgs($entity, $em)); $this->assertSame($workflowDefinition, $entity->getDefinition()); }
/** * Deserialize data of WorkflowItem * * @param WorkflowItem $workflowItem */ protected function deserialize(WorkflowItem $workflowItem) { // Pass serializer into $workflowItem to make lazy loading of workflow item data. $workflowItem->setSerializer($this->serializer, $this->format); // Set related entity $relatedEntity = $this->doctrineHelper->getEntityReference($workflowItem->getDefinition()->getRelatedEntity(), $workflowItem->getEntityId()); $workflowItem->setEntity($relatedEntity); }