コード例 #1
0
ファイル: ActionAssembler.php プロジェクト: Maksold/platform
 /**
  * @param array $conditionConfiguration
  * @return null|ConfigurableCondition
  */
 protected function createConfigurableCondition(array $conditionConfiguration)
 {
     $condition = null;
     $conditionConfiguration = $this->getOption($conditionConfiguration, self::CONDITIONS_KEY, null);
     if ($conditionConfiguration) {
         $condition = $this->conditionFactory->create(ConfigurableCondition::ALIAS, $conditionConfiguration);
     }
     return $condition;
 }
コード例 #2
0
ファイル: Process.php プロジェクト: Maksold/platform
 /**
  * @return bool|AbstractCondition
  */
 protected function getPreCondition()
 {
     if ($this->preCondition === null) {
         $this->preCondition = false;
         $conditionConfiguration = $this->processDefinition->getPreConditionsConfiguration();
         if ($conditionConfiguration) {
             $this->preCondition = $this->conditionFactory->create(ConfigurableCondition::ALIAS, $conditionConfiguration);
         }
     }
     return $this->preCondition;
 }
コード例 #3
0
ファイル: ProcessTest.php プロジェクト: ramunasd/platform
 public function testExecutePreConditionsAreNotMet()
 {
     $context = [];
     $conditionConfiguration = ['test' => []];
     $condition = $this->getMockBuilder('Oro\\Bundle\\WorkflowBundle\\Model\\Condition\\Configurable')->disableOriginalConstructor()->getMock();
     $condition->expects($this->any())->method('evaluate')->with($context)->will($this->returnValue(false));
     $this->processDefinition->expects($this->once())->method('getPreConditionsConfiguration')->will($this->returnValue($conditionConfiguration));
     $this->conditionFactory->expects($this->once())->method('create')->with(ConfigurableCondition::ALIAS, $conditionConfiguration)->will($this->returnValue($condition));
     $this->processDefinition->expects($this->never())->method('getActionsConfiguration');
     $this->actionAssembler->expects($this->never())->method('assemble');
     $this->process->execute($context);
 }
コード例 #4
0
 public function testCreateContextAccessorAware()
 {
     $options = ['key' => 'value'];
     $expr = $this->getMockBuilder('Oro\\Component\\ConfigExpression\\Condition\\Blank')->disableOriginalConstructor()->getMock();
     $expr->expects($this->once())->method('setContextAccessor')->with($this->identicalTo($this->contextAccessor));
     $expr->expects($this->once())->method('initialize')->with($options);
     $extension = $this->getMock('Oro\\Component\\ConfigExpression\\Extension\\ExtensionInterface');
     $this->factory->addExtension($extension);
     $extension->expects($this->once())->method('hasExpression')->with('test')->will($this->returnValue(true));
     $extension->expects($this->once())->method('getExpression')->with('test')->will($this->returnValue($expr));
     $this->assertSame($expr, $this->factory->create('test', $options));
 }
コード例 #5
0
 /**
  * @param string $name
  * @param array $options
  * @param array $definition
  * @param Step[]|ArrayCollection $steps
  * @param Attribute[]|Collection $attributes
  * @return Transition
  * @throws AssemblerException
  */
 protected function assembleTransition($name, array $options, array $definition, $steps, $attributes)
 {
     $this->assertOptions($options, array('step_to', 'label'));
     $stepToName = $options['step_to'];
     if (empty($steps[$stepToName])) {
         throw new AssemblerException(sprintf('Step "%s" not found', $stepToName));
     }
     $transition = new Transition();
     $transition->setName($name)->setLabel($options['label'])->setStepTo($steps[$stepToName])->setMessage($this->getOption($options, 'message'))->setStart($this->getOption($options, 'is_start', false))->setHidden($this->getOption($options, 'is_hidden', false))->setUnavailableHidden($this->getOption($options, 'is_unavailable_hidden', false))->setFormType($this->getOption($options, 'form_type', WorkflowTransitionType::NAME))->setFormOptions($this->assembleFormOptions($options, $attributes, $name))->setFrontendOptions($this->getOption($options, 'frontend_options', array()))->setDisplayType($this->getOption($options, 'display_type', WorkflowConfiguration::DEFAULT_TRANSITION_DISPLAY_TYPE))->setPageTemplate($this->getOption($options, 'page_template'))->setDialogTemplate($this->getOption($options, 'dialog_template'));
     $definition['pre_conditions'] = $this->addAclPreConditions($options, $definition);
     if (!empty($definition['pre_conditions'])) {
         $condition = $this->conditionFactory->create(ConfigurableCondition::ALIAS, $definition['pre_conditions']);
         $transition->setPreCondition($condition);
     }
     if (!empty($definition['conditions'])) {
         $condition = $this->conditionFactory->create(ConfigurableCondition::ALIAS, $definition['conditions']);
         $transition->setCondition($condition);
     }
     if (!empty($definition['post_actions'])) {
         $postAction = $this->actionFactory->create(ConfigurableAction::ALIAS, $definition['post_actions']);
         $transition->setPostAction($postAction);
     }
     return $transition;
 }