/** * Sets Toolbar options. * * @param array $options */ public function setToolbar(array $options) { if (isset($options['enabled'])) { $this->toolbar['enabled'] = (bool) $options['enabled']; } if (isset($options['version_check'])) { $this->toolbar['version_check'] = (bool) $options['version_check']; } if (isset($options['position'])) { if ($options['position'] !== 'bottom' && $options['position'] !== 'top') { $this->report->addError(sprintf('[\'ZfjPageBanner\'][\'toolbar\'][\'position\'] must be "top" or "bottom", %s given.', $options['position'])); } else { $this->toolbar['position'] = $options['position']; } } if (isset($options['entries'])) { if (is_array($options['entries'])) { foreach ($options['entries'] as $collector => $template) { if ($template === false || $template === null) { unset($this->toolbar['entries'][$collector]); } else { $this->toolbar['entries'][$collector] = $template; } } } else { $this->report->addError(sprintf('[\'ZfjPageBanner\'][\'toolbar\'][\'entries\'] must be an array, %s given.', gettype($options['entries']))); } } }
/** * 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; }