public function onNotification(GenericEvent $event, $eventName)
    {
        static $start = false;

        switch ($eventName) {
            case Events::PROGRESS:
                if (!$start) {
                    $this->stopwatch->start($event['source']);
                    $start = true;
                }
                return;
            case Events::ERROR:
                $message = 'Parser has detected an error on file "%filename%". %error%';
                break;
            case Events::COMPLETE:
                $message  = "Parsing data source \"%source%\" completed.";
                $appEvent = $this->stopwatch->stop($event['source']);
                $time     = $appEvent->getDuration();
                $memory   = $appEvent->getMemory();

                $event['profile'] = sprintf(
                    'Time: %s, Memory: %4.2fMb',
                    Timer::toTimeString($time),
                    $memory / (1024 * 1024)
                );
                break;
        }
        $format = $this->notifier->getMessageFormat();

        $event['eventname'] = $eventName;
        $event['message']   = strtr($message, $this->getPlaceholders($event));
        $event['formatted'] = strtr($format, $this->getPlaceholders($event));

        $this->notifier->notify($event);
    }
public function onNotification(GenericEvent $event, $eventName)
    {
        static $start = false;

        switch ($eventName) {
            case Events::PROGRESS:
                if (!$start) {
                    $this->stopwatch->start($event['source']);
                    $start = true;
                }
                return;
            case Events::ERROR:
                $message = 'Parser has detected an error on file "%filename%". %error%';
                break;
            case Events::COMPLETE:
                $message  = "Parsing data source \"%source%\" completed.";
                $appEvent = $this->stopwatch->stop($event['source']);
                $time     = $appEvent->getDuration();
                $memory   = $appEvent->getMemory();

                $event['profile'] = sprintf(
                    'Time: %s, Memory: %4.2fMb',
                    Timer::toTimeString($time),
                    $memory / (1024 * 1024)
                );
                break;
        }
        $format = $this->notifier->getMessageFormat();

        $event['eventname'] = $eventName;
        $event['message']   = strtr($message, $this->getPlaceholders($event));
        $event['formatted'] = strtr($format, $this->getPlaceholders($event));

        $this->notifier->notify($event);
    }
public function onNotification ( GenericEvent $ event , $ eventName ) { static $ start = false ; switch ( $ eventName ) { case Events :: PROGRESS : if ( ! $ start ) { $ this -> stopwatch -> start ( $ event [ 'source' ] ) ; $ start = true ; } return ; case Events :: ERROR : $ message = 'Parser has detected an error on file "%filename%". %error%' ; break ; case Events :: COMPLETE : $ message = "Parsing data source \"%source%\" completed." ; $ appEvent = $ this -> stopwatch -> stop ( $ event [ 'source' ] ) ; $ time = $ appEvent -> getDuration ( ) ; $ memory = $ appEvent -> getMemory ( ) ; $ event [ 'profile' ] = sprintf ( 'Time: %s, Memory: %4.2fMb' , Timer :: toTimeString ( $ time ) , $ memory / ( 1024 * 1024 ) ) ; break ; } $ format = $ this -> notifier -> getMessageFormat ( ) ; $ event [ 'eventname' ] = $ eventName ; $ event [ 'message' ] = strtr ( $ message , $ this -> getPlaceholders ( $ event ) ) ; $ event [ 'formatted' ] = strtr ( $ format , $ this -> getPlaceholders ( $ event ) ) ; $ this -> notifier -> notify ( $ event ) ; }
Notifies all important application events

@param GenericEvent $event     Any event
@param string       $eventName Name of event dispatched

@return void
Notifies all important application events