execute() public method

Implementations of ezcWorkflowNode should reimplement this method. This method is called automatically by the workflow execution environment and should not be called directly. The default implementation resets the activation state of the node.
public execute ( ezcWorkflowExecution $execution ) : boolean
$execution ezcWorkflowExecution
return boolean true when the node finished execution, and false otherwise
Beispiel #1
0
 /**
  * Executes this by setting all the variables specified by the
  * configuration.
  *
  * @param ezcWorkflowExecution $execution
  * @return boolean true when the node finished execution,
  *                 and false otherwise
  * @ignore
  */
 public function execute(ezcWorkflowExecution $execution)
 {
     foreach ($this->configuration as $variable => $value) {
         $execution->setVariable($variable, $value);
     }
     $this->activateNode($execution, $this->outNodes[0]);
     return parent::execute($execution);
 }
Beispiel #2
0
 /**
  * Performs the merge by ending the incoming threads and
  * activating the outgoing node.
  *
  * @param ezcWorkflowExecution $execution
  * @return boolean true when the node finished execution,
  *                 and false otherwise
  */
 protected function doMerge(ezcWorkflowExecution $execution)
 {
     foreach ($this->state['threads'] as $threadId) {
         $execution->endThread($threadId);
     }
     $this->activateNode($execution, $this->outNodes[0]);
     $this->initState();
     return parent::execute($execution);
 }
 /**
  * Activates this node's outgoing nodes.
  *
  * @param ezcWorkflowExecution $execution
  * @param array                $nodes
  * @return boolean true when the node finished execution,
  *                 and false otherwise
  */
 protected function activateOutgoingNodes(ezcWorkflowExecution $execution, array $nodes)
 {
     $threadId = $this->getThreadId();
     $numNodesToActivate = count($nodes);
     foreach ($nodes as $node) {
         if ($this->startNewThreadForBranch) {
             $node->activate($execution, $this, $execution->startThread($threadId, $numNodesToActivate));
         } else {
             $node->activate($execution, $this, $threadId);
         }
     }
     return parent::execute($execution);
 }
 /**
  * Executes this node.
  *
  * @param ezcWorkflowExecution $execution
  * @return boolean true when the node finished execution,
  *                 and false otherwise
  * @ignore
  */
 public function execute(ezcWorkflowExecution $execution)
 {
     if ($execution->definitionStorage === null) {
         throw new ezcWorkflowExecutionException('No ezcWorkflowDefinitionStorage implementation available.');
     }
     $workflow = $execution->definitionStorage->loadByName($this->configuration['workflow']);
     // Sub Workflow is not interactive.
     if (!$workflow->isInteractive() && !$workflow->hasSubWorkflows()) {
         $subExecution = $execution->getSubExecution(null, false);
         $subExecution->workflow = $workflow;
         $this->passVariables($execution, $subExecution, $this->configuration['variables']['in']);
         $subExecution->start();
     } else {
         // Sub Workflow is to be started.
         if ($this->state == 0) {
             $subExecution = $execution->getSubExecution();
             $subExecution->workflow = $workflow;
             $this->passVariables($execution, $subExecution, $this->configuration['variables']['in']);
             $subExecution->start($execution->getId());
             $this->state = $subExecution->getId();
         } else {
             $subExecution = $execution->getSubExecution($this->state);
             $subExecution->workflow = $workflow;
             $subExecution->resume($execution->getVariables());
         }
     }
     // Execution of Sub Workflow was cancelled.
     if ($subExecution->isCancelled()) {
         $execution->cancel($this);
     }
     // Execution of Sub Workflow has ended.
     if ($subExecution->hasEnded()) {
         $this->passVariables($subExecution, $execution, $this->configuration['variables']['out']);
         $this->activateNode($execution, $this->outNodes[0]);
         $this->state = 0;
         return parent::execute($execution);
     }
     // Execution of Sub Workflow has been suspended.
     foreach ($subExecution->getWaitingFor() as $variableName => $data) {
         $execution->addWaitingFor($this, $variableName, $data['condition']);
     }
     return false;
 }
