/** * @param WorkflowDefinition $definition * @return array */ protected function getDataAsArray(WorkflowDefinition $definition) { $entitiesData = array(); foreach ($definition->getWorkflowDefinitionEntities() as $entity) { $entitiesData[] = array('class' => $entity->getClassName()); } return array('name' => $definition->getName(), 'label' => $definition->getLabel(), 'enabled' => $definition->isEnabled(), 'start_step' => $definition->getStartStep(), 'configuration' => $definition->getConfiguration(), 'entities' => $entitiesData); }
public function testSetWorkflowDefinitionEntities() { $firstEntity = new WorkflowDefinitionEntity(); $firstEntity->setClassName('FirstClass'); $secondEntity = new WorkflowDefinitionEntity(); $secondEntity->setClassName('SecondClass'); $secondEntitySameClass = new WorkflowDefinitionEntity(); $secondEntitySameClass->setClassName('SecondClass'); $thirdEntity = new WorkflowDefinitionEntity(); $thirdEntity->setClassName('ThirdClass'); $newDefinition = new WorkflowDefinition(); $newDefinition->setWorkflowDefinitionEntities(array($firstEntity, $secondEntity)); $this->assertEquals(array($firstEntity, $secondEntity), array_values($newDefinition->getWorkflowDefinitionEntities()->toArray())); $newDefinition->setWorkflowDefinitionEntities(array($secondEntitySameClass, $thirdEntity)); $this->assertEquals(array($secondEntity, $thirdEntity), array_values($newDefinition->getWorkflowDefinitionEntities()->toArray())); }
/** * @param WorkflowDefinition $definition * @return $this */ public function import(WorkflowDefinition $definition) { $this->setName($definition->getName())->setType($definition->getType())->setLabel($definition->getLabel())->setEnabled($definition->isEnabled())->setConfiguration($definition->getConfiguration())->setStartStep($definition->getStartStep())->setWorkflowDefinitionEntities($definition->getWorkflowDefinitionEntities()); return $this; }