Initialization no longer takes place within __construct(), instead all logic is moved into __run().
This way you can access the current request object via RequestHandler::getInstance()->getActiveRequest()->getRequestObject(), but beware it isn't fully initialized yet (as the __run() is active while you access the object itself).
protected $response = null;
/**
- * @see wcf\action\AbstractAction::_construct()
+ * @see wcf\action\IAction::__run()
*/
- public function __construct() {
+ public function __run() {
try {
- parent::__construct();
+ parent::__run();
}
catch (\Exception $e) {
if ($e instanceof AJAXException) {
public $neededPermissions = array();
/**
- * Creates a new AbstractAction object.
- * Calls the methods readParameters() and execute() automatically.
+ * @see wcf\action\IAction::__run()
*/
- public function __construct() {
+ public function __run() {
// call default methods
$this->readParameters();
$this->execute();
protected $objectTypeID = 0;
/**
- * @see wcf\action\AbstractAction::_construct()
+ * @see wcf\action\IAction::__run()
*/
- public function __construct() {
+ public function __run() {
try {
- parent::__construct();
+ parent::__run();
}
catch (\Exception $e) {
if ($e instanceof AJAXException) {
protected $typeName = '';
/**
- * @see wcf\action\AbstractAction::_construct()
+ * @see wcf\action\IAction::__run()
*/
- public function __construct() {
+ public function __run() {
try {
- parent::__construct();
+ parent::__run();
}
catch (\Exception $e) {
if ($e instanceof AJAXException) {
* @category Community Framework
*/
interface IAction {
+ /**
+ * Initializes this action.
+ */
+ public function __run();
+
/**
* Reads the given parameters.
*/
public $neededPermissions = array();
/**
- * Creates a new AbstractPage object.
- * Calls the readParameters() and show() methods automatically.
+ * @see wcf\page\IPage::__run()
*/
- public function __construct() {
+ public function __run() {
// call default methods
$this->readParameters();
$this->show();
* @category Community Framework
*/
interface IPage {
+ /**
+ * Initializes the page.
+ */
+ public function __run();
+
/**
* Reads the given parameters.
*/
protected $pageType = '';
/**
- * true, if this request has already been executed
- * @var boolean
+ * request object
+ * @var object
*/
- protected $executed = false;
+ protected $requestObject = null;
/**
* Creates a new request object.
* Executes this request.
*/
public function execute() {
- if (!$this->executed) {
- $this->executed = true;
- new $this->className();
+ if ($this->requestObject === null) {
+ $this->requestObject = new $this->className();
+ $this->requestObject->__run();
}
}
* @return boolean
*/
public function isExecuted() {
- return $this->executed;
+ return ($this->requestObject !== null);
}
/**
public function getPageType() {
return $this->pageType;
}
+
+ /**
+ * Returns the current request object.
+ *
+ * @return object
+ */
+ public function getRequestObject() {
+ return $this->requestObject;
+ }
}