EntityType.php
Same filename in this branch
Same filename in other branches
- 9 core/lib/Drupal/Core/Entity/EntityType.php
- 9 core/lib/Drupal/Core/Entity/Annotation/EntityType.php
- 8.9.x core/lib/Drupal/Core/Entity/EntityType.php
- 8.9.x core/lib/Drupal/Core/Entity/Annotation/EntityType.php
- 10 core/lib/Drupal/Core/Entity/EntityType.php
- 10 core/lib/Drupal/Core/Entity/Annotation/EntityType.php
Namespace
Drupal\Core\Entity\AttributeFile
-
core/
lib/ Drupal/ Core/ Entity/ Attribute/ EntityType.php
View source
<?php
namespace Drupal\Core\Entity\Attribute;
use Drupal\Component\Plugin\Attribute\Plugin;
use Drupal\Core\StringTranslation\TranslatableMarkup;
/**
* 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.
*
* @ingroup entity_api
*
* @see \Drupal\Core\Entity\EntityType
* @see \Drupal\Core\Entity\ContentEntityTypeInterface
*/
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);
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
EntityType | Defines an entity type for plugin discovery. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.