...
defined in /library/ZfExtended/Controllers/Action.php will trigger an event on each and every controller. The different controllers are named in the following list as Controllername which are Index, Login etc.
- beforeControllernameActionActionnameAction with parameter 'controller' containing the controller on Zend preDispatch
- afterControllernameActionnameAction with parameter $this->view on Zend postDispatch
RestController-Events
- beforeControllernameActionnameAction with the following parameters:
- entity: $this->entity
- params: all parameters
- controller: the controller instance
- afterSetDataInEntity with the following parameters:
- entity: $this->entity
- beforeSetDataInEntity with the following parameters:
- entity: $this->entity
- data: $this->data
- afterControllernameActionnameAction with the following parameters:
- entity: $this->entity
- view: $this->view
...
editor_Workflow_Abstract
Task
- doReopen
- doEnd
- doConfirm (getting status "open" coming from status "unconfirmed")
TaskUserAssoc
- beforeFinish
- doUnfinish
- beforeOpen
- doOpen
- beforeView
- doView
- beforeEdit
- doEdit
- beforeFinish
- doFinish
- beforeWait
- doWait
...
- afterTaskOpen with parameter array('task' => $this->entity, 'view' => $this->view, 'openState' => the opened state), used after the task was registered in the session
- afterTaskClose with parameter array('task' => $this->entity, 'view' => $this->view), used after the task was unregistered / removed from the session
editor_LanguageresourcetaskassocController
- afterPost#(Language Resources service name)
- fired after language resource to task association is created (post action). The event name contains the language resources service name (ex: when TermCollection is assigned as language resource to the task the event name will be 'afterPost#TermCollection' )
- afterDelete#(Language Resources service name)
- fired after language resource to task association is removed (delete action). Example of full event name when the language resoure is OpenTM2 → afterDelete#OpenTM2
editor_Models_Import
- importWorkerQueued is fired after the Import Worker is queued (but not started yet). Parameter: 'task' => editor_Models_Task, 'workerId' => integer
- afterImport is fired after parsing the data and storing the segments in DB. Parameter: 'task' => editor_Models_Task, 'parentWorkerId' => integer, 'importConfig' => editor_Models_Import_Configuration
- importCompleted is fired after all import plugins were run, defines the end of import. Parameter: 'task' => editor_Models_Task
editor_Models_Import_SegmentProcessor_Review
- process: is fired in processing the segment before it is first saved to the DB. Parameter: 'segment' => editor_Models_Segment, 'segmentAttributes' => editor_Models_Import_FileParser_SegmentAttributes, 'importConfig' => editor_Models_Import_Configuration
All other SegmentProcessors may follow with a process event.
editor_Models_Import_Worker_FileTree
- beforeDirectoryParsing is fired before directory parsing of proofread workfiles file. Parameter: 'importFolder' => string, 'task' => editor_Models_Task, 'workerParentId' => parent worker id of the filetree worker
- afterDirectoryParsing is fired after directory parsing of workfiles files but before further processing of the files. Parameters: 'importFolder' => string, 'task' => editor_Models_Task, 'filelist' => array (fileIds to file paths), 'workerParentId' => parent worker id of the filetree worker
editor_Models_Export
- afterExport is fired after exporting the data to a folder on the disk, also on ZIP export. Parameter: 'task' => editor_Models_Task, 'parentWorkerId' => integer
triggered only for export in the original imported format, is not triggered for xliff2 export.
editor_Models_Export_ExportedWorker
- exportCompleted is fired after all export steps (inclusive all export workers) are finished. Parameter: 'task' => editor_Models_Task, 'parameters' => array, the initial parameters given to the worker
ZfExtended_Mail
- afterMailViewInit is fired after the view for rendering the mail templates is initialized. Parameter: 'view' => Zend_View
Handmade events
Handmade events are spezial events wich are defined direct in the code. No automatic definition is used while trigger.
...
Because Zend has a special class for static (global) events, best-pratice to use events in a class is:
Event-Trigger
...
- use a protected variable $events to hold the event(-trigger)-object
- initialize $this->events in the class-constructor
- parameter should be send in an named-array 'name' => $value
Code Block | ||||
---|---|---|---|---|
| ||||
/** * @var ZfExtended_EventManager */ protected $events = false; public function __construct() { $this->events = ZfExtended_Factory::get('ZfExtended_EventManager', array(get_class($this))); } public function doSomething(){ $this->events->trigger("eventName", $this, array('model' => $this, 'moreParam' => $moreParams)); } |
...
- use a protected variable $staticEvents to hold the event(-listener)-Object.
- initialize $this->staticEvents in the class-constructor
- define all event-listeners in the class-constructor
- if handler use a event-parameter which is an object make a var-definition-comment so the IDE autocomplete can work correct
Code Block | ||||
---|---|---|---|---|
| ||||
/** * @var Zend_EventManager_StaticEventManager */ protected $staticEvents = false; public function __construct(){ $this->staticEvents = Zend_EventManager_StaticEventManager::getInstance(); $this->staticEvents->attach('classNameTriggerClass', 'eventName', array($this, 'handleEvent')); } public function handleEvent(Zend_EventManager_Event $event) { // do something on event "eventName" with parameters send within event-trigger $model = $event->getParam('model'); /* @var $model nameOfTheModelClass */ // to trigger IDE $moreParams = $event->getParam('moreParams'); } |
...
Trigger and Listen in one class
...