Beispiel #5
0
 /**
  * Executes this node by creating the service object and calling its execute() method.
  *
  * If the service object returns true, the output node will be activated.
  * If the service node returns false the workflow will be suspended
  * unless there are other activated nodes. An action node suspended this way
  * will be executed again the next time the workflow is resumed.
  *
  * @param ezcWorkflowExecution $execution
  * @return boolean true when the node finished execution,
  *                 and false otherwise
  * @ignore
  */
 public function execute(ezcWorkflowExecution $execution)
 {
     $object = $this->createObject();
     $finished = $object->execute($execution);
     // Execution of the Service Object has finished.
     if ($finished !== false) {
         $this->activateNode($execution, $this->outNodes[0]);
         return parent::execute($execution);
     } else {
         return false;
     }
 }
Beispiel #6
0
 /**
  * Ends the execution of this workflow.
  *
  * @param ezcWorkflowExecution $execution
  * @return boolean true when the node finished execution,
  *                 and false otherwise
  * @ignore
  */
 public function execute(ezcWorkflowExecution $execution)
 {
     $execution->end($this);
     return parent::execute($execution);
 }
Beispiel #7
0
 /**
  * Executes this node.
  *
  * @param ezcWorkflowExecution $execution
  * @return boolean true when the node finished execution,
  *                 and false otherwise
  * @ignore
  */
 public function execute(ezcWorkflowExecution $execution)
 {
     $variables = $execution->getVariables();
     $canExecute = true;
     $errors = array();
     foreach ($this->configuration as $variable => $condition) {
         if (!isset($variables[$variable])) {
             $execution->addWaitingFor($this, $variable, $condition);
             $canExecute = false;
         } else {
             if (!$condition->evaluate($variables[$variable])) {
                 $errors[$variable] = (string) $condition;
             }
         }
     }
     if (!empty($errors)) {
         throw new ezcWorkflowInvalidInputException($errors);
     }
     if ($canExecute) {
         $this->activateNode($execution, $this->outNodes[0]);
         return parent::execute($execution);
     } else {
         return false;
     }
 }
Beispiel #8
0
 /**
  * Activates the sole output node.
  *
  * @param ezcWorkflowExecution $execution
  * @return boolean true when the node finished execution,
  *                 and false otherwise
  * @ignore
  */
 public function execute(ezcWorkflowExecution $execution)
 {
     $this->outNodes[0]->activate($execution, $this, $execution->startThread());
     return parent::execute($execution);
 }
 /**
  * Executes this node and returns true.
  *
  * Expects the configuration parameters 'name' the name of the workflow
  * variable to work on and the parameter 'value' the value to operate with
  * or the name of the workflow variable containing the value.
  *
  * @param ezcWorkflowExecution $execution
  * @return boolean
  * @ignore
  */
 public function execute(ezcWorkflowExecution $execution)
 {
     if (is_array($this->configuration)) {
         $variableName = $this->configuration['name'];
     } else {
         $variableName = $this->configuration;
     }
     $this->variable = $execution->getVariable($variableName);
     if (!is_numeric($this->variable)) {
         throw new ezcWorkflowExecutionException(sprintf('Variable "%s" is not a number.', $variableName));
     }
     if (is_numeric($this->configuration['operand'])) {
         $this->operand = $this->configuration['operand'];
     } else {
         if (is_string($this->configuration['operand'])) {
             try {
                 $operand = $execution->getVariable($this->configuration['operand']);
                 if (is_numeric($operand)) {
                     $this->operand = $operand;
                 }
             } catch (ezcWorkflowExecutionException $e) {
             }
         }
     }
     if ($this->operand === null) {
         throw new ezcWorkflowExecutionException('Illegal operand.');
     }
     $this->doExecute();
     $execution->setVariable($variableName, $this->variable);
     $this->activateNode($execution, $this->outNodes[0]);
     return parent::execute($execution);
 }