EntityManagerInterface deprecated
interface EntityManagerInterface implements EntityTypeListenerInterface, EntityBundleListenerInterface, FieldStorageDefinitionListenerInterface, FieldDefinitionListenerInterface, EntityTypeManagerInterface, EntityTypeRepositoryInterface, EntityTypeBundleInfoInterface, EntityDisplayRepositoryInterface, EntityFieldManagerInterface, EntityRepositoryInterface (View source)
deprecated
Provides an interface for entity type managers.
Methods
Reacts to the creation of the fieldable entity type.
Reacts to the update of the entity type.
Reacts to the update of a fieldable entity type.
Reacts to a bundle being created.
Reacts to a bundle being deleted.
Reacts to the creation of a field storage definition.
Reacts to the update of a field storage definition.
Reacts to the deletion of a field storage definition.
Reacts to the creation of a field.
Reacts to the update of a field.
Reacts to the deletion of a field.
Gets a specific plugin definition.
Indicates if a specific plugin definition exists.
Creates a pre-configured instance of a plugin.
Gets a preconfigured instance of a plugin.
Clears static and persistent plugin definition caches.
Creates a new access control handler instance.
Creates a new storage instance.
Creates a new view builder instance.
Creates a new entity list builder.
Creates a new form instance.
Gets all route provider instances.
Checks whether a certain entity type has a certain handler.
Returns a handler instance for the given entity type and handler.
Creates new handler instance.
Builds a list of entity type labels suitable for a Form API options list.
Gets the entity type ID based on the class that is called on.
Get the bundle info of all entity types.
Gets the bundle info of an entity type.
Gets the entity view mode info for all entity types.
Gets the entity view mode info for a specific entity type.
Gets the entity form mode info for all entity types.
Gets the entity form mode info for a specific entity type.
Gets an array of view mode options.
Gets an array of form mode options.
Returns an array of enabled view mode options by bundle.
Returns an array of enabled form mode options by bundle.
Clears the gathered display mode info.
Returns the entity view display associated with a bundle and view mode.
Returns the entity form display associated with a bundle and form mode.
Gets the base field definitions for a content entity type.
Gets the field definitions for a specific bundle.
Gets the field storage definitions for a content entity type.
Gets a lightweight map of fields across bundles.
Sets a lightweight map of fields across bundles.
Gets a lightweight map of fields across bundles filtered by field type.
Clears static and persistent field definition caches.
Gets the "extra fields" for a bundle.
Loads an entity by UUID.
Loads an entity by the config target identifier.
Gets the entity translation to be used in the given context.
Retrieves the active entity variant matching the specified context.
Retrieves the active entity variants matching the specified context.
Retrieves the canonical entity variant matching the specified context.
Retrieves the canonical entity variants matching the specified context.
Details
onEntityTypeCreate(EntityTypeInterface $entity_type)
Reacts to the creation of the entity type.
onFieldableEntityTypeCreate(EntityTypeInterface $entity_type, array $field_storage_definitions)
Reacts to the creation of the fieldable entity type.
onEntityTypeUpdate(EntityTypeInterface $entity_type, EntityTypeInterface $original)
Reacts to the update of the entity type.
onFieldableEntityTypeUpdate(EntityTypeInterface $entity_type, EntityTypeInterface $original, array $field_storage_definitions, array $original_field_storage_definitions, array $sandbox = NULL)
Reacts to the update of a fieldable entity type.
onEntityTypeDelete(EntityTypeInterface $entity_type)
Reacts to the deletion of the entity type.
onBundleCreate(string $bundle, string $entity_type_id)
Reacts to a bundle being created.
onBundleDelete(string $bundle, string $entity_type_id)
Reacts to a bundle being deleted.
This method runs before fields are deleted.
onFieldStorageDefinitionCreate(FieldStorageDefinitionInterface $storage_definition)
Reacts to the creation of a field storage definition.
onFieldStorageDefinitionUpdate(FieldStorageDefinitionInterface $storage_definition, FieldStorageDefinitionInterface $original)
Reacts to the update of a field storage definition.
onFieldStorageDefinitionDelete(FieldStorageDefinitionInterface $storage_definition)
Reacts to the deletion of a field storage definition.
onFieldDefinitionCreate(FieldDefinitionInterface $field_definition)
Reacts to the creation of a field.
onFieldDefinitionUpdate(FieldDefinitionInterface $field_definition, FieldDefinitionInterface $original)
Reacts to the update of a field.
onFieldDefinitionDelete(FieldDefinitionInterface $field_definition)
Reacts to the deletion of a field.
Stored values should not be wiped at once, but marked as 'deleted' so that they can go through a proper purge process later on.
mixed
getDefinition(string $plugin_id, bool $exception_on_invalid = TRUE)
Gets a specific plugin definition.
array
getDefinitions()
Gets the definition of all plugins for this type.
bool
hasDefinition(string $plugin_id)
Indicates if a specific plugin definition exists.
object
createInstance(string $plugin_id, array $configuration = [])
Creates a pre-configured instance of a plugin.
object|false
getInstance(array $options)
Gets a preconfigured instance of a plugin.
clearCachedDefinitions()
Clears static and persistent plugin definition caches.
Don't resort to calling \Drupal::cache()->delete() and friends to make Drupal detect new or updated plugin definitions. Always use this method on the appropriate plugin type's plugin manager!
useCaches(bool $use_caches = FALSE)
Disable the use of caches.
Can be used to ensure that uncached plugin definitions are returned, without invalidating all cached information.
This will also remove all local/static caches.
EntityAccessControlHandlerInterface
getAccessControlHandler(string $entity_type_id)
Creates a new access control handler instance.
EntityStorageInterface
getStorage(string $entity_type_id)
Creates a new storage instance.
EntityViewBuilderInterface
getViewBuilder(string $entity_type_id)
Creates a new view builder instance.
EntityListBuilderInterface
getListBuilder(string $entity_type_id)
Creates a new entity list builder.
EntityFormInterface
getFormObject(string $entity_type_id, string $operation)
Creates a new form instance.
EntityRouteProviderInterface[]
getRouteProviders(string $entity_type_id)
Gets all route provider instances.
bool
hasHandler(string $entity_type_id, string $handler_type)
Checks whether a certain entity type has a certain handler.
object
getHandler(string $entity_type_id, string $handler_type)
Returns a handler instance for the given entity type and handler.
Entity handlers are instantiated once per entity type and then cached in the entity type manager, and so subsequent calls to getHandler() for a particular entity type and handler type will return the same object. This means that properties on a handler may be used as a static cache, although as the handler is common to all entities of the same type, any data that is per-entity should be keyed by the entity ID.
object
createHandlerInstance(mixed $class, EntityTypeInterface $definition = NULL)
Creates new handler instance.
Usually \Drupal\Core\Entity\EntityManagerInterface::getHandler() is preferred since that method has additional checking that the class exists and has static caches.
array
getEntityTypeLabels(bool $group = FALSE)
Builds a list of entity type labels suitable for a Form API options list.
string
getEntityTypeFromClass(string $class_name)
Gets the entity type ID based on the class that is called on.
Compares the class this is called on against the known entity classes and returns the entity type ID of a direct match or a subclass as fallback, to support entity type definitions that were altered.
array
getAllBundleInfo()
Get the bundle info of all entity types.
array
getBundleInfo(string $entity_type_id)
Gets the bundle info of an entity type.
clearCachedBundles()
Clears static and persistent bundles.
array
getAllViewModes()
Gets the entity view mode info for all entity types.
array
getViewModes(string $entity_type_id)
Gets the entity view mode info for a specific entity type.
array
getAllFormModes()
Gets the entity form mode info for all entity types.
array
getFormModes(string $entity_type_id)
Gets the entity form mode info for a specific entity type.
array
getViewModeOptions(string $entity_type_id)
Gets an array of view mode options.
array
getFormModeOptions(string $entity_type_id)
Gets an array of form mode options.
array
getViewModeOptionsByBundle(string $entity_type_id, string $bundle)
Returns an array of enabled view mode options by bundle.
array
getFormModeOptionsByBundle(string $entity_type_id, string $bundle)
Returns an array of enabled form mode options by bundle.
$this
clearDisplayModeInfo()
Clears the gathered display mode info.
EntityViewDisplayInterface
getViewDisplay(string $entity_type, string $bundle, string $view_mode = self::DEFAULT_DISPLAY_MODE)
Returns the entity view display associated with a bundle and view mode.
Use this function when assigning suggested display options for a component in a given view mode. Note that they will only be actually used at render time if the view mode itself is configured to use dedicated display settings for the bundle; if not, the 'default' display is used instead.
The function reads the entity view display from the current configuration, or returns a ready-to-use empty one if configuration entry exists yet for this bundle and view mode. This streamlines manipulation of display objects by always returning a consistent object that reflects the current state of the configuration.
Example usage:
- Set the 'body' field to be displayed and the 'field_image' field to be hidden on article nodes in the 'default' display.
EntityFormDisplayInterface
getFormDisplay(string $entity_type, string $bundle, string $form_mode = self::DEFAULT_DISPLAY_MODE)
Returns the entity form display associated with a bundle and form mode.
The function reads the entity form display object from the current configuration, or returns a ready-to-use empty one if no configuration entry exists yet for this bundle and form mode. This streamlines manipulation of entity form displays by always returning a consistent object that reflects the current state of the configuration.
Example usage:
- Set the 'body' field to be displayed with the 'text_textarea_with_summary' widget and the 'field_image' field to be hidden on article nodes in the 'default' form mode.
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.
FieldDefinitionInterface[]
getFieldDefinitions(string $entity_type_id, string $bundle)
Gets the field definitions for a specific bundle.
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.
array
getFieldMap()
Gets a lightweight map of fields across bundles.
$this
setFieldMap(array $field_map)
Sets a lightweight map of fields across bundles.
array
getFieldMapByFieldType(string $field_type)
Gets a lightweight map of fields across bundles filtered by field type.
clearCachedFieldDefinitions()
Clears static and persistent field definition caches.
array
getExtraFields(string $entity_type_id, string $bundle)
Gets the "extra fields" for a bundle.
EntityInterface|null
loadEntityByUuid(string $entity_type_id, string $uuid)
Loads an entity by UUID.
Note that some entity types may not support UUIDs.
EntityInterface|null
loadEntityByConfigTarget(string $entity_type_id, string $target)
Loads an entity by the config target identifier.
EntityInterface
getTranslationFromContext(EntityInterface $entity, string $langcode = NULL, array $context = [])
Gets the entity translation to be used in the given context.
This will check whether a translation for the desired language is available and if not, it will fall back to the most appropriate translation based on the provided context.
EntityInterface|null
getActive(string $entity_type_id, int|string $entity_id, array $contexts = NULL)
Retrieves the active entity variant matching the specified context.
If an entity type is revisionable and/or translatable, which entity variant should be handled depends on the context in which the manipulation happens. Based on the specified contextual information, revision and translation negotiation needs to be performed to return the active variant, that is the most up-to-date entity variant in the context scope. This may or may not be an entity variant intended for unprivileged user consumption, in fact it might be a work in progress containing yet to be published information. The active variant should always be retrieved when editing an entity, both in form and in REST workflows, or previewing the related changes.
The negotiation process will not perform any access check, so it is the responsibility of the caller to verify that the user manipulating the entity variant is actually allowed to do so.
EntityInterface
getActiveMultiple(string $entity_type_id, array $entity_ids, array $contexts = NULL)
Retrieves the active entity variants matching the specified context.
EntityInterface|null
getCanonical(string $entity_type_id, int|string $entity_id, array $contexts = NULL)
Retrieves the canonical entity variant matching the specified context.
If an entity type is revisionable and/or translatable, which entity variant should be handled depends on the context in which the manipulation happens. This will return the fittest entity variant intended for unprivileged user consumption matching the specified context. This is typically the variant that would be displayed on the entity's canonical route.
The negotiation process will not perform any access check, so it is the responsibility of the caller to verify that the user manipulating the entity variant is actually allowed to do so.
EntityInterface
getCanonicalMultiple(string $entity_type_id, array $entity_ids, array $contexts = NULL)
Retrieves the canonical entity variants matching the specified context.
getLastInstalledDefinition($entity_type_id)
deprecated
deprecated
No description
getLastInstalledFieldStorageDefinitions($entity_type_id)
deprecated
deprecated
No description