mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
Added new layout and page method onInit()
called after components are initialized and before AJAX requests are processed.
This commit is contained in:
parent
b63859cd2d
commit
fdac3416e1
@ -1,3 +1,6 @@
|
||||
* **Build 11x** (2014-07-xx)
|
||||
- Added new layout and page method `onInit()` called after components are initialized and before AJAX requests are processed.
|
||||
|
||||
* **Build 115** (2014-07-06)
|
||||
- Important! All references to *Email* have been changed to *Mail* and renaming may be required in plugins.
|
||||
- Console command october:update now supports --core, --plugins and --force options.
|
||||
@ -58,7 +61,7 @@
|
||||
- Components can now be dragged from the side navigation directly on to the page.
|
||||
- Asset maker methods (addJs, addCss, addRss) now use an optional build code, either *core* or a plugin code. This is converted to a version number to ensure updates are not affected by cached assets.
|
||||
- Added new method `addComponent()` to Cms Controller. Components can now act as a proxy for other components.
|
||||
- Added new override method `onInit()` to Components, called before AJAX requests are processed.
|
||||
- Added new override method `init()` to Components, called before AJAX requests are processed.
|
||||
|
||||
* **Build 90** (2014-05-23)
|
||||
- Class `CmsPropertyHelper` has been deprecated, will be removed year > 2014.
|
||||
|
@ -41,6 +41,12 @@ class CodeBase extends Extendable implements ArrayAccess
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* This event is triggered when all components are initialized and before AJAX is handled.
|
||||
* The layout's onInit method triggers before the page's onInit method.
|
||||
*/
|
||||
public function onInit() {}
|
||||
|
||||
/**
|
||||
* This event is triggered in the beginning of the execution cycle.
|
||||
* The layout's onStart method triggers before the page's onStart method.
|
||||
|
@ -17,6 +17,7 @@ abstract class ComponentBase extends Extendable
|
||||
{
|
||||
use \System\Traits\AssetMaker;
|
||||
use \System\Traits\PropertyContainer;
|
||||
use \October\Rain\Support\Traits\Emitter;
|
||||
|
||||
/**
|
||||
* @var string A unique identifier for this component.
|
||||
@ -107,7 +108,8 @@ abstract class ComponentBase extends Extendable
|
||||
/**
|
||||
* Executed when this component is first initialized, before AJAX requests.
|
||||
*/
|
||||
public function onInit() {}
|
||||
public function init() {}
|
||||
public function onInit() {} // Deprecated: Remove ithis line if year >= 2015
|
||||
|
||||
/**
|
||||
* Executed when this component is bound to a page or layout, part of
|
||||
|
@ -173,6 +173,18 @@ class Controller extends BaseController
|
||||
|
||||
$this->initComponents();
|
||||
|
||||
/*
|
||||
* Give the layout and page an opportunity to participate
|
||||
* after components are initialized and before AJAX is handled.
|
||||
*/
|
||||
CmsException::mask($this->layout, 300);
|
||||
$this->layoutObj->onInit()
|
||||
CmsException::unmask();
|
||||
|
||||
CmsException::mask($this->page, 300);
|
||||
$this->pageObj->onInit();
|
||||
CmsException::unmask();
|
||||
|
||||
/*
|
||||
* Execute AJAX event
|
||||
*/
|
||||
@ -248,7 +260,7 @@ class Controller extends BaseController
|
||||
protected function initCustomObjects()
|
||||
{
|
||||
$this->layoutObj = null;
|
||||
|
||||
|
||||
if (!$this->layout->isFallBack()) {
|
||||
CmsException::mask($this->layout, 300);
|
||||
$parser = new CodeParser($this->layout);
|
||||
@ -307,7 +319,8 @@ class Controller extends BaseController
|
||||
$this->vars[$alias] = $this->page->components[$alias] = $componentObj;
|
||||
}
|
||||
|
||||
$componentObj->onInit();
|
||||
$componentObj->init();
|
||||
$componentObj->onInit(); // Deprecated: Remove ithis line if year >= 2015
|
||||
return $componentObj;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user