/**
  * This method is capable of taking an active flow and trigger the
  * execution its steps until it finishes (ok or not) or reach a waiting
  * point.
  *
  * @param \TooBasic\Workflows\ItemFlowRepresentation $flow Flow to be
  * executed.
  * @param string $error Returns an error message when something went
  * wrong.
  * @return boolean Returns FALSE when an error was found.
  */
 public function run(ItemFlowRepresentation $flow, &$error = false)
 {
     //
     // Defautl values.
     $out = true;
     //
     // Enforcing known factories to be loaded.
     $this->loadFactories();
     //
     // Loading flow's workflow.
     $workflow = $this->getWorkflow($flow->workflow);
     //
     // Loading flow's workflow.
     $item = $this->_factories[$flow->type]->item($flow->item);
     //
     // Basic log prefixes.
     $logParams = array('workflow' => $flow->workflow);
     //
     // Logging operation start.
     $this->_log->log(LGGR_LOG_LEVEL_INFO, 'Running flow: ' . json_encode($flow->toArray()), $logParams);
     $this->_log->log(LGGR_LOG_LEVEL_INFO, '        item: ' . json_encode($item->toArray()), $logParams);
     //
     // Walking through each step until it's no longer ok or flagged to
     // stop.
     $continue = true;
     while ($continue && $flow->status == WKFL_ITEM_FLOW_STATUS_OK) {
         //
         // Asking the workflow to run a step.
         $continue = $workflow->runFor($flow, $item);
         //
         // Reloading flow to avoid errors.
         $flow->load($flow->id);
         //
         // Logging step execution results.
         $this->_log->log(LGGR_LOG_LEVEL_INFO, 'Current flow status: ' . json_encode($flow->toArray()), $logParams);
         $this->_log->log(LGGR_LOG_LEVEL_INFO, '        item status: ' . json_encode($item->toArray()), $logParams);
         $this->_log->log(LGGR_LOG_LEVEL_INFO, 'Continue?: ' . ($continue ? 'Yes' : 'No'), $logParams);
     }
     return $out;
 }