示例#1
0
 /**
  * [[@doctodo method_description:run]].
  *
  * @param [[@doctodo param_type:resumeLog]] $resumeLog [[@doctodo param_description:resumeLog]] [optional]
  * @param [[@doctodo param_type:action]]    $action    [[@doctodo param_description:action]] [optional]
  *
  * @return [[@doctodo return_type:run]] [[@doctodo return_description:run]]
  */
 public function run($resumeLog = null, $action = null)
 {
     register_shutdown_function([$this, 'saveLog']);
     if ($action === null) {
         $action = new NonInteractiveAction();
     }
     $action->interface = $this;
     if (!empty($resumeLog)) {
         $action->resumeLog($resumeLog);
     }
     $this->_currentInterfaceAction = $action;
     if (!$this->_currentInterfaceAction->start()) {
         $this->error = 'Could not start interface action!';
         return false;
     }
     try {
         $this->object->run($this->_currentInterfaceAction);
     } catch (Exception $e) {
         $this->_currentInterfaceAction->status->addError('Exception raised: ' . $e->getMessage());
         $this->_currentInterfaceAction->end(true);
         $this->error = 'Exception raised while running action (' . $e->getMessage() . ').';
         return false;
     }
     $this->_currentInterfaceAction->end();
     return !$this->_currentInterfaceAction->status->hasError;
 }