コード例 #1
0
ファイル: Collector.php プロジェクト: shyim/shopware-profiler
 public function onDispatchLoopShutdown(\Enlight_Event_EventArgs $args)
 {
     if (!$this->container->has('profileId')) {
         return;
     }
     if (!$this->container->has('front')) {
         return;
     }
     /** @var \Enlight_Controller_Response_ResponseHttp $response */
     $response = $args->get('response');
     $profileTemplate = [];
     $profileTemplate['renderedTemplates'] = $this->renderedTemplates;
     $profileTemplate['blockCalls'] = $this->blockCalls;
     $profileTemplate['templateCalls'] = $this->templateCalls;
     $profileTemplate['renderTime'] = $this->renderTime;
     $profileData = $this->container->get('shyim_profiler.collector')->collectInformation($this->container->get('profileController'));
     $profileData['template'] = array_merge($profileData['template'], $profileTemplate);
     $profileData['mails'] = $this->mails;
     $this->container->get('shyim_profiler.collector')->saveCollectInformation($this->container->get('profileId'), $profileData);
     $view = $this->container->get('template');
     $view->assign('sProfiler', $profileData);
     $view->assign('sProfilerCollectors', $this->container->get('shyim_profiler.collector')->getCollectors());
     $view->assign('sProfilerID', $this->container->get('profileId'));
     $view->assign('sProfilerTime', round(microtime(true) - STARTTIME, 3));
     $view->addTemplateDir($this->container->getParameter('shyim_profiler.plugin_dir') . '/Resources/views/');
     $profileTemplate = $view->fetch('@Profiler/index.tpl');
     $content = $response->getBody();
     $content = str_replace('</body>', $profileTemplate . '</body>', $content);
     $response->setBody($content);
 }
コード例 #2
0
ファイル: Collector.php プロジェクト: shyim/shopware-profiler
 public function onDispatchLoopShutdown(\Enlight_Event_EventArgs $args)
 {
     if (empty($this->profileId) || !$this->container->has('front')) {
         return;
     }
     $profileTemplate = [];
     $profileTemplate['renderedTemplates'] = $this->renderedTemplates;
     $profileTemplate['blockCalls'] = $this->blockCalls;
     $profileTemplate['templateCalls'] = $this->templateCalls;
     $profileTemplate['renderTime'] = $this->renderTime;
     $profileData = $this->container->get('shyim_profiler.collector')->collectInformation($this->profileController);
     $profileData['template'] = array_merge($profileData['template'], $profileTemplate);
     $profileData['mails'] = $this->mails;
     $isIPWhitelisted = in_array(Shopware()->Front()->Request()->getClientIp(), explode("\n", $this->pluginConfig['whitelistIP']));
     if (empty($this->pluginConfig['whitelistIP']) || $this->pluginConfig['whitelistIPProfile'] == 1 || $isIPWhitelisted) {
         $this->container->get('shyim_profiler.collector')->saveCollectInformation($this->profileId, $profileData, $this->profileController->Request()->getModuleName() == 'widgets');
     }
     if ($this->profileController->Request()->getModuleName() == 'frontend' && (empty($this->pluginConfig['whitelistIP']) || $isIPWhitelisted)) {
         $view = $this->container->get('template');
         $view->assign('sProfiler', $profileData);
         $view->assign('sProfilerCollectors', $this->container->get('shyim_profiler.collector')->getCollectors());
         $view->assign('sProfilerID', $this->profileId);
         $view->assign('sProfilerTime', round(microtime(true) - STARTTIME, 3));
         $view->addTemplateDir($this->container->getParameter('shyim_profiler.plugin_dir') . '/Resources/views/');
         $profileTemplate = $view->fetch('@Profiler/index.tpl');
         /** @var \Enlight_Controller_Response_ResponseHttp $response */
         $response = $args->get('response');
         $content = $response->getBody();
         $content = str_replace('</body>', $profileTemplate . '</body>', $content);
         $response->setBody($content);
     }
 }
コード例 #3
0
 /**
  * Returns cache information
  *
  * @param string $dir
  * @return array
  */
 public function getDirectoryInfo($dir)
 {
     $docRoot = $this->container->getParameter('kernel.root_dir') . '/';
     $info = array();
     $info['dir'] = str_replace($docRoot, '', $dir);
     $info['dir'] = str_replace(DIRECTORY_SEPARATOR, '/', $info['dir']);
     $info['dir'] = rtrim($info['dir'], '/') . '/';
     if (!file_exists($dir) || !is_dir($dir)) {
         $info['message'] = 'Cache dir not exists';
         return $info;
     }
     if (!is_readable($dir)) {
         $info['message'] = 'Cache dir is not readable';
         return $info;
     }
     if (!is_writable($dir)) {
         $info['message'] = 'Cache dir is not writable';
     }
     $info['size'] = (double) 0;
     $info['files'] = 0;
     $dirIterator = new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS);
     $iterator = new \RecursiveIteratorIterator($dirIterator, \RecursiveIteratorIterator::LEAVES_ONLY);
     /** @var $entry \SplFileInfo */
     foreach ($iterator as $entry) {
         if ($entry->getFileName() === '.gitkeep') {
             continue;
         }
         $info['size'] += $entry->getSize();
         $info['files']++;
     }
     $info['size'] = $this->encodeSize($info['size']);
     $info['freeSpace'] = disk_free_space($dir);
     $info['freeSpace'] = $this->encodeSize($info['freeSpace']);
     return $info;
 }
コード例 #4
0
ファイル: Assets.php プロジェクト: shyim/shopware-profiler
 public function addLessFiles()
 {
     $less = new LessDefinition([], [$this->container->getParameter('shyim_profiler.plugin_dir') . '/Resources/views/frontend/_public/src/less/all.less'], __DIR__);
     return new ArrayCollection([$less]);
 }
コード例 #5
0
 public function onProfilerController()
 {
     $this->container->get('template')->addTemplateDir($this->container->getParameter('shyim_profiler.plugin_dir') . '/Resources/views/');
     return $this->container->getParameter('shyim_profiler.plugin_dir') . '/Controllers/Frontend/Profiler.php';
 }