3 namespace Drupal\Core\Entity;
6 * Provides an interface for an entity field manager.
8 interface EntityFieldManagerInterface {
11 * Gets the base field definitions for a content entity type.
13 * Only fields that are not specific to a given bundle or set of bundles are
14 * returned. This excludes configurable fields, as they are always attached
15 * to a specific bundle.
17 * @param string $entity_type_id
18 * The entity type ID. Only entity types that implement
19 * \Drupal\Core\Entity\FieldableEntityInterface are supported.
21 * @return \Drupal\Core\Field\FieldDefinitionInterface[]
22 * The array of base field definitions for the entity type, keyed by field
25 * @throws \LogicException
26 * Thrown if one of the entity keys is flagged as translatable.
28 public function getBaseFieldDefinitions($entity_type_id);
31 * Gets the field definitions for a specific bundle.
33 * @param string $entity_type_id
34 * The entity type ID. Only entity types that implement
35 * \Drupal\Core\Entity\FieldableEntityInterface are supported.
36 * @param string $bundle
39 * @return \Drupal\Core\Field\FieldDefinitionInterface[]
40 * The array of field definitions for the bundle, keyed by field name.
42 public function getFieldDefinitions($entity_type_id, $bundle);
45 * Gets the field storage definitions for a content entity type.
47 * This returns all field storage definitions for base fields and bundle
48 * fields of an entity type. Note that field storage definitions of a base
49 * field equal the full base field definition (i.e. they implement
50 * FieldDefinitionInterface), while the storage definitions for bundle fields
51 * may implement FieldStorageDefinitionInterface only.
53 * @param string $entity_type_id
54 * The entity type ID. Only content entities are supported.
56 * @return \Drupal\Core\Field\FieldStorageDefinitionInterface[]
57 * The array of field storage definitions for the entity type, keyed by
60 * @see \Drupal\Core\Field\FieldStorageDefinitionInterface
62 public function getFieldStorageDefinitions($entity_type_id);
65 * Gets a lightweight map of fields across bundles.
68 * An array keyed by entity type. Each value is an array which keys are
69 * field names and value is an array with two entries:
70 * - type: The field type.
71 * - bundles: An associative array of the bundles in which the field
72 * appears, where the keys and values are both the bundle's machine name.
74 public function getFieldMap();
77 * Sets a lightweight map of fields across bundles.
79 * @param array[] $field_map
80 * See the return value of self::getFieldMap().
84 public function setFieldMap(array $field_map);
87 * Gets a lightweight map of fields across bundles filtered by field type.
89 * @param string $field_type
90 * The field type to filter by.
93 * An array keyed by entity type. Each value is an array which keys are
94 * field names and value is an array with two entries:
95 * - type: The field type.
96 * - bundles: An associative array of the bundles in which the field
97 * appears, where the keys and values are both the bundle's machine name.
99 public function getFieldMapByFieldType($field_type);
102 * Clears static and persistent field definition caches.
104 public function clearCachedFieldDefinitions();
107 * Disable the use of caches.
109 * @param bool $use_caches
110 * FALSE to not use any caches.
112 * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
114 * @todo Remove in https://www.drupal.org/node/2549143.
116 public function useCaches($use_caches = FALSE);
119 * Gets the "extra fields" for a bundle.
121 * @param string $entity_type_id
122 * The entity type ID.
123 * @param string $bundle
127 * A nested array of 'pseudo-field' elements. Each list is nested within the
128 * following keys: entity type, bundle name, context (either 'form' or
129 * 'display'). The keys are the name of the elements as appearing in the
130 * renderable array (either the entity form or the displayed entity). The
131 * value is an associative array:
132 * - label: The human readable name of the element. Make sure you sanitize
133 * this appropriately.
134 * - description: A short description of the element contents.
135 * - weight: The default weight of the element.
136 * - visible: (optional) The default visibility of the element. Defaults to
138 * - edit: (optional) String containing markup (normally a link) used as the
139 * element's 'edit' operation in the administration interface. Only for
141 * - delete: (optional) String containing markup (normally a link) used as the
142 * element's 'delete' operation in the administration interface. Only for
145 public function getExtraFields($entity_type_id, $bundle);