Skip to content

Commit 62331d0

Browse files
committed
fix: Allow properties of ancestor block to populate child block
1 parent f893606 commit 62331d0

4 files changed

Lines changed: 29 additions & 2 deletions

File tree

Util/Block/BlockRenderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function get(
2626
throw new RuntimeException((string)__('No block found with name "%1"', $blockName));
2727
}
2828

29-
$this->populateBlock($block, $data);
29+
$this->populateBlock($block, $data, $ancestorBlock);
3030

3131
if ($block instanceof Template && false === strlen($block->getTemplate()) > 0) {
3232
throw new RuntimeException((string)__('No template found with block "%1"', $blockName));

Util/Block/TemplateRenderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function get(
1919
$block = $this->createBlockFromTemplate($templateName, $blockName);
2020
$block->setTemplate($templateName); // @phpstan-ignore bitExpertMagento.setTemplateDisallowedForBlock
2121

22-
$this->populateBlock($block, $data);
22+
$this->populateBlock($block, $data, $ancestorBlock);
2323

2424
return $block;
2525
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Loki\Components\Util\Block;
4+
5+
class TransferableAncestorBlockProperties
6+
{
7+
private array $properties;
8+
9+
public function __construct(
10+
array $properties = []
11+
) {
12+
$this->properties = $properties;
13+
}
14+
15+
public function getProperties(): array
16+
{
17+
return $this->properties;
18+
}
19+
}

etc/di.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,12 @@
119119
</argument>
120120
</arguments>
121121
</type>
122+
123+
<type name="Loki\Components\Util\Block\TransferableAncestorBlockProperties">
124+
<arguments>
125+
<argument name="properties" xsi:type="array">
126+
<item name="css_classes" xsi:type="string">css_classes</item>
127+
</argument>
128+
</arguments>
129+
</type>
122130
</config>

0 commit comments

Comments
 (0)