Skip to content

Commit 2da1c1f

Browse files
authored
ENGCOM-4750: Adding a validation before adding or executing layout generator class. #22324
2 parents fe5d25a + 45f8497 commit 2da1c1f

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

lib/internal/Magento/Framework/View/Layout/GeneratorPool.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class GeneratorPool
3737
* @param ScheduledStructure\Helper $helper
3838
* @param ConditionFactory $conditionFactory
3939
* @param \Psr\Log\LoggerInterface $logger
40-
* @param array $generators
40+
* @param array|null $generators
4141
*/
4242
public function __construct(
4343
ScheduledStructure\Helper $helper,
@@ -67,7 +67,7 @@ public function getGenerator($type)
6767
}
6868

6969
/**
70-
* Traverse through all generators and generate all scheduled elements
70+
* Traverse through all generators and generate all scheduled elements.
7171
*
7272
* @param Reader\Context $readerContext
7373
* @param Generator\Context $generatorContext
@@ -86,11 +86,17 @@ public function process(Reader\Context $readerContext, Generator\Context $genera
8686
* Add generators to pool
8787
*
8888
* @param GeneratorInterface[] $generators
89+
*
8990
* @return void
9091
*/
9192
protected function addGenerators(array $generators)
9293
{
9394
foreach ($generators as $generator) {
95+
if (!$generator instanceof GeneratorInterface) {
96+
throw new \InvalidArgumentException(
97+
sprintf('Generator class must be an instance of %s', GeneratorInterface::class)
98+
);
99+
}
94100
$this->generators[$generator->getType()] = $generator;
95101
}
96102
}
@@ -131,9 +137,9 @@ protected function buildStructure(ScheduledStructure $scheduledStructure, Data\S
131137
}
132138

133139
/**
134-
* Reorder a child of a specified element
140+
* Reorder a child of a specified element.
135141
*
136-
* @param ScheduledStructure $scheduledStructure,
142+
* @param ScheduledStructure $scheduledStructure
137143
* @param Data\Structure $structure
138144
* @param string $elementName
139145
* @return void
@@ -227,6 +233,8 @@ protected function moveElementInStructure(
227233
}
228234

229235
/**
236+
* Check visibility conditions exists in data.
237+
*
230238
* @param array $data
231239
*
232240
* @return bool

0 commit comments

Comments
 (0)