Beispiel #1
0
 /**
  * Render page menu
  * 
  * - $page determines the branch of labeled forest
  * - $useCurrentPageAsLabelRoot
  *      - if set to FALSE (default behaviour) the label root is used as a 
  *        root of traversing
  *      - if is set to TRUE - the $page is used as the root of traversing
  *        even if the $page is labelled passivelly
  * 
  * - $ignorePage (use case MaxPraga shopMenu)
  * 
  * @param type $page
  * @param type $useCurrentPageAsLabelRoot
  * @param type $ignorePage
  */
 public function render($page = NULL, $useCurrentPageAsLabelRoot = FALSE, $ignorePage = FALSE)
 {
     \SimpleProfiler\Profiler::advancedTimer();
     $this->parentPage = $page;
     $traverser = $this->getTraverser();
     //$traverser->preprareRoots();
     $doCaching = FALSE;
     if (isset($this->presenter->page)) {
         $doCaching = TRUE;
     }
     $doCaching = $doCaching && $this->cachingEnabled;
     $cacheKey = NULL;
     if ($doCaching) {
         $cacheKey = $this->presenter->page->getModuleCacheId($this->name);
         if ($traverser->isHighlighted()) {
             $cacheKey = $this->presenter->page->getPageCacheId($this->name);
         }
     }
     $cache = new \Nette\Caching\Cache($this->presenter->context->cacheStorage, 'Bubo.PageMenus');
     $val = $cache->load($cacheKey);
     if (!$doCaching) {
         $val = NULL;
     }
     if ($val === NULL) {
         $val = $traverser ? $traverser->setRenderer($this->setUpRenderer($this->renderer))->setUpSpecifiedRoot($page, $useCurrentPageAsLabelRoot, $ignorePage)->traverse() : '';
         if ($doCaching) {
             $this->cacheTags[] = 'labels/' . $traverser->label['nicename'];
             $dp = array(Cache::TAGS => $this->cacheTags);
             $cache->save($cacheKey, $val->__toString(), $dp);
         }
     }
     echo $val;
     \SimpleProfiler\Profiler::advancedTimer($this->reflection->shortName);
 }
 public function testCounter1()
 {
     Profiler::count('foo');
     Profiler::count('bar');
     Profiler::count('par');
     Profiler::count('foo');
     Profiler::count('foo');
     Profiler::count('bar', 3);
     $this->assertSame([['name' => 'foo', 'count' => 3], ['name' => 'bar', 'count' => 4], ['name' => 'par', 'count' => 1]], Profiler::getCounterStat());
 }