class ConfigEntityType

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

Provides an implementation of a configuration entity type and its metadata.

Hierarchy

Expanded class hierarchy of ConfigEntityType

6 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/Unit/EntityViewsDataTest.php
Contains \Drupal\Tests\views\Unit\EntityViewsDataTest.
rest.install in core/modules/rest/rest.install
Install, update and uninstall functions for the rest module.

... See full list

File

core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php, line 12

Namespace

Drupal\Core\Config\Entity
View 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()
     */
    protected $config_prefix;
    
    /**
     * {@inheritdoc}
     */
    protected $static_cache = FALSE;
    
    /**
     * Keys that are stored key value store for fast lookup.
     *
     * @var array
     */
    protected $lookup_keys = [];
    
    /**
     * The list of configuration entity properties to export from the annotation.
     *
     * @var array
     */
    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 FALSE;
    }
    
    /**
     * {@inheritdoc}
     */
    public function getRevisionDataTable() {
        return FALSE;
    }
    
    /**
     * {@inheritdoc}
     */
    public function getRevisionTable() {
        return FALSE;
    }
    
    /**
     * {@inheritdoc}
     */
    public function getDataTable() {
        return FALSE;
    }
    
    /**
     * {@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) {
        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 {
            // @todo https://www.drupal.org/project/drupal/issues/2949021 Deprecate
            //   fallback to schema.
            $config_name = $this->getConfigPrefix() . '.' . $id;
            $definition = \Drupal::service('config.typed')->getDefinition($config_name);
            if (!isset($definition['mapping'])) {
                return NULL;
            }
            @trigger_error(sprintf('Entity type "%s" is using config schema as a fallback for a missing `config_export` definition is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. See https://www.drupal.org/node/2949023.', $this->id()), E_USER_DEPRECATED);
            $this->mergedConfigExport = array_combine(array_keys($definition['mapping']), array_keys($definition['mapping']));
        }
        return $this->mergedConfigExport;
    }
    
    /**
     * {@inheritdoc}
     */
    public function getLookupKeys() {
        return $this->lookup_keys;
    }

}

Members

