/** * @see wcf\action\IAction::execute() */ public function execute() { parent::execute(); // validate class name if (!class_exists($this->className)) { throw new SystemException("unknown class '" . $this->className . "'"); } if (!ClassUtil::isInstanceOf($this->className, 'wcf\\data\\IDatabaseObjectAction')) { throw new SystemException("'" . $this->className . "' should implement wcf\\system\\IDatabaseObjectAction"); } // create object action instance $this->objectAction = new $this->className($this->objectIDs, $this->actionName, $this->parameters); // validate action try { $this->objectAction->validateAction(); } catch (UserInputException $e) { $this->throwException($e); } catch (ValidateActionException $e) { $this->throwException($e); } // execute action try { $this->response = $this->objectAction->executeAction(); } catch (\Exception $e) { $this->throwException($e); } $this->executed(); // send JSON-encoded response header('Content-type: application/json'); echo JSON::encode($this->response); exit; }
/** * @see wcf\action\IAction::execute() */ public function execute() { parent::execute(); // get object ids $objectIDs = $this->getObjectIDs(); // create object action instance $this->objectAction = new $this->parameters['className']($objectIDs, $this->parameters['actionName']); // validate action try { $this->objectAction->validateAction(); } catch (ValidateActionException $e) { throw new AJAXException("validation failed: " . $e->getMessage()); } // execute action try { $this->response = $this->objectAction->executeAction(); } catch (\Exception $e) { throw new AJAXException('unknown exception caught: ' . $e->getMessage()); } $this->executed(); // send JSON-encoded response header('Content-type: application/json'); echo JSON::encode($this->response); exit; }