Version 45, last updated by Johan Janssens at 14 May 02:51 UTC
1. KView
- KViewAbstract::getRoute() no longer accepts a route that starts with 'index.php?'. If you are using @route() in your templates you need to remove 'index.php?'.
2. KBehavior
- The behavior related code in KController and KDatabaseTable have been moved in a unified KBehavior package.
- A KMixinBehavior has been added to allow easy mixin of the behavior interface into KController and KDatabaseTable classes.
See ticket #187
2.1 What do you need to change ?
Function names in your controller and table behaviors must now include the calling type, so for instance _beforeAdd becomes _beforeControllerAdd, _afterInsert becomes _afterTableInsert, etc.
3. KControllerToolbar
The toolbar API has been moved into KMixinToolbar to allow easy mixing of Toolbar functions. A controller is no longer limited to having a fix number of toolbars. KMixinToolbar allows to define an unlimited number of toolbars per controller.
KControllerToolbar is now implemented as an event listener. It is auto-wired to the controller. The toolbar injects itself dynamically into the view and can be retrieved based on it's name.
Toolbar rendering is implemented using a module template filter. The toolbar output is pushed into the desired module position by the filter.
3.1 What do you need to change ?
- You need to render the toolbar manually in your templates. You can do so by adding <?= @template('com://admin/default.view.grid.toolbar'); ?> for grid views or <?= @template('com://admin/default.view.form.toolbar'); ?> for forms view. This will will render the default toolbar markup. Offcourse you can also override this and implement your own template to render the toolbars.
Note : because the toolbars are now implemented as event listeners the event dispatcher is no longer a global object. Each object that dispatches events will have it's own event dispatcher. The dispatcher is available through the KMixinEvent API interface.
4. Event handling
The event dispatcher is no longer a global object, instead event dispatchers exists in the event publisher scope and are accessible through the KMixinEvent interface. By default KMixinEvent is being mixed through the KMixinCommand if dispatch_events is TRUE.
Controllers, dispatchers and database adapters will fire events out of the box as they have dispatch_events set to TRUE by default. To disable this in your specialized objects you need to set 'dispatch_events' to false when initializing.
Added new KEventSubscriber API's. An event subscriber is an object that extends from KEventSubscriber and is aware of the event (subscriptions) it is listening for. Using KEventDispatcher::addEventSubscriber() you can wire a subscriber to a dispatcher. The addEventSubscriber function is also exposed through the KMixinEvent directly on an event publisher. Example :
A. Using the API's
$subscriber = $this->getService('com://admin/foo.event.subscriber.foo');
$this->getService('com://admin/foo.controller.bar')->getDispatcher()->addEventSubscriber($subscriber);
B. Using KMixinEvent
$this->getService('com://admin/foo.controller.bar')->addEventSubscriber('foo'); or
$this->getService('com://admin/foo.controller.bar')->addEventSubscriber('com://admin/foo.event.subscriber.bar');
C. Using Dependency injection
KService::setConfig('com://admin/foo.controller.bar', array('event_subscribers' => array('com://admin/foo.event.subscriber.bar')));
Fore more info on KEvent refactoring please see #230
4.1 Plugins
-
Plugins in the 'koowa' group no longer receive events from any event publisher as before. Instead you need to wire them manually with one or more event publishers you wish the plugin to subscribe too. You can do this in two ways :
class PlgKoowaFoo extends PlgKoowaDefault { protected function _initialize(KConfig $config) { $config->append(array( 'event_publishers' => array('com://admin/foo.dispatcher') )); parent::_initialize($config); } public function onBeforeDispatcherDispatch(KEvent $event) { //implement event handler } }
For an example see the default plugin.
4. KDatabaseRowset
KDatabaseRowset::addData() now implements a configurable row cloning or row instantiation approach. By default addData() will use the faster row cloning approach. This behavior is configurable using the new 'row_cloning' config option. Default is TRUE.
If you set 'row_cloning' to FALSE you can use the KServiceInstantiatable interface to decide during object instantiation which class needs to be used to instantiate the object based on data being passed in $config->data. For example if you have a $config->data->type.
Fore more info please see #208
5. KDatabaseBehaviorIdentifiable
Added 'auto_generate' config option. Default is TRUE. The identifiable behavior will auto-generate the uuid of the uuid column exists and the row is not new. This makes it easy to enable the identifiable behavior at any time.
6. Hypermedia
6.1 JSON error output
Added support for JSON error rendering to the koowa system plugin. If KRequest::format() == 'json' and an error is throw json will be returned using the following format :
{
version: "1.0",
errors: [
{
message: "",
code: xxx,
data: {
file: "",
line: x,
function: null,
class: null,
args: false,
info: ""
}
}
]
}
The data array is only added when debug is turned on.
6. KHttp
6.1 KHttpUrl
- Renamed KHttpUrl::set() to KHttpUrl::setUrl();
- Renamed KHttpUrl::get() to KHttpUrl::getUrl();
7. KObjectStack
Added a new KObjectStack class that implements a basic object stack interace. The object stack is implemented by KTemplateAbstract and by KCommandChain. In KCommandChain the stack allows to run a command chain recursively. Before 12.2, running a recursive chain would break the chain.
See ticket #248