function EntityBundleConstraint::applyConstraints

Applies relevant constraints for this condition to the injected contexts.

Parameters

\Drupal\Core\Plugin\Context\ContextInterface[] $contexts:

Overrides ConstraintConditionInterface::applyConstraints

File

src/Plugin/Condition/EntityBundleConstraint.php, line 20

Class

EntityBundleConstraint
Entity Bundle Constraints

Namespace

Drupal\ctools\Plugin\Condition

Code

public function applyConstraints(array $contexts = []) {
  // Nullify any bundle constraints on contexts we care about.
  $this->removeConstraints($contexts);
  $bundle = array_values($this->configuration['bundles']);
  // There's only one expected context for this plugin type.
  foreach ($this->getContextMapping() as $definition_id => $context_id) {
    $contexts[$context_id]->getContextDefinition()
      ->addConstraint('Bundle', [
      'value' => $bundle,
    ]);
  }
}