From 90eff3a7f4d6189c8f55e2456d0e28d9e2d929fb Mon Sep 17 00:00:00 2001 From: Tiago Sampaio Date: Sat, 13 Apr 2019 12:40:25 -0300 Subject: [PATCH 1/2] Adding a validation before adding or executing layout generator class. --- .../Framework/View/Layout/GeneratorPool.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/internal/Magento/Framework/View/Layout/GeneratorPool.php b/lib/internal/Magento/Framework/View/Layout/GeneratorPool.php index 266a1f873f4b7..b899e34e6b39d 100644 --- a/lib/internal/Magento/Framework/View/Layout/GeneratorPool.php +++ b/lib/internal/Magento/Framework/View/Layout/GeneratorPool.php @@ -35,9 +35,9 @@ class GeneratorPool /** * @param ScheduledStructure\Helper $helper - * @param ConditionFactory $conditionFactory - * @param \Psr\Log\LoggerInterface $logger - * @param array $generators + * @param ConditionFactory $conditionFactory + * @param \Psr\Log\LoggerInterface $logger + * @param array $generators */ public function __construct( ScheduledStructure\Helper $helper, @@ -69,8 +69,9 @@ public function getGenerator($type) /** * Traverse through all generators and generate all scheduled elements * - * @param Reader\Context $readerContext + * @param Reader\Context $readerContext * @param Generator\Context $generatorContext + * * @return $this */ public function process(Reader\Context $readerContext, Generator\Context $generatorContext) @@ -86,11 +87,17 @@ public function process(Reader\Context $readerContext, Generator\Context $genera * Add generators to pool * * @param GeneratorInterface[] $generators + * * @return void */ protected function addGenerators(array $generators) { foreach ($generators as $generator) { + if (!$generator instanceof GeneratorInterface) { + throw new \InvalidArgumentException( + sprintf('Generator class must be an instance of %s', GeneratorInterface::class) + ); + } $this->generators[$generator->getType()] = $generator; } } From a27c3e0fb452d772e5af7e577d1c0b6ad2a231ef Mon Sep 17 00:00:00 2001 From: Nazarn96 Date: Wed, 24 Apr 2019 11:24:29 +0300 Subject: [PATCH 2/2] static test fix --- .../Framework/View/Layout/GeneratorPool.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/internal/Magento/Framework/View/Layout/GeneratorPool.php b/lib/internal/Magento/Framework/View/Layout/GeneratorPool.php index b899e34e6b39d..a585eda37df68 100644 --- a/lib/internal/Magento/Framework/View/Layout/GeneratorPool.php +++ b/lib/internal/Magento/Framework/View/Layout/GeneratorPool.php @@ -35,9 +35,9 @@ class GeneratorPool /** * @param ScheduledStructure\Helper $helper - * @param ConditionFactory $conditionFactory - * @param \Psr\Log\LoggerInterface $logger - * @param array $generators + * @param ConditionFactory $conditionFactory + * @param \Psr\Log\LoggerInterface $logger + * @param array|null $generators */ public function __construct( ScheduledStructure\Helper $helper, @@ -67,11 +67,10 @@ public function getGenerator($type) } /** - * Traverse through all generators and generate all scheduled elements + * Traverse through all generators and generate all scheduled elements. * - * @param Reader\Context $readerContext + * @param Reader\Context $readerContext * @param Generator\Context $generatorContext - * * @return $this */ public function process(Reader\Context $readerContext, Generator\Context $generatorContext) @@ -138,9 +137,9 @@ protected function buildStructure(ScheduledStructure $scheduledStructure, Data\S } /** - * Reorder a child of a specified element + * Reorder a child of a specified element. * - * @param ScheduledStructure $scheduledStructure, + * @param ScheduledStructure $scheduledStructure * @param Data\Structure $structure * @param string $elementName * @return void @@ -234,6 +233,8 @@ protected function moveElementInStructure( } /** + * Check visibility conditions exists in data. + * * @param array $data * * @return bool