ezcWorkflowExecution::activate PHP Method

activate() public method

The node will only be activated if the node is executable. See {@link ezcWorkflowNode::isExecutable()}.
public activate ( ezcWorkflowNode $node, boolean $notifyPlugins = true ) : boolean
$node ezcWorkflowNode
$notifyPlugins boolean
return boolean
    public function activate(ezcWorkflowNode $node, $notifyPlugins = true)
    {
        // Only activate the node when
        //  - the execution of the workflow has not been cancelled,
        //  - the node is ready to be activated,
        //  - and the node is not already activated.
        if ($this->cancelled || !$node->isExecutable() || ezcWorkflowUtil::findObject($this->activatedNodes, $node) !== false) {
            return false;
        }
        $activateNode = true;
        foreach ($this->plugins as $plugin) {
            $activateNode = $plugin->beforeNodeActivated($this, $node);
            if (!$activateNode) {
                // @codeCoverageIgnoreStart
                break;
                // @codeCoverageIgnoreEnd
            }
        }
        if ($activateNode) {
            // Add node to list of activated nodes.
            $this->activatedNodes[] = $node;
            $this->numActivatedNodes++;
            if ($node instanceof ezcWorkflowNodeEnd) {
                $this->numActivatedEndNodes++;
            }
            if ($notifyPlugins) {
                foreach ($this->plugins as $plugin) {
                    $plugin->afterNodeActivated($this, $node);
                }
            }
            return true;
        } else {
            // @codeCoverageIgnoreStart
            return false;
            // @codeCoverageIgnoreEnd
        }
    }

Usage Example

Esempio n. 1
0
File: node.php Progetto: bmdevel/ezc
 /**
  * Activate this node in the execution environment $execution.
  *
  * $activatedFrom is the node that activated this node and $threadId is
  * threadId of the thread the node should be activated in.
  *
  * This method is called by other nodes and/or the execution environment
  * depending on the workflow.
  *
  * @param ezcWorkflowExecution $execution
  * @param ezcWorkflowNode $activatedFrom
  * @param int $threadId
  * @ignore
  */
 public function activate(ezcWorkflowExecution $execution, ezcWorkflowNode $activatedFrom = null, $threadId = 0)
 {
     if ($this->activationState === self::WAITING_FOR_ACTIVATION) {
         $this->activationState = self::WAITING_FOR_EXECUTION;
         $this->setThreadId($threadId);
         if ($activatedFrom !== null) {
             $this->activatedFrom[] = get_class($activatedFrom);
         }
         $execution->activate($this);
     }
 }