File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33namespace Loki \Base \ViewModel \Block ;
44
5+ use Loki \Components \Util \Block \TransferableAncestorBlockProperties ;
56use Magento \Framework \App \State as AppState ;
67use Magento \Framework \View \Element \AbstractBlock ;
78use Magento \Framework \View \Element \Block \ArgumentInterface ;
@@ -15,13 +16,24 @@ public function __construct(
1516 protected LayoutInterface $ layout ,
1617 protected AppState $ appState ,
1718 protected ChildCounter $ childCounter ,
19+ protected TransferableAncestorBlockProperties $ transferableAncestorBlock
1820 ) {
1921 }
2022
2123 public function populateBlock (
2224 AbstractBlock $ block ,
23- array $ data = []
25+ array $ data = [],
26+ ?AbstractBlock $ ancestorBlock = null ,
2427 ): void {
28+ if ($ ancestorBlock instanceof AbstractBlock) {
29+ foreach ($ this ->transferableAncestorBlock ->getProperties () as $ propertyName ) {
30+ $ propertyValue = $ ancestorBlock ->getData ($ propertyName );
31+ if (!empty ($ propertyValue )) {
32+ $ block ->setData ($ propertyName , $ propertyValue );
33+ }
34+ }
35+ }
36+
2537 $ block ->addData ($ data );
2638 $ block ->setAncestorBlock ($ this ->getAncestorBlock ());
2739 $ block ->setUniqId ($ this ->getUniqId ($ block , $ data ));
You can’t perform that action at this time.
0 commit comments