コード例 #1
0
ファイル: Actions.php プロジェクト: hypejunction/hypeapps
 /**
  * Executes an action
  * Triggers 'action:after', $ation hook that allows you to filter the Result object
  *
  * @param Action $controller Action name or instance of Action
  * @param bool  $feedback    Display errors and messages
  * @return ActionResult
  */
 public function execute(Action $controller, $feedback = true)
 {
     try {
         $action = $this->parseActionName();
         elgg_make_sticky_form($action);
         $controller->setup();
         if ($controller->validate() === false) {
             throw new ActionValidationException("Invalid input for action {$action}");
         }
         $controller->execute();
         $this->result = $controller->getResult();
     } catch (ActionValidationException $ex) {
         $this->result->addError($ex->getMessage());
         elgg_log($ex->getMessage(), 'ERROR');
     } catch (PermissionsException $ex) {
         $this->result->addError(elgg_echo('apps:permissions:error'));
         elgg_log($ex->getMessage(), 'ERROR');
     } catch (InvalidEntityException $ex) {
         $this->result->addError(elgg_echo('apps:entity:error'));
         elgg_log($ex->getMessage(), 'ERROR');
     } catch (Exception $ex) {
         $this->result->addError(elgg_echo('apps:action:error'));
         elgg_log($ex->getMessage(), 'ERROR');
     }
     $errors = $this->result->getErrors();
     $messages = $this->result->getMessages();
     if (empty($errors)) {
         elgg_clear_sticky_form($action);
     } else {
         $this->result->setForwardURL(REFERRER);
     }
     if ($feedback) {
         foreach ($errors as $error) {
             register_error($error);
         }
         foreach ($messages as $message) {
             system_message($message);
         }
     }
     return elgg_trigger_plugin_hook('action:after', $action, null, $this->result);
 }
コード例 #2
0
 public function __construct($content)
 {
     parent::__construct($content);
 }