Skip to content

Commit d2e5fab

Browse files
committed
Revert behaviour of layout skipping, because repositories might need block from layout
1 parent d0345a6 commit d2e5fab

4 files changed

Lines changed: 20 additions & 4 deletions

File tree

Component/Component.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ public function getBlock(): ?AbstractBlock
150150
return $this->block;
151151
}
152152

153+
public function setBlock(AbstractBlock $block): void
154+
{
155+
$this->block = $block;
156+
}
157+
153158
public function getGlobalMessageRegistry(): GlobalMessageRegistry
154159
{
155160
return $this->globalMessageRegistry;

Component/ComponentRegistry.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ public function getComponentFromBlock(AbstractBlock $block): Component
4545
throw new NoComponentFoundException((string)__('Block has no name', $block->getJsId()));
4646
}
4747

48-
return $this->getComponentByName($blockName);
48+
$component = $this->getComponentByName($blockName);
49+
$component->setBlock($block);
50+
51+
return $component;
4952
}
5053

5154
/**

Controller/Index/Html.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,14 @@ public function execute(): ResultInterface|ResponseInterface
102102
*
103103
* @return ComponentUpdate[]
104104
*/
105-
private function getComponentUpdates(array $updates): array
105+
private function getComponentUpdates(array $updates, LayoutInterface $layout): array
106106
{
107107
$componentUpdates = [];
108108
foreach ($updates as $updateIndex => $update) {
109+
$block = $this->getBlock($layout, $update['blockName']);
109110
$componentUpdate = $this->componentUpdateFactory->create([
110-
'component' => $this->componentRegistry->getComponentByName($update['blockName']),
111+
'block' => $block,
112+
'component' => $this->componentRegistry->getComponentFromBlock($block),
111113
'componentData' => $update['update'],
112114
]);
113115

Util/Controller/ComponentUpdate.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,21 @@
33
namespace Loki\Components\Util\Controller;
44

55
use Loki\Components\Component\Component;
6-
6+
use Magento\Framework\View\Element\AbstractBlock;
77
class ComponentUpdate
88
{
99
public function __construct(
10+
private readonly AbstractBlock $block,
1011
private readonly Component $component,
1112
private readonly mixed $componentData = null
1213
) {
1314
}
1415

16+
public function getBlock(): AbstractBlock
17+
{
18+
return $this->block;
19+
}
20+
1521
public function getComponent(): Component
1622
{
1723
return $this->component;

0 commit comments

Comments
 (0)