Skip to content

Commit 90eff3a

Browse files
committed
Adding a validation before adding or executing layout generator class.
1 parent b85552f commit 90eff3a

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ class GeneratorPool
3535

3636
/**
3737
* @param ScheduledStructure\Helper $helper
38-
* @param ConditionFactory $conditionFactory
39-
* @param \Psr\Log\LoggerInterface $logger
40-
* @param array $generators
38+
* @param ConditionFactory $conditionFactory
39+
* @param \Psr\Log\LoggerInterface $logger
40+
* @param array $generators
4141
*/
4242
public function __construct(
4343
ScheduledStructure\Helper $helper,
@@ -69,8 +69,9 @@ public function getGenerator($type)
6969
/**
7070
* Traverse through all generators and generate all scheduled elements
7171
*
72-
* @param Reader\Context $readerContext
72+
* @param Reader\Context $readerContext
7373
* @param Generator\Context $generatorContext
74+
*
7475
* @return $this
7576
*/
7677
public function process(Reader\Context $readerContext, Generator\Context $generatorContext)
@@ -86,11 +87,17 @@ public function process(Reader\Context $readerContext, Generator\Context $genera
8687
* Add generators to pool
8788
*
8889
* @param GeneratorInterface[] $generators
90+
*
8991
* @return void
9092
*/
9193
protected function addGenerators(array $generators)
9294
{
9395
foreach ($generators as $generator) {
96+
if (!$generator instanceof GeneratorInterface) {
97+
throw new \InvalidArgumentException(
98+
sprintf('Generator class must be an instance of %s', GeneratorInterface::class)
99+
);
100+
}
94101
$this->generators[$generator->getType()] = $generator;
95102
}
96103
}

0 commit comments

Comments
 (0)