Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a validation before adding or executing layout generator class. #22324

Merged
merged 2 commits into from
Apr 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions lib/internal/Magento/Framework/View/Layout/GeneratorPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class GeneratorPool
* @param ScheduledStructure\Helper $helper
* @param ConditionFactory $conditionFactory
* @param \Psr\Log\LoggerInterface $logger
* @param array $generators
* @param array|null $generators
*/
public function __construct(
ScheduledStructure\Helper $helper,
Expand Down Expand Up @@ -67,7 +67,7 @@ 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 Generator\Context $generatorContext
Expand All @@ -86,11 +86,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;
}
}
Expand Down Expand Up @@ -131,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
Expand Down Expand Up @@ -227,6 +233,8 @@ protected function moveElementInStructure(
}

/**
* Check visibility conditions exists in data.
*
* @param array $data
*
* @return bool
Expand Down