function NodeType::applyConstraints

Parameters

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

Overrides ConstraintConditionInterface::applyConstraints

File

src/Plugin/Condition/NodeType.php, line 26

Class

NodeType

Namespace

Drupal\ctools\Plugin\Condition

Code

public function applyConstraints(array $contexts = []) {
    // Nullify any bundle constraints on contexts we care about.
    $this->removeConstraints($contexts);
    // If a single bundle is configured, we can set a proper constraint.
    if (count($this->configuration['bundles']) == 1) {
        $bundle = array_values($this->configuration['bundles']);
        foreach ($this->getContextMapping() as $definition_id => $context_id) {
            $contexts[$context_id]->getContextDefinition()
                ->addConstraint('Bundle', [
                'value' => $bundle[0],
            ]);
        }
    }
}