@@ -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