예제 #1
0
 public function testImport()
 {
     $step = new WorkflowStep();
     $step->setName('step');
     $definition = new WorkflowDefinition();
     $definition->addStep($step);
     $this->entityAcl->setAttribute('attribute');
     $this->entityAcl->setStep($step);
     $this->entityAcl->setEntityClass('TestEntity');
     $this->entityAcl->setUpdatable(false);
     $this->entityAcl->setDeletable(false);
     $newEntityAcl = new WorkflowEntityAcl();
     $newEntityAcl->setDefinition($definition);
     $this->assertEquals($newEntityAcl, $newEntityAcl->import($this->entityAcl));
     $this->assertEquals('attribute', $newEntityAcl->getAttribute());
     $this->assertEquals($step, $newEntityAcl->getStep());
     $this->assertEquals('TestEntity', $newEntityAcl->getEntityClass());
     $this->assertFalse($this->entityAcl->isUpdatable());
     $this->assertFalse($this->entityAcl->isDeletable());
     $this->assertEquals($this->entityAcl->getAttributeStepKey(), $newEntityAcl->getAttributeStepKey());
 }
 /**
  * @param WorkflowDefinition $workflowDefinition
  * @param Workflow $workflow
  */
 protected function setEntityAcls(WorkflowDefinition $workflowDefinition, Workflow $workflow)
 {
     $entityAcls = array();
     foreach ($workflow->getAttributeManager()->getEntityAttributes() as $attribute) {
         foreach ($workflow->getStepManager()->getSteps() as $step) {
             $updatable = $attribute->isEntityUpdateAllowed() && $step->isEntityUpdateAllowed($attribute->getName());
             $deletable = $attribute->isEntityDeleteAllowed() && $step->isEntityDeleteAllowed($attribute->getName());
             if (!$updatable || !$deletable) {
                 $entityAcl = new WorkflowEntityAcl();
                 $entityAcl->setAttribute($attribute->getName())->setStep($workflowDefinition->getStepByName($step->getName()))->setEntityClass($attribute->getOption('class'))->setUpdatable($updatable)->setDeletable($deletable);
                 $entityAcls[] = $entityAcl;
             }
         }
     }
     $workflowDefinition->setEntityAcls($entityAcls);
 }