getVariables() public method

Returns the variables.
public getVariables ( ) : array
return array
Beispiel #1
0
 /**
  * Visualizes the current state of the workflow execution.
  *
  * @param ezcWorkflowExecution $execution
  */
 protected function visualize(ezcWorkflowExecution $execution)
 {
     $activatedNodes = array();
     foreach ($execution->getActivatedNodes() as $node) {
         $activatedNodes[] = $node->getId();
     }
     if ($this->options['includeVariables']) {
         $variables = $execution->getVariables();
     } else {
         $variables = array();
     }
     $visitor = new ezcWorkflowVisitorVisualization();
     $visitor->options['highlightedNodes'] = $activatedNodes;
     $visitor->options['workflowVariables'] = $variables;
     $execution->workflow->accept($visitor);
     file_put_contents(sprintf('%s%s%s_%03d_%03d.dot', $this->options['directory'], DIRECTORY_SEPARATOR, $execution->workflow->name, $execution->getId(), ++$this->fileCounter), $visitor);
 }
Beispiel #2
0
 /**
  * Gets a rendered HTML form
  */
 public function get_form(ezcWorkflowExecution $execution)
 {
     $list_of_variables = $execution->getVariables();
     if (array_key_exists('review_form', $list_of_variables)) {
         $db_form = new midgardmvc_ui_forms_form($list_of_variables['review_form']);
         $form = midgardmvc_ui_forms_generator::get_by_form($db_form, false);
         $form->set_readonly(false);
         if ($this->request->isset_data_item('redirect_link')) {
             $redirect_link = $this->request->get_data_item('redirect_link');
         } else {
             if (array_key_exists('HTTP_REFERER', $_SERVER)) {
                 $redirect_link = $_SERVER['HTTP_REFERER'];
             } else {
                 $redirect_link = '';
             }
         }
         $form->set_cancel(null, $this->mvc->i18n->get('cancel', 'midgardmvc_helper_forms'), $redirect_link);
         // add a hidden input with the recirect link
         // where we go upon successful submit
         $field = $form->add_field('redirect_link', 'text');
         $field->set_value($redirect_link);
         $widget = $field->set_widget('hidden');
         // add a hidden input with the execution guid
         $field = $form->add_field('execution', 'text');
         $field->set_value($execution->guid);
         $widget = $field->set_widget('hidden');
         return array('db_form' => $db_form, 'form' => $form);
     }
     return null;
 }
 /**
  * Evaluates all the conditions, checks the constraints and activates any nodes that have
  * passed through both checks and condition evaluation.
  *
  * @param ezcWorkflowExecution $execution
  * @return boolean true when the node finished execution,
  *                 and false otherwise
  * @ignore
  */
 public function execute(ezcWorkflowExecution $execution)
 {
     $keys = array_keys($this->outNodes);
     $numKeys = count($keys);
     $nodesToStart = array();
     $numActivatedConditionalOutNodes = 0;
     if ($this->maxActivatedConditionalOutNodes !== false) {
         $maxActivatedConditionalOutNodes = $this->maxActivatedConditionalOutNodes;
     } else {
         $maxActivatedConditionalOutNodes = $numKeys;
     }
     for ($i = 0; $i < $numKeys && $numActivatedConditionalOutNodes <= $maxActivatedConditionalOutNodes; $i++) {
         if (isset($this->configuration['condition'][$keys[$i]])) {
             // Conditional outgoing node.
             if ($this->configuration['condition'][$keys[$i]]->evaluate($execution->getVariables())) {
                 $nodesToStart[] = $this->outNodes[$keys[$i]];
                 $numActivatedConditionalOutNodes++;
             }
         } else {
             // Unconditional outgoing node.
             $nodesToStart[] = $this->outNodes[$keys[$i]];
         }
     }
     if ($this->minActivatedConditionalOutNodes !== false && $numActivatedConditionalOutNodes < $this->minActivatedConditionalOutNodes) {
         throw new ezcWorkflowExecutionException('Node activates less conditional outgoing nodes than required.');
     }
     return $this->activateOutgoingNodes($execution, $nodesToStart);
 }
Beispiel #4
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;
     }
 }