This document the state "draft" !!!

If you need an event in translate5, 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 = "before".ucfirst($this->_request->getActionName())."Action";
            $this->events->trigger($eventName, $this);
        }

will define an "beforeControllerAction"-event for each an every controller. For the default IndexController of the Editor-Modul this will lead to an event Editor_IndexController#beforeIndexAction

Controller-Events

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.

RestController-Events

ZfExtended_Models_Entity_Abstract

editor_Workflow_Abstract

Task

TaskUserAssoc

 Editor_SegmentController

 Editor_TaskController

editor_LanguageresourcetaskassocController

editor_Models_Import

editor_Models_Import_SegmentProcessor_Review

All other SegmentProcessors may follow with a process event.

editor_Models_Import_Worker_FileTree

editor_Models_Export

editor_Models_Export_ExportedWorker

ZfExtended_Mail

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-pratice to use events in a class is:


Event-Trigger



    /**
     * @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));
    }

Event-Listener


    /**
     * @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

If you use two different class-variables $events and $staticEvents you can combine event-triggering and event-listening in one class without problems.