<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
contao-community-alliance / event-dispatcher example snippets
return array(
// With a closure
'event-name' => array(
function($event) {
// event code
}
),
// With a static callable
'event-name' => array(
array('MyEventListener', 'myCallable')
),
// With an object callable
'event-name' => array(
array(new MyEventListener(), 'myCallable')
),
// With a service object
'event-name' => array(
array($GLOBALS['container']['my_event_listener'], 'myCallable')
),
// You can wrap the listener into an array with a priority
'event-name' => array(
array($listener, $priority)
),
);
return array(
// With a factory
function($eventDispatcher) {
return new MyEventSubscriber();
},
// With an object class name
'MyEventSubscriber',
// With an object instance
new MyEventSubscriber(),
// With a service object
$GLOBALS['container']['my_event_subscriber'],
);
$GLOBALS['TL_EVENT_SUBSCRIBERS'][] = function($eventDispatcher) {
return new MyEventSubscriber();
};