public function ContextHandler::checkRequirements in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Plugin/Context/ContextHandler.php \Drupal\Core\Plugin\Context\ContextHandler::checkRequirements()
Checks a set of requirements against a set of contexts.
@todo Use context definition objects after https://www.drupal.org/node/2281635.
Parameters
\Drupal\Component\Plugin\Context\ContextInterface[] $contexts: An array of available contexts.
\Drupal\Core\TypedData\DataDefinitionInterface[] $requirements: An array of requirements.
Return value
bool TRUE if all of the requirements are satisfied by the context, FALSE otherwise.
Overrides ContextHandlerInterface::checkRequirements
1 call to ContextHandler::checkRequirements()
- ContextHandler::filterPluginDefinitionsByContexts in core/
lib/ Drupal/ Core/ Plugin/ Context/ ContextHandler.php - Determines plugins whose constraints are satisfied by a set of contexts.
File
- core/
lib/ Drupal/ Core/ Plugin/ Context/ ContextHandler.php, line 63
Class
- ContextHandler
- Provides methods to handle sets of contexts.
Namespace
Drupal\Core\Plugin\ContextCode
public function checkRequirements(array $contexts, array $requirements) {
foreach ($requirements as $requirement) {
if ($requirement
->isRequired() && !$this
->getMatchingContexts($contexts, $requirement)) {
return FALSE;
}
}
return TRUE;
}