...
- 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 file. Parameter: 'importFolder' => string, 'task' => editor_Models_Task, 'workerParentId' => parent worker id of the filetree worker
- afterDirectoryParsing is fired after directory parsing of proofread 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
...
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
...