Exemplo n.º 1
0
 /**
  * Runs all collectors.
  *
  * @triggers ProfilerEvent::EVENT_COLLECTED
  * @param    MvcEvent $mvcEvent
  * @return   Profiler
  * @throws   Exception\ProfilerException
  */
 public function collect(MvcEvent $mvcEvent)
 {
     $this->report->setToken(uniqid('zdt'))->setUri($mvcEvent->getRequest()->getUriString())->setMethod($mvcEvent->getRequest()->getMethod())->setTime(new \DateTime('now', new \DateTimeZone('UTC')))->setIp($mvcEvent->getRequest()->getServer()->get('REMOTE_ADDR'));
     if (isset($this->collectors)) {
         foreach ($this->collectors as $collector) {
             $collector->collect($mvcEvent);
             $this->report->addCollector(unserialize(serialize($collector)));
         }
         $this->eventManager->trigger(ProfilerEvent::EVENT_COLLECTED, $this->getEvent());
         return $this;
     }
     if ($this->strict === true) {
         throw new Exception\ProfilerException('There is nothing to collect.');
     }
     $this->report->addError('There is nothing to collect.');
     return $this;
 }