Example #1
0
 /**
  * Monitor execution time and memory on specified event points in application
  *
  * @return \Enlight_Event_Subscriber_Array
  */
 public function getListeners()
 {
     $events = $this->eventManager->getEvents();
     $listeners = new \Enlight_Event_Subscriber_Array();
     foreach ($events as $event) {
         if ($event == 'Enlight_Controller_Front_DispatchLoopShutdown') {
             continue;
         }
         $listeners->registerListener(new \Enlight_Event_Handler_Default($event, array($this, 'onBenchmarkEvent'), -1000));
         $listeners->registerListener(new \Enlight_Event_Handler_Default($event, array($this, 'onBenchmarkEvent'), 1000));
     }
     return $listeners;
 }
Example #2
0
    /**
     * Monitor execution time and memory on specified event points in application
     *
     * @return Enlight_Event_Subscriber_Array
     */
    public function getListeners()
    {
        $events = array(
            'Enlight_Controller_Front_RouteStartup',
            'Enlight_Controller_Front_RouteShutdown',
            'Enlight_Controller_Front_DispatchLoopStartup',
            'Enlight_Controller_Front_PreDispatch',
            'Enlight_Controller_Front_PostDispatch',
            'Enlight_Controller_Front_DispatchLoopShutdown',

            'Enlight_Controller_Action_Init',
            'Enlight_Controller_Action_PreDispatch',
            'Enlight_Controller_Action_PostDispatch',

            'Enlight_Plugins_ViewRenderer_PreRender',
            'Enlight_Plugins_ViewRenderer_PostRender'
        );

        $listeners = new Enlight_Event_Subscriber_Array();
        foreach ($events as $event) {
            $listeners->registerListener(
                new Enlight_Event_Handler_Default(
                    $event, array($this, 'onBenchmarkEvent'), -99
                )
            );
        }
        return $listeners;
    }