Title Sort descending Deprecated Modifiers Object type Summary Overriden Title Overrides
ConfigEntityType::$config_export protected property The list of configuration entity properties to export from the annotation.
ConfigEntityType::$config_prefix protected property The config prefix set in the configuration entity type annotation.
ConfigEntityType::$lookup_keys protected property Keys that are stored key value store for fast lookup.
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 Overrides EntityType::getBaseTable
ConfigEntityType::getConfigDependencyKey public function Overrides EntityType::getConfigDependencyKey
ConfigEntityType::getConfigPrefix public function Overrides ConfigEntityTypeInterface::getConfigPrefix
ConfigEntityType::getDataTable public function Overrides EntityType::getDataTable
ConfigEntityType::getLookupKeys public function Overrides ConfigEntityTypeInterface::getLookupKeys
ConfigEntityType::getPropertiesToExport public function Overrides ConfigEntityTypeInterface::getPropertiesToExport
ConfigEntityType::getRevisionDataTable public function Overrides EntityType::getRevisionDataTable
ConfigEntityType::getRevisionTable public function 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 An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
EntityType::$additional protected property Any additional properties and values.
EntityType::$admin_permission protected property The name of the default administrative permission.
EntityType::$base_table protected property The name of the entity type's base table.
EntityType::$bundle_entity_type protected property The name of the entity type which provides bundles.
EntityType::$bundle_label protected property The human-readable name of the entity bundles, e.g. Vocabulary.
EntityType::$bundle_of protected property The name of the entity type for which bundles are provided.
EntityType::$common_reference_target protected property Indicates whether this entity type is commonly used as a reference target.
EntityType::$constraints protected property Entity constraint definitions.
EntityType::$data_table protected property The name of the entity type's data table.
EntityType::$entity_keys protected property An array of entity keys.
EntityType::$field_ui_base_route protected property The route name used by field UI to attach its management pages.
EntityType::$group protected property The machine name of the entity type group.
EntityType::$group_label protected property The human-readable name of the entity type group.
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_callback Deprecated protected property The name of a callback that returns the label of the entity.
EntityType::$label_collection protected property The human-readable label for a collection of entities of the type.
EntityType::$label_count protected property A definite singular/plural name of the type.
EntityType::$label_plural protected property The indefinite plural name of the type.
EntityType::$label_singular protected property The indefinite singular name of the type.
EntityType::$links protected property Link templates using the URI template syntax.
EntityType::$list_cache_contexts protected property The list cache contexts for this entity type.
EntityType::$list_cache_tags protected property The list cache tags for this entity type.
EntityType::$originalClass protected property The name of the original entity type class.
EntityType::$permission_granularity protected property The permission granularity level.
EntityType::$persistent_cache protected property Indicates if the persistent cache of field data should be used.
EntityType::$render_cache protected property Indicates whether the rendered output of entities should be cached.
EntityType::$revision_data_table protected property The name of the entity type's revision data table.
EntityType::$revision_table protected property The name of the entity type's revision table.
EntityType::$show_revision_ui protected property Indicates whether the revision form fields should be added to the form.
EntityType::$translatable protected property Indicates whether entities of this type have multilingual support.
EntityType::$uri_callback protected property A callable that can be used to provide the entity URI.
EntityType::addConstraint public function Overrides EntityTypeInterface::addConstraint
EntityType::entityClassImplements public function Overrides EntityTypeInterface::entityClassImplements
EntityType::get public function Overrides EntityTypeInterface::get
EntityType::getAccessControlClass public function Overrides EntityTypeInterface::getAccessControlClass
EntityType::getAdminPermission public function Overrides EntityTypeInterface::getAdminPermission
EntityType::getBundleConfigDependency public function Overrides EntityTypeInterface::getBundleConfigDependency
EntityType::getBundleEntityType public function Overrides EntityTypeInterface::getBundleEntityType
EntityType::getBundleLabel public function Overrides EntityTypeInterface::getBundleLabel
EntityType::getBundleOf public function Overrides EntityTypeInterface::getBundleOf
EntityType::getCollectionLabel public function Overrides EntityTypeInterface::getCollectionLabel
EntityType::getConstraints public function Overrides EntityTypeInterface::getConstraints
EntityType::getCountLabel public function Overrides EntityTypeInterface::getCountLabel
EntityType::getFormClass public function Overrides EntityTypeInterface::getFormClass
EntityType::getGroup public function Overrides EntityTypeInterface::getGroup
EntityType::getGroupLabel public function Overrides EntityTypeInterface::getGroupLabel
EntityType::getHandlerClass public function Overrides EntityTypeInterface::getHandlerClass
EntityType::getHandlerClasses public function Overrides EntityTypeInterface::getHandlerClasses
EntityType::getKey public function Overrides EntityTypeInterface::getKey
EntityType::getKeys public function Overrides EntityTypeInterface::getKeys
EntityType::getLabel public function Overrides EntityTypeInterface::getLabel
EntityType::getLabelCallback public function Overrides EntityTypeInterface::getLabelCallback
EntityType::getLinkTemplate public function Overrides EntityTypeInterface::getLinkTemplate
EntityType::getLinkTemplates public function Overrides EntityTypeInterface::getLinkTemplates
EntityType::getListBuilderClass public function Overrides EntityTypeInterface::getListBuilderClass
EntityType::getListCacheContexts public function Overrides EntityTypeInterface::getListCacheContexts
EntityType::getListCacheTags public function Overrides EntityTypeInterface::getListCacheTags
EntityType::getLowercaseLabel public function Overrides EntityTypeInterface::getLowercaseLabel
EntityType::getOriginalClass public function Overrides EntityTypeInterface::getOriginalClass
EntityType::getPermissionGranularity public function Overrides EntityTypeInterface::getPermissionGranularity
EntityType::getPluralLabel public function Overrides EntityTypeInterface::getPluralLabel
EntityType::getRouteProviderClasses public function Overrides EntityTypeInterface::getRouteProviderClasses
EntityType::getSingularLabel public function Overrides EntityTypeInterface::getSingularLabel
EntityType::getStorageClass public function Overrides EntityTypeInterface::getStorageClass
EntityType::getUriCallback public function Overrides EntityTypeInterface::getUriCallback
EntityType::getViewBuilderClass public function Overrides EntityTypeInterface::getViewBuilderClass
EntityType::hasFormClasses public function Overrides EntityTypeInterface::hasFormClasses
EntityType::hasHandlerClass public function Overrides EntityTypeInterface::hasHandlerClass
EntityType::hasKey public function Overrides EntityTypeInterface::hasKey
EntityType::hasLabelCallback public function Overrides EntityTypeInterface::hasLabelCallback
EntityType::hasLinkTemplate public function Overrides EntityTypeInterface::hasLinkTemplate
EntityType::hasListBuilderClass public function Overrides EntityTypeInterface::hasListBuilderClass
EntityType::hasRouteProviders public function Overrides EntityTypeInterface::hasRouteProviders
EntityType::hasViewBuilderClass public function Overrides EntityTypeInterface::hasViewBuilderClass
EntityType::isCommonReferenceTarget public function Overrides EntityTypeInterface::isCommonReferenceTarget
EntityType::isInternal public function Overrides EntityTypeInterface::isInternal
EntityType::isPersistentlyCacheable public function Overrides EntityTypeInterface::isPersistentlyCacheable
EntityType::isRenderCacheable public function Overrides EntityTypeInterface::isRenderCacheable
EntityType::isRevisionable public function Overrides EntityTypeInterface::isRevisionable
EntityType::isStaticallyCacheable public function Overrides EntityTypeInterface::isStaticallyCacheable
EntityType::isSubclassOf public function Overrides EntityTypeInterface::isSubclassOf
EntityType::isTranslatable public function Overrides EntityTypeInterface::isTranslatable
EntityType::set public function Overrides EntityTypeInterface::set
EntityType::setAccessClass public function Overrides EntityTypeInterface::setAccessClass
EntityType::setClass public function Overrides PluginDefinition::setClass
EntityType::setConstraints public function Overrides EntityTypeInterface::setConstraints
EntityType::setFormClass public function Overrides EntityTypeInterface::setFormClass
EntityType::setHandlerClass public function Overrides EntityTypeInterface::setHandlerClass
EntityType::setLabelCallback public function Overrides EntityTypeInterface::setLabelCallback
EntityType::setLinkTemplate public function Overrides EntityTypeInterface::setLinkTemplate
EntityType::setListBuilderClass public function Overrides EntityTypeInterface::setListBuilderClass
EntityType::setStorageClass public function Overrides EntityTypeInterface::setStorageClass
EntityType::setUriCallback public function Overrides EntityTypeInterface::setUriCallback
EntityType::setViewBuilderClass public function Overrides EntityTypeInterface::setViewBuilderClass
EntityType::showRevisionUi public function 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 Overrides PluginDefinitionInterface::getClass
PluginDefinition::getProvider public function Overrides PluginDefinitionInterface::getProvider
PluginDefinition::id public function Overrides PluginDefinitionInterface::id 1
StringTranslationTrait::$stringTranslation protected property The string translation service.
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.