class EntityIsOfType
Provides an 'Entity is of type' condition.
@todo Add access callback information from Drupal 7?
Plugin annotation
@Condition(
id = "rules_entity_is_of_type",
label = @Translation("Entity is of type"),
category = @Translation("Entity"),
context_definitions = {
"entity" = @ContextDefinition("entity",
label = @Translation("Entity"),
description = @Translation("Specifies the entity for which to evaluate the condition."),
assignment_restriction = "selector"
),
"type" = @ContextDefinition("string",
label = @Translation("Type"),
description = @Translation("The entity type specified by the condition."),
options_provider = "\Drupal\rules\TypedData\Options\EntityTypeOptions",
assignment_restriction = "input"
),
}
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase extends \Drupal\Component\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait
- class \Drupal\Core\Executable\ExecutablePluginBase extends \Drupal\Core\Plugin\PluginBase implements \Drupal\Core\Executable\ExecutableInterface, \Drupal\Core\Cache\CacheableDependencyInterface, \Drupal\Core\Plugin\ContextAwarePluginInterface uses \Drupal\Core\Plugin\ContextAwarePluginTrait
- class \Drupal\Core\Condition\ConditionPluginBase extends \Drupal\Core\Executable\ExecutablePluginBase implements \Drupal\Core\Condition\ConditionInterface uses \Drupal\Core\Plugin\ContextAwarePluginAssignmentTrait
- class \Drupal\rules\Core\RulesConditionBase extends \Drupal\Core\Condition\ConditionPluginBase implements \Drupal\rules\Core\RulesConditionInterface uses \Drupal\rules\Context\ContextProviderTrait, \Drupal\rules\Core\ExecutablePluginTrait, \Drupal\rules\Core\ConfigurationAccessControlTrait
- class \Drupal\rules\Plugin\Condition\EntityIsOfType extends \Drupal\rules\Core\RulesConditionBase
- class \Drupal\rules\Core\RulesConditionBase extends \Drupal\Core\Condition\ConditionPluginBase implements \Drupal\rules\Core\RulesConditionInterface uses \Drupal\rules\Context\ContextProviderTrait, \Drupal\rules\Core\ExecutablePluginTrait, \Drupal\rules\Core\ConfigurationAccessControlTrait
- class \Drupal\Core\Condition\ConditionPluginBase extends \Drupal\Core\Executable\ExecutablePluginBase implements \Drupal\Core\Condition\ConditionInterface uses \Drupal\Core\Plugin\ContextAwarePluginAssignmentTrait
- class \Drupal\Core\Executable\ExecutablePluginBase extends \Drupal\Core\Plugin\PluginBase implements \Drupal\Core\Executable\ExecutableInterface, \Drupal\Core\Cache\CacheableDependencyInterface, \Drupal\Core\Plugin\ContextAwarePluginInterface uses \Drupal\Core\Plugin\ContextAwarePluginTrait
- class \Drupal\Core\Plugin\PluginBase extends \Drupal\Component\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait
Expanded class hierarchy of EntityIsOfType
File
-
src/
Plugin/ Condition/ EntityIsOfType.php, line 32
Namespace
Drupal\rules\Plugin\ConditionView source
class EntityIsOfType extends RulesConditionBase {
/**
* Check if the provided entity is of a specific type.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity to check for a type.
* @param string $type
* The type to check for.
*
* @return bool
* TRUE if the entity is of the provided type.
*/
protected function doEvaluate(EntityInterface $entity, $type) {
$entity_type = $entity->getEntityTypeId();
// Check to see whether the entity's type matches the specified value.
return $entity_type == $type;
}
}