Finds the object $needle in an array of objects
and returns the position in the $haystack
/** * Removes a listener. * * @param ezcWorkflowExecutionListener $listener * @return bool true when the listener was removed, false otherwise. */ public function removeListener(ezcWorkflowExecutionListener $listener) { $index = ezcWorkflowUtil::findObject($this->listeners, $listener); if ($index === false) { return false; } unset($this->listeners[$index]); return true; }
/** * Activates a node and returns true if it was activated, false if not. * * The node will only be activated if the node is executable. * See {@link ezcWorkflowNode::isExecutable()}. * * @param ezcWorkflowNode $node * @param bool $notifyPlugins * @return bool * @ignore */ 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 } }
/** * Returns true when the $node belongs to an ELSE condition. * * @param ezcWorkflowNode $node * @return bool * @ignore */ public function isElse(ezcWorkflowNode $node) { return isset($this->configuration['else'][ezcWorkflowUtil::findObject($this->outNodes, $node)]); }
/** * Removes a node from the outgoing nodes of this node. * * Automatically removes $this as an in node of $node. * * @param ezcWorkflowNode $node The node that is to be removed as outgoing node. * @throws ezcWorkflowInvalidWorkflowException if the operation violates the constraints of the nodes involved. * @return boolean */ public function removeOutNode(ezcWorkflowNode $node) { $index = ezcWorkflowUtil::findObject($this->outNodes, $node); if ($index !== false) { // Remove this node as an incoming node from the other node. if (!self::$internalCall) { self::$internalCall = true; $node->removeInNode($this); } else { self::$internalCall = false; } unset($this->outNodes[$index]); $this->numOutNodes--; return true; } return false; }