Ejemplo n.º 1
0
 /**
  * Loads all blocks needed to display the document for caching purposes. This
  * includes loading blocks that are owned by the Template.
  *
  * @return Environment
  */
 public function load()
 {
     if ($this->isLoaded) {
         return;
     }
     $blocks = $this->getBlocksRecursive($this->object);
     $blocks = $this->blockManager->sortBlocks($blocks);
     $cacheKey = $this->getCacheKey();
     $blocks = $this->loadSharedBlocks($blocks);
     $this->blockCache[$cacheKey] = $blocks;
     $this->isLoaded = true;
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * Loads all blocks needed to display the document for caching purposes. This
  * includes loading blocks that are owned by the Template.
  *
  * @return Environment
  */
 protected function loadBlocks()
 {
     if ($this->isLoaded) {
         return;
     }
     $blockOwners = $this->getBlockOwners();
     $blocks = array();
     foreach ($blockOwners as $blockOwner) {
         $version = $this->getVersion($blockOwner->getId());
         $owned = $this->blockManager->findByOwner($blockOwner, $version);
         $blocks = array_merge($blocks, $owned);
     }
     $blocks = $this->blockManager->sortBlocks(array_merge($blocks, $blockOwners));
     $cacheKey = $this->getCacheKey();
     $this->blockCache[$cacheKey] = array_filter($blocks, function ($item) {
         return $item instanceof DocumentBlock ? false : true;
     });
     $this->isLoaded = true;
     return $this;
 }