Drupal 8  8.0.2
EntityFieldManager Class Reference
Inheritance diagram for EntityFieldManager:

Public Member Functions

 __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)
 
 getBaseFieldDefinitions ($entity_type_id)
 
 getFieldDefinitions ($entity_type_id, $bundle)
 
 getFieldStorageDefinitions ($entity_type_id)
 
 setFieldMap (array $field_map)
 
 getFieldMap ()
 
 getFieldMapByFieldType ($field_type)
 
 clearCachedFieldDefinitions ()
 
 useCaches ($use_caches=FALSE)
 
 getExtraFields ($entity_type_id, $bundle)
 

Protected Member Functions

 buildFieldStorageDefinitions ($entity_type_id)
 

Protected Attributes

 $extraFields = []
 
 $baseFieldDefinitions
 
 $fieldDefinitions
 
 $fieldStorageDefinitions
 
 $fieldMap = []
 
 $fieldMapByFieldType = []
 
 $typedDataManager
 
 $languageManager
 
 $keyValueFactory
 
 $moduleHandler
 
 $entityTypeManager
 
 $entityTypeBundleInfo
 
 $entityDisplayRepository
 

Detailed Description

Manages the discovery of entity fields.

This includes field definitions, base field definitions, and field storage definitions.

Constructor & Destructor Documentation

__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 
)

Constructs a new EntityFieldManager.

Parameters
\Drupal\Core\Entity\EntityTypeManagerInterface$entity_type_managerThe entity type manager.
\Drupal\Core\Entity\EntityTypeBundleInfoInterface$entity_type_bundle_infoThe entity type bundle info.
\Drupal\Core\Entity\EntityDisplayRepositoryInterface$entity_display_repositoryThe entity display repository.
\Drupal\Core\TypedData\TypedDataManagerInterface$typed_data_managerThe typed data manager.
\Drupal\Core\Language\LanguageManagerInterface$language_managerThe language manager.
\Drupal\Core\KeyValueStore\KeyValueFactoryInterface$key_value_factoryThe key-value factory.
\Drupal\Core\Extension\ModuleHandlerInterface$module_handlerThe module handler.
\Drupal\Core\Cache\CacheBackendInterface$cache_backendThe cache backend.

References Drupal\entityTypeManager(), Drupal\languageManager(), Drupal\moduleHandler(), and Drupal\typedDataManager().

Here is the call graph for this function:

Member Function Documentation

buildFieldStorageDefinitions (   $entity_type_id)
protected

Builds field storage definitions for an entity type.

Parameters
string$entity_type_idThe entity type ID. Only entity types that implement are supported
Returns
[] An array of field storage definitions, keyed by field name.

References Drupal\entityTypeManager(), and Drupal\moduleHandler().

Referenced by EntityFieldManager\getFieldStorageDefinitions().

Here is the call graph for this function:

Here is the caller graph for this function:

clearCachedFieldDefinitions ( )

{Clears static and persistent field definition caches.}

Implements EntityFieldManagerInterface.

References Cache\invalidateTags(), and Drupal\typedDataManager().

Here is the call graph for this function:

getBaseFieldDefinitions (   $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.

Parameters
string$entity_type_idThe entity type ID. Only entity types that implement are supported.
Returns
[] The array of base field definitions for the entity type, keyed by field name.
Exceptions
\LogicExceptionThrown if one of the entity keys is flagged as translatable.
}

Implements EntityFieldManagerInterface.

References Drupal\languageManager(), and Cache\PERMANENT.

Referenced by EntityFieldManager\getFieldDefinitions(), EntityFieldManager\getFieldMap(), and EntityFieldManager\getFieldStorageDefinitions().

Here is the call graph for this function:

Here is the caller graph for this function:

getExtraFields (   $entity_type_id,
  $bundle 
)

{Gets the "extra fields" for a bundle.

Parameters
string$entity_type_idThe entity type ID.
string$bundleThe bundle name.
Returns
array A nested array of 'pseudo-field' elements. Each list is nested within the following keys: entity type, bundle name, context (either 'form' or 'display'). The keys are the name of the elements as appearing in the renderable array (either the entity form or the displayed entity). The value is an associative array:
  • label: The human readable name of the element. Make sure you sanitize this appropriately.
  • description: A short description of the element contents.
  • weight: The default weight of the element.
  • visible: (optional) The default visibility of the element. Defaults to TRUE.
  • edit: (optional) String containing markup (normally a link) used as the element's 'edit' operation in the administration interface. Only for 'form' context.
  • delete: (optional) String containing markup (normally a link) used as the element's 'delete' operation in the administration interface. Only for 'form' context.
}

Implements EntityFieldManagerInterface.

References Drupal\languageManager(), Drupal\moduleHandler(), and Cache\PERMANENT.

Here is the call graph for this function:

getFieldDefinitions (   $entity_type_id,
  $bundle 
)

{Gets the field definitions for a specific bundle.

Parameters
string$entity_type_idThe entity type ID. Only entity types that implement are supported.
string$bundleThe bundle.
Returns
[] The array of field definitions for the bundle, keyed by field name.
}

Implements EntityFieldManagerInterface.

References EntityFieldManager\getBaseFieldDefinitions(), Drupal\languageManager(), and Cache\PERMANENT.

Here is the call graph for this function:

getFieldMap ( )

{Gets a lightweight map of fields across bundles.

Returns
array An array keyed by entity type. Each value is an array which keys are field names and value is an array with two entries:
  • type: The field type.
  • bundles: The bundles in which the field appears.
}

Implements EntityFieldManagerInterface.

References EntityFieldManager\$fieldMap, Drupal\entityTypeManager(), EntityFieldManager\getBaseFieldDefinitions(), and Cache\PERMANENT.

Referenced by EntityFieldManager\getFieldMapByFieldType().

Here is the call graph for this function:

Here is the caller graph for this function:

getFieldMapByFieldType (   $field_type)

{Gets a lightweight map of fields across bundles filtered by field type.

Parameters
string$field_typeThe field type to filter by.
Returns
array An array keyed by entity type. Each value is an array which keys are field names and value is an array with two entries:
  • type: The field type.
  • bundles: The bundles in which the field appears.
}

Implements EntityFieldManagerInterface.

References EntityFieldManager\getFieldMap().

Here is the call graph for this function:

getFieldStorageDefinitions (   $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.

Parameters
string$entity_type_idThe entity type ID. Only content entities are supported.
Returns
[] The array of field storage definitions for the entity type, keyed by field name.
See Also
}

Implements EntityFieldManagerInterface.

References EntityFieldManager\buildFieldStorageDefinitions(), EntityFieldManager\getBaseFieldDefinitions(), Drupal\languageManager(), and Cache\PERMANENT.

Here is the call graph for this function:

setFieldMap ( array  $field_map)

{Sets a lightweight map of fields across bundles.

Parameters
array[]$field_map See the return value of self::getFieldMap().
Returns
$this
}

Implements EntityFieldManagerInterface.

useCaches (   $use_caches = FALSE)

{Disable the use of caches.

Parameters
bool$use_cachesFALSE to not use any caches.
Deprecated:
in Drupal 8.0.0, will be removed before Drupal 9.0.0.
Todo:
Remove in https://www.drupal.org/node/2549143.
}

Implements EntityFieldManagerInterface.

Field Documentation

$fieldMap = []
protected

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:

  • type: The field type.
  • bundles: The bundles in which the field appears.
Returns
array

Referenced by EntityFieldManager\getFieldMap().


The documentation for this class was generated from the following file: