Skip to content

Commit 2067d21

Browse files
committed
Allow component update to load different XML layout handles
1 parent 3b4a667 commit 2067d21

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

Util/Controller/LayoutLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ public function __construct(
1414
) {
1515
}
1616

17-
public function load(array $handles = []): LayoutInterface
17+
public function load(array $handles = [], bool $isView = false, bool $isolated = true): LayoutInterface
1818
{
1919
$handles = $this->layoutHandlerComposite->getHandles($handles);
20-
$resultPage = $this->resultPageFactory->create();
20+
$resultPage = $this->resultPageFactory->create($isView, ['isIsolated' => $isolated]);
2121

2222
if ($handles !== []) {
2323
foreach ($handles as $handle) {

Util/Controller/TargetRenderer.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,18 @@ class TargetRenderer
1212
{
1313
public function __construct(
1414
private readonly EventManager $eventManager,
15-
private readonly LayoutInterface $layout,
1615
private readonly IdConvertor $idConvertor,
1716
private readonly LayoutHandlerComposite $layoutHandlerComposite,
1817
private readonly LayoutLoader $layoutLoader
1918
) {
2019
}
2120

22-
public function render(LayoutInterface $layout, array $targetNames): array
21+
public function render(LayoutInterface $originalLayout, array $targetNames): array
2322
{
24-
$handles = $this->layoutHandlerComposite->getHandles($layout->getUpdate()->getHandles());
25-
$layout = $this->layoutLoader->load($handles);
23+
$handles = $this->layoutHandlerComposite->getHandles($originalLayout->getUpdate()->getHandles());
24+
$newLayout = $this->layoutLoader->load($handles);
2625

27-
return $this->renderBlocks($layout, $this->getTargetBlockNames($targetNames));
26+
return $this->renderBlocks($newLayout, $this->getTargetBlockNames($newLayout, $targetNames));
2827
}
2928

3029
private function renderBlocks(LayoutInterface $layout, array $blockNames): array
@@ -49,18 +48,18 @@ private function renderBlocks(LayoutInterface $layout, array $blockNames): array
4948
return $htmlParts;
5049
}
5150

52-
private function getTargetBlockNames(array $targets): array
51+
private function getTargetBlockNames(LayoutInterface $layout, array $targets): array
5352
{
54-
$blockNames = $this->convertTargetsToBlockNames($targets);
53+
$blockNames = $this->convertTargetsToBlockNames($layout, $targets);
5554
$blockNames = array_unique($blockNames);
5655
$this->eventManager->dispatch('loki_components_blocks', ['blocks' => $blockNames]);
5756

5857
return $blockNames;
5958
}
6059

61-
private function convertTargetsToBlockNames(array $targets): array
60+
private function convertTargetsToBlockNames(LayoutInterface $layout, array $targets): array
6261
{
63-
$allBlockNames = array_keys($this->layout->getAllBlocks());
62+
$allBlockNames = array_keys($layout->getAllBlocks());
6463

6564
$blockNames = [];
6665
foreach ($targets as $target) {

0 commit comments

Comments
 (0)