/** * Constructor * * @param Slot $slot * @param PageBlocksInterface $pageContentsContainer * @param FactoryRepositoryInterface $factoryRepository * * @api */ public function __construct(Slot $slot, PageBlocksInterface $pageContentsContainer, FactoryRepositoryInterface $factoryRepository) { $this->slot = $slot; $this->pageContentsContainer = $pageContentsContainer; $this->factoryRepository = $factoryRepository; $this->languageRepository = $this->factoryRepository->createRepository('Language'); $this->pageRepository = $this->factoryRepository->createRepository('Page'); $this->blockRepository = $this->factoryRepository->createRepository('Block'); $slotBlocks = $this->pageContentsContainer->getSlotBlocks($this->slot->getSlotName()); $this->blocksToArray($slotBlocks); }
protected function mergeAppBlocksAssets(AssetCollection $assetsCollection, array $options) { $blockTypes = $this->pageBlocks->getBlockTypes(); // When a block has examined, it is saved in this array to avoid parsing it again $appsAssets = array(); // merges assets from installed apps foreach ($this->availableBlocks as $className) { if (!in_array($className, $blockTypes)) { continue; } if (!in_array($className, $appsAssets)) { $parameterSchema = '%s.%s_%s'; $parameter = sprintf($parameterSchema, strtolower($className), $options["type"], $options["assetType"]); $this->addAssetsFromContainer($assetsCollection, $parameter); $this->addExtraAssets($assetsCollection, $parameter); $appsAssets[] = $className; } } return $assetsCollection; }
private function initBasePages($languages) { $templates = $this->theme->getTemplates(); foreach ($languages as $language) { $blocks = $this->blockRepository->retrieveContents(array(1, $language->getId()), 1); foreach ($templates as $template) { $this->pageBlocks->setBlocks($blocks); $this->pages['base'][] = $this->initPageTree($language, null, $template); } } }
/** * Verifies when the block is included * * @param string $slotName * @return boolean */ private function isIncluded($slotName) { if (!preg_match('/^([0-9]+)\\-/', $slotName, $matches)) { return false; } // @codeCoverageIgnoreStart $blockId = $matches[1]; $slotBlocks = $this->pageBlocks->getBlocks(); foreach ($slotBlocks as $blocks) { foreach ($blocks as $block) { if ($block->getId() == $blockId) { return true; } } } return false; // @codeCoverageIgnoreEnd }