EntityFieldManager
class EntityFieldManager implements EntityFieldManagerInterface (View source)
Manages the discovery of entity fields.
This includes field definitions, base field definitions, and field storage definitions.
Traits
Provides methods to use a cache backend while respecting a 'use caches' flag.
Wrapper methods for \Drupal\Core\StringTranslation\TranslationInterface.
Properties
| protected CacheBackendInterface | $cacheBackend | Cache backend instance. |
from UseCacheBackendTrait |
| protected bool | $useCaches | Flag whether caches should be used or skipped. |
from UseCacheBackendTrait |
| protected TranslationInterface | $stringTranslation | The string translation service. |
from StringTranslationTrait |
| protected array | $extraFields | Extra fields by bundle. |
|
| protected array | $baseFieldDefinitions | Static cache of base field definitions. |
|
| protected array | $fieldDefinitions | Static cache of field definitions per bundle and entity type. |
|
| protected array | $fieldStorageDefinitions | Static cache of field storage definitions per entity type. |
|
| protected array | $activeFieldStorageDefinitions | Static cache of active field storage definitions per entity type. |
|
| protected array | $fieldMap | An array keyed by entity type. Each value is an array whose keys are field names and whose value is an array with two entries:
|
|
| protected array | $fieldMapByFieldType | An array keyed by field type. Each value is an array whose key are entity types including arrays in the same form that $fieldMap. |
|
| protected TypedDataManagerInterface | $typedDataManager | The typed data manager. |
|
| protected LanguageManagerInterface | $languageManager | The language manager. |
|
| protected KeyValueFactoryInterface | $keyValueFactory | The key-value factory. |
|
| protected ModuleHandlerInterface | $moduleHandler | The module handler. |
|
| protected EntityTypeManagerInterface | $entityTypeManager | The entity type manager. |
|
| protected EntityTypeBundleInfoInterface | $entityTypeBundleInfo | The entity type bundle info. |
|
| protected EntityDisplayRepositoryInterface | $entityDisplayRepository | The entity display repository. |
|
| protected EntityLastInstalledSchemaRepositoryInterface | $entityLastInstalledSchemaRepository | The entity last installed schema repository. |
Methods
Fetches from the cache backend, respecting the use caches flag.
Stores data in the persistent cache, respecting the use caches flag.
Translates a string to the current language or to a given language.
Formats a string containing a count of items.
Returns the number of plurals supported by a given language.
Gets the string translation service.
Constructs a new EntityFieldManager.
Gets the base field definitions for a content entity type.
Builds base field definitions for an entity type.
Gets the field definitions for a specific bundle.
Builds field definitions for a specific bundle within an entity type.
Gets the field storage definitions for a content entity type.
Gets the active field storage definitions for a content entity type.
Sets a lightweight map of fields across bundles.
Gets a lightweight map of fields across bundles.
Gets a lightweight map of fields across bundles filtered by field type.
Builds field storage definitions for an entity type.
Clears static and persistent field definition caches.
Disable the use of caches.
Gets the "extra fields" for a bundle.
Details
protected object|false
cacheGet(string $cid)
Fetches from the cache backend, respecting the use caches flag.
protected
cacheSet(string $cid, mixed $data, int $expire = Cache::PERMANENT, array $tags = [])
Stores data in the persistent cache, respecting the use caches flag.
protected TranslatableMarkup
t(string $string, array $args = [], array $options = [])
Translates a string to the current language or to a given language.
See \Drupal\Core\StringTranslation\TranslatableMarkup::__construct() for important security information and usage guidelines.
In order for strings to be localized, make them available in one of the ways supported by the
protected
formatPlural($count, $singular, $plural, array $args = [], array $options = [])
Formats a string containing a count of items.
protected
getNumberOfPlurals($langcode = NULL)
Returns the number of plurals supported by a given language.
protected TranslationInterface
getStringTranslation()
Gets the string translation service.
$this
setStringTranslation(TranslationInterface $translation)
Sets the string translation service to use.
__construct(EntityTypeManagerInterface $entity_type_manager, EntityTypeBundleInfoInterface $entity_type_bundle_info, EntityDisplayRepositoryInterface $entity_display_repository, TypedDataManagerInterface $typed_data_manager, LanguageManagerInterface $language_manager, KeyValueFactoryInterface $key_value_factory, ModuleHandlerInterface $module_handler, CacheBackendInterface $cache_backend, EntityLastInstalledSchemaRepositoryInterface $entity_last_installed_schema_repository = NULL)
Constructs a new EntityFieldManager.
FieldDefinitionInterface[]
getBaseFieldDefinitions(string $entity_type_id)
Gets the base field definitions for a content entity type.
Only fields that are not specific to a given bundle or set of bundles are returned. This excludes configurable fields, as they are always attached to a specific bundle.
protected FieldDefinitionInterface[]
buildBaseFieldDefinitions(string $entity_type_id)
Builds base field definitions for an entity type.
FieldDefinitionInterface[]
getFieldDefinitions(string $entity_type_id, string $bundle)
Gets the field definitions for a specific bundle.
protected FieldDefinitionInterface[]
buildBundleFieldDefinitions(string $entity_type_id, string $bundle, array $base_field_definitions)
Builds field definitions for a specific bundle within an entity type.
FieldStorageDefinitionInterface[]
getFieldStorageDefinitions(string $entity_type_id)
Gets the field storage definitions for a content entity type.
This returns all field storage definitions for base fields and bundle fields of an entity type. Note that field storage definitions of a base field equal the full base field definition (i.e. they implement FieldDefinitionInterface), while the storage definitions for bundle fields may implement FieldStorageDefinitionInterface only.
FieldStorageDefinitionInterface[]
getActiveFieldStorageDefinitions(string $entity_type_id)
| internal |
Gets the active field storage definitions for a content entity type.
$this
setFieldMap(array $field_map)
Sets a lightweight map of fields across bundles.
array
getFieldMap()
Gets a lightweight map of fields across bundles.
array
getFieldMapByFieldType(string $field_type)
Gets a lightweight map of fields across bundles filtered by field type.
protected FieldStorageDefinitionInterface[]
buildFieldStorageDefinitions(string $entity_type_id)
Builds field storage definitions for an entity type.
clearCachedFieldDefinitions()
Clears static and persistent field definition caches.
useCaches(bool $use_caches = FALSE)
Disable the use of caches.
array
getExtraFields(string $entity_type_id, string $bundle)
Gets the "extra fields" for a bundle.