Date: Fri, 29 Mar 2024 15:24:01 +0000 (UTC)
Message-ID: <523882439.11.1711725841993@node2041-mqi-confluence.web.inetsolutions.cloud>
Subject: Exported From Confluence
MIME-Version: 1.0
Content-Type: multipart/related;
boundary="----=_Part_10_590407712.1711725841992"
------=_Part_10_590407712.1711725841992
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Content-Location: file:///C:/exported.html
This document the state "dr=
aft" !!!
If you need an event in tra=
nslate5, that is not listed here, please contact support@translate5.net.
Automatic events
Automatic events are defined in some global (basic ??) tranlate5 classes=
. For the events-names variables or automatisms are used. On that way a lot=
of internal trigger-points are generated on the fly.
=
public function preDispatch()
{
$eventName =3D "before".ucfirst($this->_request->getActio=
nName())."Action";
$this->events->trigger($eventName, $this);
}
will define an "beforeControllerAction"-event for each an every controll=
er. For the default IndexController of the Editor-Modul this will lead to a=
n event Editor_IndexController#beforeIndexAction
Controller-Events
defined in /library/ZfExtended/Controllers/Action.php wil=
l trigger an event on each and every controller. The different controllers =
are named in the following list as Controllername which are Index,=
Login etc.
- beforeActionnameAction with parameter 'contro=
ller' containing the controller on Zend preDispatch
- afterActionnameAction with parameter $this->view on Zend postDispatch
RestController-Events=
h3>
- beforeActionnameAction with the following par=
ameters:
- entity: $this->entity
- params: all parameters
- controller: the controller instance
- afterSetDataInEntity with the following parameters:
- beforeSetDataInEntity with the following parameters:
- entity: $this->entity
- data: $this->data
- afterActionnameAction with the following para=
meters:
- entity: $this->entity
- view: $this->view
ZfExtended_=
Models_Entity_Abstract
- beforeSave with parameter array('entity' =3D> $this=
), on every save as first function. !!! be careful on overwritten methods t=
o call parent::save() in first place or to take care of events !!!
editor_Workflow_Abst=
ract
Task
- doReopen
- doEnd
- doConfirm (getting status "open" coming from status "u=
nconfirmed")
TaskUserAssoc
- beforeFinish
- doUnfinish
- beforeOpen
- doOpen
- beforeView
- doView
- beforeEdit
- doEdit
- beforeFinish
- doFinish
- beforeWait
- doWait
Editor_Segment=
Controller
- beforePutSave with parameter array('entity' =3D> $t=
his->entity), used in function putAction() after normal processing befor=
e saving the entity (=3D the segment)
Editor_TaskContro=
ller
- afterTaskOpen with parameter array('task' =3D> $thi=
s->entity, 'view' =3D> $this->view, 'openState' =3D> the opened=
state), used after the task was registered in the session
- afterTaskClose with parameter array('task' =3D> $th=
is->entity, 'view' =3D> $this->view), used after the task was unre=
gistered / removed from the session
ed=
itor_LanguageresourcetaskassocController
- afterPost#(Language Resources service name)
- fired after language resource to task association is created (post acti=
on). 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 ac=
tion). Example of full event name when the language resoure is OpenTM2 =
;=E2=86=92 afterDelete#OpenTM2
editor_Models_Import
- importWorkerQueued is fired after the Import Worker is=
queued (but not started yet). Parameter: 'task' =3D> editor_Models_Task=
, 'workerId' =3D> integer
- afterImport is fired after parsing the data and storin=
g the segments in DB. Parameter: 'task' =3D> editor_Models_Task, 'parent=
WorkerId' =3D> integer, 'importConfig' =3D> editor_Models_Import_Conf=
iguration
- importCompleted is fired after all import plugins were=
run, defines the end of import. Parameter: 'task' =3D> editor_Models_Ta=
sk
=
editor_Models_Import_SegmentProcessor_Review
- process: is fired in processing the segment before it is first saved to=
the DB. Parameter: 'segment' =3D> editor_Models_Segment, 'segmentAttrib=
utes' =3D> editor_Models_Import_FileParser_SegmentAttributes, 'importCon=
fig' =3D> editor_Models_Import_Configuration
All other SegmentProcessors may follow with a process event.
editor_M=
odels_Import_Worker_FileTree
- beforeDirectoryParsing is fired before directory parsi=
ng of workfiles file. Parameter: 'importFolder' =3D> string, 'task' =3D&=
gt; editor_Models_Task, 'workerParentId' =3D> parent worker id of the fi=
letree worker
- afterDirectoryParsing is fired after directory parsing=
of workfiles files but before further processing of the files. Parameters:=
'importFolder' =3D> string, 'task' =3D> editor_Models_Task, 'filelis=
t' =3D> array (fileIds to file paths), 'workerParentId' =3D> parent w=
orker id of the filetree worker
editor_Models_Export
- afterExport is fired after exporting the data to a fol=
der on the disk, also on ZIP export. Parameter: 'task' =3D> editor_Model=
s_Task, 'parentWorkerId' =3D> integer
triggered only for export in the original imported format, is not triggered=
for xliff2 export.
editor_Mo=
dels_Export_ExportedWorker
- exportCompleted is fired after all export steps (inclu=
sive all export workers) are finished. Parameter: 'task' =3D> editor_Mod=
els_Task, 'parameters' =3D> array, the initial parameters given to the w=
orker
ZfExtended_Mail
- afterMailViewInit is fired after the view for renderin=
g the mail templates is initialized. Parameter: 'view' =3D> Zend_View
Handmade events
Handmade events are spezial events wich are defined direct in the code. =
No automatic definition is used while trigger.
At the moment there are no handmade events.
Recomendend Best-Practice for using events in classes
Because Zend has a special class for static (global) events, best-pratic=
e 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' =3D> $value
/**
* @var ZfExtended_EventManager
*/
protected $events =3D false;
public function __construct() {
$this->events =3D ZfExtended_Factory::get('ZfExtended_EventManag=
er', array(get_class($this)));
}
public function doSomething(){
$this->events->trigger("eventName", $this, array('model' =3D&=
gt; $this, 'moreParam' =3D> $moreParams));
}
Event-Listener
- use a protected variable $staticEvents to hold the event(-listener)-Obj=
ect.
- 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-definiti=
on-comment so the IDE autocomplete can work correct
/**
* @var Zend_EventManager_StaticEventManager
*/
protected $staticEvents =3D false;
public function __construct(){
$this->staticEvents =3D Zend_EventManager_StaticEventManager::ge=
tInstance();
$this->staticEvents->attach('classNameTriggerClass', 'eventNa=
me', array($this, 'handleEvent'));
}
public function handleEvent(Zend_EventManager_Event $event) {
// do something on event "eventName" with parameters send within ev=
ent-trigger
$model =3D $event->getParam('model');
/* @var $model nameOfTheModelClass */ // to trigger IDE
$moreParams =3D $event->getParam('moreParams');
}
Trigger and Listen=
in one class
If you use two different class-variables $events and $staticEvents you c=
an combine event-triggering and event-listening in one class without proble=
ms.
------=_Part_10_590407712.1711725841992--