All workflow nodes must extend this class.
Inheritance: implements ezcWorkflowVisitable
コード例 #1
0
ファイル: set.php プロジェクト: bmdevel/ezc
 /**
  * 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);
 }
コード例 #2
0
 /**
  * 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);
 }
コード例 #3
0
 /**
  * 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;
 }
コード例 #4
0
ファイル: action.php プロジェクト: zetacomponents/workflow
 /**
  * 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;
     }
 }
コード例 #5
0
ファイル: execution.php プロジェクト: zetacomponents/workflow
 /**
  * Adds a variable that an (input) node is waiting for.
  *
  * @param ezcWorkflowNode $node
  * @param string $variableName
  * @param ezcWorkflowCondition $condition
  * @ignore
  */
 public function addWaitingFor(ezcWorkflowNode $node, $variableName, ezcWorkflowCondition $condition)
 {
     if (!isset($this->waitingFor[$variableName])) {
         $this->waitingFor[$variableName] = array('node' => $node->getId(), 'condition' => $condition);
     }
 }
コード例 #6
0
ファイル: node_merge.php プロジェクト: bmdevel/ezc
 /**
  * Initializes the state of this node.
  *
  * @ignore
  */
 public function initState()
 {
     parent::initState();
     $this->state = array('threads' => array(), 'siblings' => -1);
 }
コード例 #7
0
ファイル: listener.php プロジェクト: bmdevel/ezc
 /**
  * Called after a node has been executed.
  *
  * @param ezcWorkflowExecution $execution
  * @param ezcWorkflowNode      $node
  */
 public function afterNodeExecuted(ezcWorkflowExecution $execution, ezcWorkflowNode $node)
 {
     $this->notifyListeners(sprintf('Executed node #%d(%s) for instance #%d of workflow "%s" (version %d).', $node->getId(), get_class($node), $execution->getId(), $execution->workflow->name, $execution->workflow->version), ezcWorkflowExecutionListener::DEBUG);
 }
コード例 #8
0
ファイル: node.php プロジェクト: bmdevel/ezc
 /**
  * Convenience method for activating an (outgoing) node.
  *
  * @param ezcWorkflowExecution $execution
  * @param ezcWorkflowNode $node
  */
 protected function activateNode(ezcWorkflowExecution $execution, ezcWorkflowNode $node)
 {
     $node->activate($execution, $this, $this->getThreadId());
 }
コード例 #9
0
ファイル: end.php プロジェクト: jordanmanning/ezpublish
 /**
  * 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);
 }
コード例 #10
0
ファイル: input.php プロジェクト: jordanmanning/ezpublish
 /**
  * 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;
     }
 }
コード例 #11
0
ファイル: start.php プロジェクト: jordanmanning/ezpublish
 /**
  * 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);
 }
コード例 #12
0
 /**
  * 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);
 }