class EntityType

Same name in this branch
  1. 11.x core/lib/Drupal/Core/Entity/EntityType.php \Drupal\Core\Entity\EntityType
  2. 11.x core/lib/Drupal/Core/Entity/Annotation/EntityType.php \Drupal\Core\Entity\Annotation\EntityType
Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/EntityType.php \Drupal\Core\Entity\EntityType
  2. 9 core/lib/Drupal/Core/Entity/Annotation/EntityType.php \Drupal\Core\Entity\Annotation\EntityType
  3. 8.9.x core/lib/Drupal/Core/Entity/EntityType.php \Drupal\Core\Entity\EntityType
  4. 8.9.x core/lib/Drupal/Core/Entity/Annotation/EntityType.php \Drupal\Core\Entity\Annotation\EntityType
  5. 10 core/lib/Drupal/Core/Entity/EntityType.php \Drupal\Core\Entity\EntityType
  6. 10 core/lib/Drupal/Core/Entity/Annotation/EntityType.php \Drupal\Core\Entity\Annotation\EntityType

Defines an entity type for plugin discovery.

Entity type plugins use an object-based attribute method. The attribute properties of entity types are found on \Drupal\Core\Entity\EntityType and are accessed using get/set methods defined in \Drupal\Core\Entity\EntityTypeInterface.

Hierarchy

Expanded class hierarchy of EntityType

See also

\Drupal\Core\Entity\EntityType

\Drupal\Core\Entity\ContentEntityTypeInterface

Related topics

2 files declare their use of EntityType
EntityLabelTest.php in core/modules/system/tests/src/Kernel/Entity/EntityLabelTest.php
EntityTypeManager.php in core/lib/Drupal/Core/Entity/EntityTypeManager.php
5 string references to 'EntityType'
EntityContextDefinition::getConstraintObjects in core/lib/Drupal/Core/Plugin/Context/EntityContextDefinition.php
Extracts an array of constraints for a context definition object.
EntityContextDefinitionIsSatisfiedTest::providerTestIsSatisfiedBy in core/tests/Drupal/Tests/Core/Plugin/Context/EntityContextDefinitionIsSatisfiedTest.php
Provides test data for ::testIsSatisfiedBy().
EntityDataDefinition::setEntityTypeId in core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php
Sets the entity type ID.
EntityReferenceItem::propertyDefinitions in core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php
EntityStorageBaseTest::testLoadMultiple in core/tests/Drupal/Tests/Core/Entity/EntityStorageBaseTest.php
Test loadMultiple().

File

core/lib/Drupal/Core/Entity/Attribute/EntityType.php, line 21

Namespace

Drupal\Core\Entity\Attribute
View source
class EntityType extends Plugin {
    public function __construct(string $id, ?TranslatableMarkup $label = NULL, ?TranslatableMarkup $label_collection = NULL, ?TranslatableMarkup $label_singular = NULL, ?TranslatableMarkup $label_plural = NULL, string $entity_type_class = 'Drupal\\Core\\Entity\\EntityType', string $group = 'default', TranslatableMarkup $group_label = new TranslatableMarkup('Other', [], [
        'context' => 'Entity type group',
    ]), bool $static_cache = TRUE, bool $render_cache = TRUE, bool $persistent_cache = TRUE, array $entity_keys = [], array $handlers = [], array $links = [], ?string $admin_permission = NULL, ?string $collection_permission = NULL, string $permission_granularity = 'entity_type', ?string $bundle_entity_type = NULL, ?string $bundle_of = NULL, ?TranslatableMarkup $bundle_label = NULL, ?string $base_table = NULL, ?string $data_table = NULL, ?string $revision_table = NULL, ?string $revision_data_table = NULL, bool $internal = FALSE, bool $translatable = FALSE, bool $show_revision_ui = FALSE, array $label_count = [], ?string $uri_callback = NULL, ?string $field_ui_base_route = NULL, bool $common_reference_target = FALSE, array $list_cache_contexts = [], array $list_cache_tags = [], array $constraints = [], array $additional = []) {
    }
    
    /**
     * {@inheritdoc}
     */
    public function get() : array|object {
        // Use the specified entity type class, and remove it before instantiating.
        $class = $this->entity_type_class;
        $values = array_filter(get_object_vars($this) + [
            'class' => $this->getClass(),
            'provider' => $this->getProvider(),
        ], function ($value, $key) {
            return !($value === NULL && ($key === 'deriver' || $key === 'provider' || $key == 'entity_type_class'));
        }, ARRAY_FILTER_USE_BOTH);
        return new $class($values);
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
AttributeBase::$class protected property The class used for this attribute class.
AttributeBase::$provider protected property The provider of the attribute class.
AttributeBase::getClass public function Gets the class of the attribute class. Overrides AttributeInterface::getClass 1
AttributeBase::getId public function Gets the unique ID for this attribute class. Overrides AttributeInterface::getId
AttributeBase::getProvider public function Gets the name of the provider of the attribute class. Overrides AttributeInterface::getProvider
AttributeBase::setClass public function Sets the class of the attributed class. Overrides AttributeInterface::setClass 1
AttributeBase::setProvider public function Sets the name of the provider of the attribute class. Overrides AttributeInterface::setProvider
EntityType::get public function Gets the value of an attribute. Overrides AttributeBase::get
EntityType::__construct public function Constructs a plugin attribute object. Overrides Plugin::__construct 2

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