class ContentEntityType

Same name in this branch
  1. 10 core/lib/Drupal/Core/Entity/Annotation/ContentEntityType.php \Drupal\Core\Entity\Annotation\ContentEntityType
Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Entity/ContentEntityType.php \Drupal\Core\Entity\ContentEntityType
  2. 11.x core/lib/Drupal/Core/Entity/Attribute/ContentEntityType.php \Drupal\Core\Entity\Attribute\ContentEntityType
  3. 11.x core/lib/Drupal/Core/Entity/Annotation/ContentEntityType.php \Drupal\Core\Entity\Annotation\ContentEntityType
  4. 9 core/lib/Drupal/Core/Entity/ContentEntityType.php \Drupal\Core\Entity\ContentEntityType
  5. 9 core/lib/Drupal/Core/Entity/Annotation/ContentEntityType.php \Drupal\Core\Entity\Annotation\ContentEntityType
  6. 8.9.x core/lib/Drupal/Core/Entity/ContentEntityType.php \Drupal\Core\Entity\ContentEntityType
  7. 8.9.x core/lib/Drupal/Core/Entity/Annotation/ContentEntityType.php \Drupal\Core\Entity\Annotation\ContentEntityType
  8. main core/lib/Drupal/Core/Entity/ContentEntityType.php \Drupal\Core\Entity\ContentEntityType
  9. main core/lib/Drupal/Core/Entity/Attribute/ContentEntityType.php \Drupal\Core\Entity\Attribute\ContentEntityType
  10. main core/lib/Drupal/Core/Entity/Annotation/ContentEntityType.php \Drupal\Core\Entity\Annotation\ContentEntityType

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

Hierarchy

Expanded class hierarchy of ContentEntityType

5 files declare their use of ContentEntityType
EntityDefinitionUpdateTest.php in core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php
EntityViewsData.php in core/modules/views/src/EntityViewsData.php
EntityViewsDataTest.php in core/modules/views/tests/src/Kernel/Entity/EntityViewsDataTest.php
ModerationInformationTest.php in core/modules/content_moderation/tests/src/Unit/ModerationInformationTest.php
SqlContentEntityStorageSchemaTest.php in core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php

File

core/lib/Drupal/Core/Entity/ContentEntityType.php, line 8

Namespace

Drupal\Core\Entity
View source
class ContentEntityType extends EntityType implements ContentEntityTypeInterface {
  
  /**
   * An array of entity revision metadata keys.
   *
   * @var array
   */
  // phpcs:ignore Drupal.NamingConventions.ValidVariableName.LowerCamelName
  protected $revision_metadata_keys = [];
  
  /**
   * {@inheritdoc}
   */
  public function __construct($definition) {
    parent::__construct($definition);
    $this->handlers += [
      'storage' => 'Drupal\\Core\\Entity\\Sql\\SqlContentEntityStorage',
      'view_builder' => 'Drupal\\Core\\Entity\\EntityViewBuilder',
    ];
    $this->revision_metadata_keys += [
      'revision_default' => 'revision_default',
    ];
  }
  
  /**
   * {@inheritdoc}
   */
  public function getConfigDependencyKey() {
    return 'content';
  }
  
  /**
   * {@inheritdoc}
   *
   * @throws \InvalidArgumentException
   *   If the provided class does not implement
   *   \Drupal\Core\Entity\ContentEntityStorageInterface.
   *
   * @see \Drupal\Core\Entity\ContentEntityStorageInterface
   */
  protected function checkStorageClass($class) {
    $required_interface = ContentEntityStorageInterface::class;
    if (!is_subclass_of($class, $required_interface)) {
      throw new \InvalidArgumentException("{$class} does not implement {$required_interface}");
    }
  }
  
  /**
   * {@inheritdoc}
   */
  public function getRevisionMetadataKeys() {
    return $this->revision_metadata_keys;
  }
  
  /**
   * {@inheritdoc}
   */
  public function getRevisionMetadataKey($key) {
    $keys = $this->getRevisionMetadataKeys();
    return $keys[$key] ?? FALSE;
  }
  
  /**
   * {@inheritdoc}
   */
  public function hasRevisionMetadataKey($key) {
    $keys = $this->getRevisionMetadataKeys();
    return isset($keys[$key]);
  }
  
  /**
   * {@inheritdoc}
   */
  public function setRevisionMetadataKey($key, $field_name) {
    if ($field_name !== NULL) {
      $this->revision_metadata_keys[$key] = $field_name;
    }
    else {
      unset($this->revision_metadata_keys[$key]);
    }
    return $this;
  }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
ContentEntityType::$revision_metadata_keys protected property An array of entity revision metadata keys.
ContentEntityType::checkStorageClass protected function Overrides EntityType::checkStorageClass
ContentEntityType::getConfigDependencyKey public function Overrides EntityType::getConfigDependencyKey
ContentEntityType::getRevisionMetadataKey public function Overrides ContentEntityTypeInterface::getRevisionMetadataKey
ContentEntityType::getRevisionMetadataKeys public function Overrides ContentEntityTypeInterface::getRevisionMetadataKeys
ContentEntityType::hasRevisionMetadataKey public function Overrides ContentEntityTypeInterface::hasRevisionMetadataKey
ContentEntityType::setRevisionMetadataKey public function Overrides ContentEntityTypeInterface::setRevisionMetadataKey
ContentEntityType::__construct public function Overrides EntityType::__construct
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 2
DependencySerializationTrait::__wakeup public function #[\ReturnTypeWillChange] 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::$collection_permission protected property The name of the collection permission.
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_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::$static_cache protected property Indicates whether entities should be statically cached. 1
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::getBaseTable public function Overrides EntityTypeInterface::getBaseTable 1
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::getCollectionPermission public function Overrides EntityTypeInterface::getCollectionPermission
EntityType::getConstraints public function Overrides EntityTypeInterface::getConstraints 1
EntityType::getCountLabel public function Overrides EntityTypeInterface::getCountLabel
EntityType::getDataTable public function Overrides EntityTypeInterface::getDataTable 1
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::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::getOriginalClass public function Overrides EntityTypeInterface::getOriginalClass
EntityType::getPermissionGranularity public function Overrides EntityTypeInterface::getPermissionGranularity
EntityType::getPluralLabel public function Overrides EntityTypeInterface::getPluralLabel
EntityType::getRevisionDataTable public function Overrides EntityTypeInterface::getRevisionDataTable 1
EntityType::getRevisionTable public function Overrides EntityTypeInterface::getRevisionTable 1
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::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::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::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 1
PluginDefinition::getProvider public function Overrides PluginDefinitionInterface::getProvider
PluginDefinition::id public function 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.