示例#1
0
 /**
  * setUp.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $view = new View();
     $view->theme(option('front_theme'));
     $this->helper = new MenuHelper($view);
 }
示例#2
0
 /**
  * setUp.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $View = new View();
     $View->theme(option('front_theme'));
     $options = ['fixMissing' => false];
     $this->regions = [new Region($View, 'left-sidebar', $options), new Region($View, 'right-sidebar', $options), new Region($View, 'footer', $options)];
     $this->regions[0]->blocks(collection([new Entity(['region' => new Entity(['region' => 'left-sidebar'])]), new Entity(['region' => new Entity(['region' => 'left-sidebar'])]), new Entity(['region' => new Entity(['region' => 'left-sidebar'])])]));
     $this->regions[1]->blocks(collection([new Entity(['region' => new Entity(['region' => 'right-sidebar'])]), new Entity(['region' => new Entity(['region' => 'right-sidebar'])])]));
     $this->regions[2]->blocks(collection([new Entity(['region' => new Entity(['region' => 'footer'])]), new Entity(['region' => new Entity(['region' => 'footer'])]), new Entity(['region' => new Entity(['region' => 'footer'])]), new Entity(['region' => new Entity(['region' => 'footer'])]), new Entity(['region' => new Entity(['region' => 'footer'])])]));
 }
示例#3
0
 /**
  * Fetches all block entities that could be rendered within this region.
  *
  * @return void
  */
 protected function _prepareBlocks()
 {
     $cacheKey = "{$this->_View->theme}_{$this->_machineName}";
     $blocks = TableRegistry::get('Block.Blocks')->find('all')->cache($cacheKey, 'blocks')->contain(['Roles', 'BlockRegions'])->matching('BlockRegions', function ($q) {
         return $q->where(['BlockRegions.theme' => $this->_View->theme(), 'BlockRegions.region' => $this->_machineName]);
     })->where(['Blocks.status' => 1])->order(['BlockRegions.ordering' => 'ASC']);
     $blocks->sortBy(function ($block) {
         return $block->region->ordering;
     }, SORT_ASC);
     // remove blocks that cannot be rendered based on current request.
     $blocks = $blocks->filter(function ($block) {
         return $this->_filterBlock($block) && $block->renderable();
     });
     $this->blocks($blocks);
 }