class ConfigEntityType
Same name in this branch
- 10 core/lib/Drupal/Core/Entity/Annotation/ConfigEntityType.php \Drupal\Core\Entity\Annotation\ConfigEntityType
Same name in other branches
- 9 core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php \Drupal\Core\Config\Entity\ConfigEntityType
- 9 core/lib/Drupal/Core/Entity/Annotation/ConfigEntityType.php \Drupal\Core\Entity\Annotation\ConfigEntityType
- 8.9.x core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php \Drupal\Core\Config\Entity\ConfigEntityType
- 8.9.x core/lib/Drupal/Core/Entity/Annotation/ConfigEntityType.php \Drupal\Core\Entity\Annotation\ConfigEntityType
- 11.x core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php \Drupal\Core\Config\Entity\ConfigEntityType
- 11.x core/lib/Drupal/Core/Entity/Annotation/ConfigEntityType.php \Drupal\Core\Entity\Annotation\ConfigEntityType
- 11.x core/lib/Drupal/Core/Entity/Attribute/ConfigEntityType.php \Drupal\Core\Entity\Attribute\ConfigEntityType
Provides an implementation of a configuration entity type and its metadata.
Hierarchy
- class \Drupal\Component\Plugin\Definition\PluginDefinition implements \Drupal\Component\Plugin\Definition\PluginDefinitionInterface
- class \Drupal\Core\Entity\EntityType extends \Drupal\Component\Plugin\Definition\PluginDefinition implements \Drupal\Core\Entity\EntityTypeInterface uses \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\StringTranslation\StringTranslationTrait
- class \Drupal\Core\Config\Entity\ConfigEntityType extends \Drupal\Core\Entity\EntityType implements \Drupal\Core\Config\Entity\ConfigEntityTypeInterface
- class \Drupal\Core\Entity\EntityType extends \Drupal\Component\Plugin\Definition\PluginDefinition implements \Drupal\Core\Entity\EntityTypeInterface uses \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\StringTranslation\StringTranslationTrait
Expanded class hierarchy of ConfigEntityType
5 files declare their use of ConfigEntityType
- ConfigEntityStorageTest.php in core/
tests/ Drupal/ Tests/ Core/ Config/ Entity/ ConfigEntityStorageTest.php - ConfigEntityTypeTest.php in core/
tests/ Drupal/ Tests/ Core/ Config/ Entity/ ConfigEntityTypeTest.php - EntityResource.php in core/
modules/ rest/ src/ Plugin/ rest/ resource/ EntityResource.php - EntityViewsDataTest.php in core/
modules/ views/ tests/ src/ Kernel/ Entity/ EntityViewsDataTest.php - SchemaCheckTrait.php in core/
lib/ Drupal/ Core/ Config/ Schema/ SchemaCheckTrait.php
File
-
core/
lib/ Drupal/ Core/ Config/ Entity/ ConfigEntityType.php, line 12
Namespace
Drupal\Core\Config\EntityView source
class ConfigEntityType extends EntityType implements ConfigEntityTypeInterface {
/**
* The config prefix set in the configuration entity type annotation.
*
* @var string
*
* @see \Drupal\Core\Config\Entity\ConfigEntityTypeInterface::getConfigPrefix()
*/
// phpcs:ignore Drupal.NamingConventions.ValidVariableName.LowerCamelName
protected $config_prefix;
/**
* {@inheritdoc}
*/
// phpcs:ignore Drupal.NamingConventions.ValidVariableName.LowerCamelName
protected $static_cache = FALSE;
/**
* Keys that are stored key value store for fast lookup.
*
* @var array
*/
// phpcs:ignore Drupal.NamingConventions.ValidVariableName.LowerCamelName
protected $lookup_keys = [];
/**
* The list of configuration entity properties to export from the annotation.
*
* @var array
*/
// phpcs:ignore Drupal.NamingConventions.ValidVariableName.LowerCamelName
protected $config_export = [];
/**
* The result of merging config_export annotation with the defaults.
*
* This is stored on the class so that it does not have to be recalculated.
*
* @var array
*/
protected $mergedConfigExport = [];
/**
* {@inheritdoc}
*
* @throws \Drupal\Core\Config\Entity\Exception\ConfigEntityStorageClassException
* Exception thrown when the provided class is not an instance of
* \Drupal\Core\Config\Entity\ConfigEntityStorage.
*/
public function __construct($definition) {
// Ensure a default list cache tag is set; do this before calling the parent
// constructor, because we want "Configuration System style" cache tags.
if (empty($this->list_cache_tags)) {
$this->list_cache_tags = [
'config:' . $definition['id'] . '_list',
];
}
parent::__construct($definition);
// Always add a default 'uuid' key.
$this->entity_keys['uuid'] = 'uuid';
$this->entity_keys['langcode'] = 'langcode';
$this->handlers += [
'storage' => 'Drupal\\Core\\Config\\Entity\\ConfigEntityStorage',
];
$this->lookup_keys[] = 'uuid';
}
/**
* {@inheritdoc}
*/
public function getConfigPrefix() {
// Ensure that all configuration entities are prefixed by the name of the
// module that provides the configuration entity type.
if (isset($this->config_prefix)) {
$config_prefix = $this->provider . '.' . $this->config_prefix;
}
else {
$config_prefix = $this->provider . '.' . $this->id();
}
if (strlen($config_prefix) > static::PREFIX_LENGTH) {
throw new ConfigPrefixLengthException("The configuration file name prefix {$config_prefix} exceeds the maximum character limit of " . static::PREFIX_LENGTH);
}
return $config_prefix;
}
/**
* {@inheritdoc}
*/
public function getBaseTable() {
return NULL;
}
/**
* {@inheritdoc}
*/
public function getRevisionDataTable() {
return NULL;
}
/**
* {@inheritdoc}
*/
public function getRevisionTable() {
return NULL;
}
/**
* {@inheritdoc}
*/
public function getDataTable() {
return NULL;
}
/**
* {@inheritdoc}
*/
public function getConfigDependencyKey() {
return 'config';
}
/**
* {@inheritdoc}
*
* @throws \Drupal\Core\Config\Entity\Exception\ConfigEntityStorageClassException
* Exception thrown when the provided class is not an instance of
* \Drupal\Core\Config\Entity\ConfigEntityStorage.
*
* @see \Drupal\Core\Config\Entity\ConfigEntityStorage
*/
protected function checkStorageClass($class) {
if (!is_a($class, 'Drupal\\Core\\Config\\Entity\\ConfigEntityStorage', TRUE)) {
throw new ConfigEntityStorageClassException("{$class} is not \\Drupal\\Core\\Config\\Entity\\ConfigEntityStorage or it does not extend it");
}
}
/**
* {@inheritdoc}
*/
public function getPropertiesToExport($id = NULL) {
// @todo https://www.drupal.org/project/drupal/issues/3113620 Make the
// config_export annotation required earlier, remove the possibility of
// returning NULL and deprecate the $id argument.
if (!empty($this->mergedConfigExport)) {
return $this->mergedConfigExport;
}
if (!empty($this->config_export)) {
// Always add default properties to be exported.
$this->mergedConfigExport = [
'uuid' => 'uuid',
'langcode' => 'langcode',
'status' => 'status',
'dependencies' => 'dependencies',
'third_party_settings' => 'third_party_settings',
'_core' => '_core',
];
foreach ($this->config_export as $property => $name) {
if (is_numeric($property)) {
$this->mergedConfigExport[$name] = $name;
}
else {
$this->mergedConfigExport[$property] = $name;
}
}
}
else {
return NULL;
}
return $this->mergedConfigExport;
}
/**
* {@inheritdoc}
*/
public function getLookupKeys() {
return $this->lookup_keys;
}
/**
* {@inheritdoc}
*/
public function getConstraints() {
$constraints = parent::getConstraints();
// If there is an ID key for this config entity type, make it immutable by
// default. Individual config entities can override this with an
// `ImmutableProperties` constraint in their definition that is either empty,
// or with an alternative set of immutable properties.
$id_key = $this->getKey('id');
if ($id_key) {
$constraints += [
'ImmutableProperties' => [
$id_key,
],
];
}
return $constraints;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
ConfigEntityType::$config_export | protected | property | |||
ConfigEntityType::$config_prefix | protected | property | |||
ConfigEntityType::$lookup_keys | protected | property | |||
ConfigEntityType::$mergedConfigExport | protected | property | The result of merging config_export annotation with the defaults. | ||
ConfigEntityType::$static_cache | protected | property | Overrides EntityType::$static_cache | ||
ConfigEntityType::checkStorageClass | protected | function | Overrides EntityType::checkStorageClass | ||
ConfigEntityType::getBaseTable | public | function | Gets the name of the entity's base table. | Overrides EntityType::getBaseTable | |
ConfigEntityType::getConfigDependencyKey | public | function | Gets the key that is used to store configuration dependencies. | Overrides EntityType::getConfigDependencyKey | |
ConfigEntityType::getConfigPrefix | public | function | Gets the config prefix used by the configuration entity type. | Overrides ConfigEntityTypeInterface::getConfigPrefix | |
ConfigEntityType::getConstraints | public | function | Gets an array of validation constraints. | Overrides EntityType::getConstraints | |
ConfigEntityType::getDataTable | public | function | Gets the name of the entity's data table. | Overrides EntityType::getDataTable | |
ConfigEntityType::getLookupKeys | public | function | Gets the keys that are available for fast lookup. | Overrides ConfigEntityTypeInterface::getLookupKeys | |
ConfigEntityType::getPropertiesToExport | public | function | Gets the config entity properties to export if declared on the annotation. | Overrides ConfigEntityTypeInterface::getPropertiesToExport | |
ConfigEntityType::getRevisionDataTable | public | function | Gets the name of the entity's revision data table. | Overrides EntityType::getRevisionDataTable | |
ConfigEntityType::getRevisionTable | public | function | Gets the name of the entity's revision table. | Overrides EntityType::getRevisionTable | |
ConfigEntityType::__construct | public | function | Overrides EntityType::__construct | ||
ConfigEntityTypeInterface::PREFIX_LENGTH | constant | Length limit of the configuration entity prefix. | |||
DependencySerializationTrait::$_entityStorages | protected | property | |||
DependencySerializationTrait::$_serviceIds | protected | property | |||
DependencySerializationTrait::__sleep | public | function | 1 | ||
DependencySerializationTrait::__wakeup | public | function | 2 | ||
EntityType::$additional | protected | property | Any additional properties and values. | ||
EntityType::$admin_permission | protected | property | |||
EntityType::$base_table | protected | property | |||
EntityType::$bundle_entity_type | protected | property | |||
EntityType::$bundle_label | protected | property | |||
EntityType::$bundle_of | protected | property | |||
EntityType::$collection_permission | protected | property | |||
EntityType::$common_reference_target | protected | property | |||
EntityType::$constraints | protected | property | Entity constraint definitions. | ||
EntityType::$data_table | protected | property | |||
EntityType::$entity_keys | protected | property | |||
EntityType::$field_ui_base_route | protected | property | |||
EntityType::$group | protected | property | The machine name of the entity type group. | ||
EntityType::$group_label | protected | property | |||
EntityType::$handlers | protected | property | An array of handlers. | ||
EntityType::$id | protected | property | The unique identifier of this entity type. | Overrides PluginDefinition::$id | |
EntityType::$internal | protected | property | Indicates whether the entity data is internal. | ||
EntityType::$label | protected | property | The human-readable name of the type. | ||
EntityType::$label_collection | protected | property | |||
EntityType::$label_count | protected | property | |||
EntityType::$label_plural | protected | property | |||
EntityType::$label_singular | protected | property | |||
EntityType::$links | protected | property | Link templates using the URI template syntax. | ||
EntityType::$list_cache_contexts | protected | property | |||
EntityType::$list_cache_tags | protected | property | |||
EntityType::$originalClass | protected | property | The name of the original entity type class. | ||
EntityType::$permission_granularity | protected | property | |||
EntityType::$persistent_cache | protected | property | |||
EntityType::$render_cache | protected | property | |||
EntityType::$revision_data_table | protected | property | |||
EntityType::$revision_table | protected | property | |||
EntityType::$show_revision_ui | protected | property | |||
EntityType::$translatable | protected | property | Indicates whether entities of this type have multilingual support. | ||
EntityType::$uri_callback | protected | property | |||
EntityType::addConstraint | public | function | Adds a validation constraint. | Overrides EntityTypeInterface::addConstraint | |
EntityType::entityClassImplements | public | function | Indicates if the entity type class implements the given interface. | Overrides EntityTypeInterface::entityClassImplements | |
EntityType::get | public | function | Gets any arbitrary property. | Overrides EntityTypeInterface::get | |
EntityType::getAccessControlClass | public | function | Gets the access control class. | Overrides EntityTypeInterface::getAccessControlClass | |
EntityType::getAdminPermission | public | function | Gets the name of the default administrative permission. | Overrides EntityTypeInterface::getAdminPermission | |
EntityType::getBundleConfigDependency | public | function | Gets the config dependency info for this entity, if any exists. | Overrides EntityTypeInterface::getBundleConfigDependency | |
EntityType::getBundleEntityType | public | function | Gets the name of the entity type which provides bundles. | Overrides EntityTypeInterface::getBundleEntityType | |
EntityType::getBundleLabel | public | function | Gets the label for the bundle. | Overrides EntityTypeInterface::getBundleLabel | |
EntityType::getBundleOf | public | function | Gets the entity type ID for which this entity provides bundles. | Overrides EntityTypeInterface::getBundleOf | |
EntityType::getCollectionLabel | public | function | Gets the uppercase plural form of the name of the entity type. | Overrides EntityTypeInterface::getCollectionLabel | |
EntityType::getCollectionPermission | public | function | Gets the name of the default collection permission. | Overrides EntityTypeInterface::getCollectionPermission | |
EntityType::getCountLabel | public | function | Gets the label's definite article form for use with a count of entities. | Overrides EntityTypeInterface::getCountLabel | |
EntityType::getFormClass | public | function | Gets the form class for a specific operation. | Overrides EntityTypeInterface::getFormClass | |
EntityType::getGroup | public | function | Gets the machine name of the entity type group. | Overrides EntityTypeInterface::getGroup | |
EntityType::getGroupLabel | public | function | Gets the human-readable name of the entity type group. | Overrides EntityTypeInterface::getGroupLabel | |
EntityType::getHandlerClass | public | function | Overrides EntityTypeInterface::getHandlerClass | ||
EntityType::getHandlerClasses | public | function | Gets an array of handlers. | Overrides EntityTypeInterface::getHandlerClasses | |
EntityType::getKey | public | function | Gets a specific entity key. | Overrides EntityTypeInterface::getKey | |
EntityType::getKeys | public | function | Gets an array of entity keys. | Overrides EntityTypeInterface::getKeys | |
EntityType::getLabel | public | function | Gets the human-readable name of the entity type. | Overrides EntityTypeInterface::getLabel | |
EntityType::getLinkTemplate | public | function | Gets the link template for a given key. | Overrides EntityTypeInterface::getLinkTemplate | |
EntityType::getLinkTemplates | public | function | Gets the link templates using the URI template syntax. | Overrides EntityTypeInterface::getLinkTemplates | |
EntityType::getListBuilderClass | public | function | Gets the list class. | Overrides EntityTypeInterface::getListBuilderClass | |
EntityType::getListCacheContexts | public | function | The list cache contexts associated with this entity type. | Overrides EntityTypeInterface::getListCacheContexts | |
EntityType::getListCacheTags | public | function | The list cache tags associated with this entity type. | Overrides EntityTypeInterface::getListCacheTags | |
EntityType::getOriginalClass | public | function | Gets the name of the original entity type class. | Overrides EntityTypeInterface::getOriginalClass | |
EntityType::getPermissionGranularity | public | function | Gets the permission granularity level. | Overrides EntityTypeInterface::getPermissionGranularity | |
EntityType::getPluralLabel | public | function | Gets the indefinite plural form of the name of the entity type. | Overrides EntityTypeInterface::getPluralLabel | |
EntityType::getRouteProviderClasses | public | function | Gets all the route provide handlers. | Overrides EntityTypeInterface::getRouteProviderClasses | |
EntityType::getSingularLabel | public | function | Gets the indefinite singular form of the name of the entity type. | Overrides EntityTypeInterface::getSingularLabel | |
EntityType::getStorageClass | public | function | Gets the storage class. | Overrides EntityTypeInterface::getStorageClass | |
EntityType::getUriCallback | public | function | Gets a callable that can be used to provide the entity URI. | Overrides EntityTypeInterface::getUriCallback | |
EntityType::getViewBuilderClass | public | function | Gets the view builder class. | Overrides EntityTypeInterface::getViewBuilderClass | |
EntityType::hasFormClasses | public | function | Indicates if this entity type has any forms. | Overrides EntityTypeInterface::hasFormClasses | |
EntityType::hasHandlerClass | public | function | Determines if there is a handler for a given type. | Overrides EntityTypeInterface::hasHandlerClass | |
EntityType::hasKey | public | function | Indicates if a given entity key exists. | Overrides EntityTypeInterface::hasKey | |
EntityType::hasLinkTemplate | public | function | Indicates if a link template exists for a given key. | Overrides EntityTypeInterface::hasLinkTemplate | |
EntityType::hasListBuilderClass | public | function | Indicates if this entity type has a list class. | Overrides EntityTypeInterface::hasListBuilderClass | |
EntityType::hasRouteProviders | public | function | Indicates if this entity type has any route provider. | Overrides EntityTypeInterface::hasRouteProviders | |
EntityType::hasViewBuilderClass | public | function | Indicates if this entity type has a view builder. | Overrides EntityTypeInterface::hasViewBuilderClass | |
EntityType::isCommonReferenceTarget | public | function | Indicates whether this entity type is commonly used as a reference target. | Overrides EntityTypeInterface::isCommonReferenceTarget | |
EntityType::isInternal | public | function | Indicates whether the entity data is internal. | Overrides EntityTypeInterface::isInternal | |
EntityType::isPersistentlyCacheable | public | function | Indicates if the persistent cache of field data should be used. | Overrides EntityTypeInterface::isPersistentlyCacheable | |
EntityType::isRenderCacheable | public | function | Indicates whether the rendered output of entities should be cached. | Overrides EntityTypeInterface::isRenderCacheable | |
EntityType::isRevisionable | public | function | Indicates whether entities of this type have revision support. | Overrides EntityTypeInterface::isRevisionable | |
EntityType::isStaticallyCacheable | public | function | Indicates whether entities should be statically cached. | Overrides EntityTypeInterface::isStaticallyCacheable | |
EntityType::isTranslatable | public | function | Indicates whether entities of this type have multilingual support. | Overrides EntityTypeInterface::isTranslatable | |
EntityType::set | public | function | Sets a value to an arbitrary property. | Overrides EntityTypeInterface::set | |
EntityType::setAccessClass | public | function | Sets the access control handler class. | Overrides EntityTypeInterface::setAccessClass | |
EntityType::setClass | public | function | Sets the class. | Overrides PluginDefinition::setClass | |
EntityType::setConstraints | public | function | Sets the array of validation constraints for the FieldItemList. | Overrides EntityTypeInterface::setConstraints | |
EntityType::setFormClass | public | function | Sets a form class for a specific operation. | Overrides EntityTypeInterface::setFormClass | |
EntityType::setHandlerClass | public | function | Sets the handlers for a given type. | Overrides EntityTypeInterface::setHandlerClass | |
EntityType::setLinkTemplate | public | function | Sets a single link template. | Overrides EntityTypeInterface::setLinkTemplate | |
EntityType::setListBuilderClass | public | function | Sets the list class. | Overrides EntityTypeInterface::setListBuilderClass | |
EntityType::setStorageClass | public | function | Sets the storage class. | Overrides EntityTypeInterface::setStorageClass | |
EntityType::setUriCallback | public | function | Sets a callable to use to provide the entity URI. | Overrides EntityTypeInterface::setUriCallback | |
EntityType::setViewBuilderClass | public | function | Gets the view builder class. | Overrides EntityTypeInterface::setViewBuilderClass | |
EntityType::showRevisionUi | public | function | Indicates whether the revision form fields should be added to the form. | Overrides EntityTypeInterface::showRevisionUi | |
EntityTypeInterface::BUNDLE_MAX_LENGTH | constant | The maximum length of bundle name, in characters. | |||
EntityTypeInterface::ID_MAX_LENGTH | constant | The maximum length of ID, in characters. | |||
PluginDefinition::$class | protected | property | A fully qualified class name. | ||
PluginDefinition::$provider | protected | property | The plugin provider. | ||
PluginDefinition::getClass | public | function | Gets the class. | Overrides PluginDefinitionInterface::getClass | 1 |
PluginDefinition::getProvider | public | function | Gets the plugin provider. | Overrides PluginDefinitionInterface::getProvider | |
PluginDefinition::id | public | function | Gets the unique identifier of the plugin. | Overrides PluginDefinitionInterface::id | 1 |
StringTranslationTrait::$stringTranslation | protected | property | The string translation service. | 3 | |
StringTranslationTrait::formatPlural | protected | function | Formats a string containing a count of items. | ||
StringTranslationTrait::getNumberOfPlurals | protected | function | Returns the number of plurals supported by a given language. | ||
StringTranslationTrait::getStringTranslation | protected | function | Gets the string translation service. | ||
StringTranslationTrait::setStringTranslation | public | function | Sets the string translation service to use. | 2 | |
StringTranslationTrait::t | protected | function | Translates a string to the current language or to a given language. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.