Exemplo n.º 1
0
 /**
  * Attempts to display widget using its template
  *
  * @param string $template Template file name OPTIONAL
  *
  * @return void
  */
 public function display($template = null)
 {
     $flag = isset($template);
     if ($flag || $this->checkVisibility()) {
         if (!$this->isCloned && !$flag) {
             $this->initView();
         }
         // Body of the old includeCompiledFile() method
         $normalized = $this->getTemplateFile($template);
         $compiled = \XLite\Singletons::$handler->flexy->prepare($normalized);
         $cnt = static::$profilerInfo['countDeep']++;
         $cntLevel = static::$profilerInfo['countLevel']++;
         if (static::$profilerInfo['isEnabled']) {
             $timePoint = str_repeat('+', $cntLevel) . '[TPL ' . str_repeat('0', 4 - strlen((string) $cnt)) . $cnt . '] ' . get_class($this) . ' :: ' . substr($template, strlen(LC_DIR_SKINS));
             \XLite\Core\Profiler::getInstance()->log($timePoint);
         }
         if (static::$profilerInfo['markTemplates']) {
             $template = substr($template, strlen(LC_DIR_SKINS));
             $markTplText = get_class($this) . ' : ' . $template . ' (' . $cnt . ')' . ($this->viewListName ? ' [\'' . $this->viewListName . '\' list child]' : '');
             echo '<!-- ' . $markTplText . ' {' . '{{ -->';
         }
         static::$profilerInfo['tail'][] = $normalized;
         include $compiled;
         array_pop(static::$profilerInfo['tail']);
         if (static::$profilerInfo['markTemplates']) {
             echo '<!-- }}' . '} ' . $markTplText . ' -->';
         }
         if (static::$profilerInfo['isEnabled']) {
             \XLite\Core\Profiler::getInstance()->log($timePoint);
         }
         if (!$this->isCloned && !$flag) {
             $this->closeView();
         }
         static::$profilerInfo['countLevel']--;
     }
 }
Exemplo n.º 2
0
 /**
  * Start Doctrine entity manager
  *
  * @return void
  */
 public function startEntityManager()
 {
     // Initialize DB connection and entity manager
     static::$em = \Doctrine\ORM\EntityManager::create($this->getDSN(), $this->configuration);
     if (\XLite\Core\Profiler::getInstance()->enabled) {
         static::$em->getConnection()->getConfiguration()->setSQLLogger(\XLite\Core\Profiler::getInstance());
     }
     static::registerCustomTypes(static::$em);
     // Set charset for DB connection
     $this->setCharset();
     // Bind events
     $events = array(\Doctrine\ORM\Events::loadClassMetadata);
     if (static::$cacheDriver) {
         // Bind cache chekers
         $events[] = \Doctrine\ORM\Events::postPersist;
         $events[] = \Doctrine\ORM\Events::postUpdate;
         $events[] = \Doctrine\ORM\Events::postRemove;
     }
     static::$em->getEventManager()->addEventListener($events, $this);
 }