function EntityContextDefinition::getConstraintObjects

Same name in other branches
  1. 9 core/lib/Drupal/Core/Plugin/Context/EntityContextDefinition.php \Drupal\Core\Plugin\Context\EntityContextDefinition::getConstraintObjects()
  2. 8.9.x core/lib/Drupal/Core/Plugin/Context/EntityContextDefinition.php \Drupal\Core\Plugin\Context\EntityContextDefinition::getConstraintObjects()
  3. 10 core/lib/Drupal/Core/Plugin/Context/EntityContextDefinition.php \Drupal\Core\Plugin\Context\EntityContextDefinition::getConstraintObjects()

Overrides ContextDefinition::getConstraintObjects

1 call to EntityContextDefinition::getConstraintObjects()
EntityContextDefinition::getSampleValues in core/lib/Drupal/Core/Plugin/Context/EntityContextDefinition.php

File

core/lib/Drupal/Core/Plugin/Context/EntityContextDefinition.php, line 43

Class

EntityContextDefinition
Defines a class to provide entity context definitions.

Namespace

Drupal\Core\Plugin\Context

Code

protected function getConstraintObjects() {
    if (!$this->getConstraint('EntityType')) {
        $this->addConstraint('EntityType', [
            'type' => $this->getEntityTypeId(),
        ]);
    }
    return parent::getConstraintObjects();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.