Example #1
0
 /**
  * Registers listeners if enabled.
  *
  * @return self
  */
 public function init()
 {
     if ($this->options->isEnabled()) {
         if ($this->options->canFlushEarly()) {
             $this->eventManager->attachAggregate($this->serviceLocator->get('ZDT_FlushListener'));
         }
         if ($this->options->isStrict() && $this->report->hasErrors()) {
             throw new Exception\InvalidOptionException(implode(' ', $this->report->getErrors()));
         }
         $this->eventManager->attachAggregate($this->serviceLocator->get('ZDT_ProfileListener'));
         $this->registerVerbose()->registerToolbar();
         if ($this->options->isStrict() && $this->report->hasErrors()) {
             throw new Exception\ProfilerException(implode(' ', $this->report->getErrors()));
         }
     }
     return $this;
 }