/** * Browse the $area to calculate the general cache policy of the $area * according to the blocks. * If a block is private, the $area becomes private * The Max-age of the area is the min of the Max-age of all blocks * * @param AreaInterface $area * * @return array */ protected function getCacheInfoFromBlocks(AreaInterface $area) { $cacheInfo = $this->formatCacheInfo(-1, true); foreach ($area->getBlocks() as $block) { $cacheInfo = $this->mergeCacheInfo($cacheInfo, $this->formatCacheInfo($block->getMaxAge(), $this->displayBlockManager->isPublic($block))); } return $cacheInfo; }
/** * @param AreaInterface $area * @param NodeInterface|null $node * @param string|null $areaId * * @return FacadeInterface * * @throws TransformerParameterTypeException * @throws AreaTransformerHttpException */ public function transform($area, NodeInterface $node = null, $areaId = null) { $facade = $this->newFacade(); if (!$area instanceof AreaInterface) { throw new TransformerParameterTypeException(); } if (!$node instanceof NodeInterface) { throw new AreaTransformerHttpException(); } $facade->editable = $this->authorizationChecker->isGranted($this->getEditionNodeRole($node), $node); foreach ($area->getBlocks() as $blockPosition => $block) { $facade->addBlock($this->getTransformer('block')->transform($block, $blockPosition)); } if ($facade->editable) { $this->addLinksFromNode($facade, $node, $area, $areaId); } return $facade; }