Same filename in this branch
- 8.x-3.x src/Plugin/Deriver/EntityBundle.php
Same filename and directory in other branches
- 4.0.x src/Plugin/Deriver/EntityBundle.php
- 4.0.x src/Plugin/Condition/EntityBundle.php
Namespace
Drupal\ctools\Plugin\Condition
File
-
src/Plugin/Condition/EntityBundle.php
View source
<?php
namespace Drupal\ctools\Plugin\Condition;
use Drupal\Core\Entity\Plugin\Condition\EntityBundle as CoreEntityBundle;
use Drupal\ctools\ConstraintConditionInterface;
class EntityBundle extends CoreEntityBundle implements ConstraintConditionInterface {
public function applyConstraints(array $contexts = []) {
$this->removeConstraints($contexts);
$bundle = array_values($this->configuration['bundles']);
foreach ($this->getContextMapping() as $definition_id => $context_id) {
$contexts[$context_id]->getContextDefinition()
->addConstraint('Bundle', [
'value' => $bundle,
]);
}
}
public function removeConstraints(array $contexts = []) {
foreach ($this->getContextMapping() as $definition_id => $context_id) {
$constraints = $contexts[$context_id]->getContextDefinition()
->getConstraints();
unset($constraints['Bundle']);
$contexts[$context_id]->getContextDefinition()
->setConstraints($constraints);
}
}
}
Classes
| Title |
Deprecated |
Summary |
| EntityBundle |
|
Entity Bundle Constraints |