/**
  * Renders all toolbar entries.
  *
  * @param  ProfilerEvent $event
  * @return array
  * @throws InvalidOptionException
  */
 protected function renderEntries(ProfilerEvent $event)
 {
     $entries = array();
     $report = $event->getReport();
     list($isLatest, $latest) = $this->getLatestVersion(Version::VERSION);
     if (false === ($pos = strpos(Version::VERSION, 'dev'))) {
         $docUri = sprintf(self::DOC_URI_PATTERN, substr(Version::VERSION, 0, 3));
     } else {
         // unreleased dev branch - compare minor part of versions
         $partsCurrent = explode('.', substr(Version::VERSION, 0, $pos));
         $partsLatestRelease = explode('.', $latest);
         $docUri = sprintf(self::DEV_DOC_URI_PATTERN, current($partsLatestRelease) == $partsCurrent[1] ? 'latest' : 'develop');
     }
     $zfEntry = new ViewModel(array('zf_version' => Version::VERSION, 'is_latest' => $isLatest, 'latest' => $latest, 'php_version' => phpversion(), 'has_intl' => extension_loaded('intl'), 'doc_uri' => $docUri, 'modules' => $this->getModules($event)));
     $zfEntry->setTemplate('zend-developer-tools/toolbar/zendframework');
     $entries[] = $this->renderer->render($zfEntry);
     $errors = array();
     $collectors = $this->options->getCollectors();
     $templates = $this->options->getToolbarEntries();
     foreach ($templates as $name => $template) {
         if (isset($collectors[$name])) {
             try {
                 $collectorInstance = $report->getCollector($name);
                 if ($this->options->getToolbarAutoHide() && $collectorInstance instanceof AutoHideInterface && $collectorInstance->canHide()) {
                     continue;
                 }
                 $collector = new ViewModel(array('report' => $report, 'collector' => $collectorInstance));
                 $collector->setTemplate($template);
                 $entries[] = $this->renderer->render($collector);
             } catch (RuntimeException $e) {
                 $errors[$name] = $template;
             }
         }
     }
     if (!empty($errors) || $report->hasErrors()) {
         $tmp = array();
         foreach ($errors as $name => $template) {
             $cur = sprintf('Unable to render toolbar template %s (%s).', $name, $template);
             $tmp[] = $cur;
             $report->addError($cur);
         }
         if ($this->options->isStrict()) {
             throw new InvalidOptionException(implode(' ', $tmp));
         }
     }
     if ($report->hasErrors()) {
         $errorTpl = new ViewModel(array('errors' => $report->getErrors()));
         $errorTpl->setTemplate('zend-developer-tools/toolbar/error');
         $entries[] = $this->renderer->render($errorTpl);
     }
     return $entries;
 }
示例#2
0
 /**
  * Renders all toolbar entries.
  *
  * @param  ProfilerEvent $event
  * @return array
  * @throws InvalidOptionException
  */
 protected function renderEntries(ProfilerEvent $event)
 {
     $entries = array();
     $report = $event->getReport();
     list($isLatest, $latest) = $this->getLatestVersion(Version::VERSION);
     $zfEntry = new ViewModel(array('zf_version' => Version::VERSION, 'is_latest' => $isLatest, 'latest' => $latest, 'php_version' => phpversion(), 'has_intl' => extension_loaded('intl')));
     $zfEntry->setTemplate('zend-developer-tools/toolbar/zendframework');
     $entries[] = $this->renderer->render($zfEntry);
     $errors = array();
     $collectors = $this->options->getCollectors();
     $templates = $this->options->getToolbarEntries();
     foreach ($templates as $name => $template) {
         if (isset($collectors[$name])) {
             try {
                 $collector = new ViewModel(array('report' => $report, 'collector' => $report->getCollector($name)));
                 $collector->setTemplate($template);
                 $entries[] = $this->renderer->render($collector);
             } catch (RuntimeException $e) {
                 $errors[$name] = $template;
             }
         }
     }
     if (!empty($errors) || $report->hasErrors()) {
         $tmp = array();
         foreach ($errors as $name => $template) {
             $cur = sprintf('Unable to render toolbar template %s (%s).', $name, $template);
             $tmp[] = $cur;
             $report->addError($cur);
         }
         if ($this->options->isStrict()) {
             throw new InvalidOptionException(implode(' ', $tmp));
         }
     }
     if ($report->hasErrors()) {
         $errorTpl = new ViewModel(array('errors' => $report->getErrors()));
         $errorTpl->setTemplate('zend-developer-tools/toolbar/error');
         $entries[] = $this->renderer->render($errorTpl);
     }
     return $entries;
 }