diff --git a/src/Plugin/Condition/EntityBundle.php b/src/Plugin/Condition/EntityBundle.php index a93d0ec4..608e7c9c 100644 --- a/src/Plugin/Condition/EntityBundle.php +++ b/src/Plugin/Condition/EntityBundle.php @@ -102,11 +102,13 @@ class EntityBundle extends ConditionPluginBase implements ConstraintConditionInt if (empty($this->configuration['bundles']) && !$this->isNegated()) { return TRUE; } + /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ $entity = $this->getContextValue($this->bundleOf->id()); if (!$entity instanceof ContentEntityInterface) { - return TRUE; + // We need to return false if our condition is negated. + return !$this->isNegated(); } return !empty($this->configuration['bundles'][$entity->bundle()]); diff --git a/src/Plugin/Deriver/EntityBundle.php b/src/Plugin/Deriver/EntityBundle.php index 94e4e96f..6c7fe887 100644 --- a/src/Plugin/Deriver/EntityBundle.php +++ b/src/Plugin/Deriver/EntityBundle.php @@ -18,7 +18,7 @@ class EntityBundle extends EntityDeriverBase { $this->derivatives[$entity_type_id] = $base_plugin_definition; $this->derivatives[$entity_type_id]['label'] = $this->getEntityBundleLabel($entity_type); $this->derivatives[$entity_type_id]['context_definitions'] = [ - "$entity_type_id" => new EntityContextDefinition('entity:' . $entity_type_id), + "$entity_type_id" => new EntityContextDefinition('entity:' . $entity_type_id, $this->getEntityBundleLabel($entity_type), FALSE), ]; } }