function EntityBundle::applyConstraints

Same name in other branches
  1. 4.0.x src/Plugin/Condition/EntityBundle.php \Drupal\ctools\Plugin\Condition\EntityBundle::applyConstraints()

Parameters

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

Overrides ConstraintConditionInterface::applyConstraints

File

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

Class

EntityBundle
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,
        ]);
    }
}