setVariable() public method

Sets a variable.
public setVariable ( string $variableName, mixed $value ) : mixed
$variableName string
$value mixed
return mixed the value that the variable has been set to
示例#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
 public function execute(ezcWorkflowExecution $execution)
 {
     $package_instance = new com_meego_package($execution->getVariable('package_instance'));
     // We load the form from the package's repository
     $repository = new com_meego_repository($package_instance->repository);
     $list_of_forms = midgardmvc_ui_forms_generator::list_for_object($repository);
     if (empty($list_of_forms)) {
         return;
     }
     $execution->setVariable('review_form', $list_of_forms[0]->name);
 }
 /**
  * @todo: docs
  */
 public function execute(ezcWorkflowExecution $execution)
 {
     $form = midgardmvc_ui_forms_generator::get_by_guid($execution->getVariable('review_form'));
     $instance = new midgardmvc_ui_forms_form_instance($execution->getVariable('review'));
     $review = midgardmvc_ui_forms_store::load_form($form, $instance);
     $items = $form->items;
     $boolean_count = 0;
     $positive = 0;
     $package = new com_meego_package($instance->relatedobject);
     foreach ($items as $key => $item) {
         if ($key == "redirect_link" || $key == "execution") {
             continue;
         }
         try {
             $field = new midgardmvc_ui_forms_form_field($key);
         } catch (Exception $e) {
             midgardmvc_core::get_instance()->log('Invalid field detected in distill review: ' . $key . ', value: ' . $item, 'warning');
         }
         // todo: ugly hardcoded check, but what can we do..
         if ($field->title == "Should the application be in this application catalog?") {
             // if the answer belongs to a certain field then we process
             // this field must be a boolean too
             if ($item instanceof midgardmvc_helper_forms_field_boolean) {
                 if ($item->get_value()) {
                     // add +1 to the package score
                     $package->metadata->score++;
                 } else {
                     //  oh yes, we do give -1 points too ;)
                     $package->metadata->score--;
                 }
                 $res = $package->update();
                 if (!$res) {
                     //update failed; do what?
                 }
             }
         } else {
             // otherwise
             continue;
         }
     }
     // pass on the score
     $execution->setVariable('distilled_review', $package->metadata->score);
 }
示例#4
0
 /**
  * Passes variables from one execution context to another.
  *
  * @param  ezcWorkflowExecution $from The execution context the variables are passed from.
  * @param  ezcWorkflowExecution $to The execution context the variables are passed to.
  * @param  array                $variables The names of the variables.
  * @throws ezcWorkflowExecutionException if a variable that is to be passed does not exist.
  * @ignore
  */
 protected function passVariables(ezcWorkflowExecution $from, ezcWorkflowExecution $to, array $variables)
 {
     foreach ($variables as $fromName => $toName) {
         $to->setVariable($toName, $from->getVariable($fromName));
     }
 }
 /**
  * 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);
 }