annotate core/lib/Drupal/Core/Entity/EntityFieldManagerInterface.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents af1871eacc83
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Drupal\Core\Entity;
Chris@0 4
Chris@0 5 /**
Chris@0 6 * Provides an interface for an entity field manager.
Chris@0 7 */
Chris@0 8 interface EntityFieldManagerInterface {
Chris@0 9
Chris@0 10 /**
Chris@0 11 * Gets the base field definitions for a content entity type.
Chris@0 12 *
Chris@0 13 * Only fields that are not specific to a given bundle or set of bundles are
Chris@0 14 * returned. This excludes configurable fields, as they are always attached
Chris@0 15 * to a specific bundle.
Chris@0 16 *
Chris@0 17 * @param string $entity_type_id
Chris@0 18 * The entity type ID. Only entity types that implement
Chris@0 19 * \Drupal\Core\Entity\FieldableEntityInterface are supported.
Chris@0 20 *
Chris@0 21 * @return \Drupal\Core\Field\FieldDefinitionInterface[]
Chris@0 22 * The array of base field definitions for the entity type, keyed by field
Chris@0 23 * name.
Chris@0 24 *
Chris@0 25 * @throws \LogicException
Chris@0 26 * Thrown if one of the entity keys is flagged as translatable.
Chris@0 27 */
Chris@0 28 public function getBaseFieldDefinitions($entity_type_id);
Chris@0 29
Chris@0 30 /**
Chris@0 31 * Gets the field definitions for a specific bundle.
Chris@0 32 *
Chris@0 33 * @param string $entity_type_id
Chris@0 34 * The entity type ID. Only entity types that implement
Chris@0 35 * \Drupal\Core\Entity\FieldableEntityInterface are supported.
Chris@0 36 * @param string $bundle
Chris@0 37 * The bundle.
Chris@0 38 *
Chris@0 39 * @return \Drupal\Core\Field\FieldDefinitionInterface[]
Chris@0 40 * The array of field definitions for the bundle, keyed by field name.
Chris@0 41 */
Chris@0 42 public function getFieldDefinitions($entity_type_id, $bundle);
Chris@0 43
Chris@0 44 /**
Chris@0 45 * Gets the field storage definitions for a content entity type.
Chris@0 46 *
Chris@0 47 * This returns all field storage definitions for base fields and bundle
Chris@0 48 * fields of an entity type. Note that field storage definitions of a base
Chris@0 49 * field equal the full base field definition (i.e. they implement
Chris@0 50 * FieldDefinitionInterface), while the storage definitions for bundle fields
Chris@0 51 * may implement FieldStorageDefinitionInterface only.
Chris@0 52 *
Chris@0 53 * @param string $entity_type_id
Chris@0 54 * The entity type ID. Only content entities are supported.
Chris@0 55 *
Chris@0 56 * @return \Drupal\Core\Field\FieldStorageDefinitionInterface[]
Chris@0 57 * The array of field storage definitions for the entity type, keyed by
Chris@0 58 * field name.
Chris@0 59 *
Chris@0 60 * @see \Drupal\Core\Field\FieldStorageDefinitionInterface
Chris@0 61 */
Chris@0 62 public function getFieldStorageDefinitions($entity_type_id);
Chris@0 63
Chris@0 64 /**
Chris@0 65 * Gets a lightweight map of fields across bundles.
Chris@0 66 *
Chris@0 67 * @return array
Chris@0 68 * An array keyed by entity type. Each value is an array which keys are
Chris@0 69 * field names and value is an array with two entries:
Chris@0 70 * - type: The field type.
Chris@0 71 * - bundles: An associative array of the bundles in which the field
Chris@0 72 * appears, where the keys and values are both the bundle's machine name.
Chris@0 73 */
Chris@0 74 public function getFieldMap();
Chris@0 75
Chris@0 76 /**
Chris@0 77 * Sets a lightweight map of fields across bundles.
Chris@0 78 *
Chris@0 79 * @param array[] $field_map
Chris@0 80 * See the return value of self::getFieldMap().
Chris@0 81 *
Chris@0 82 * @return $this
Chris@0 83 */
Chris@0 84 public function setFieldMap(array $field_map);
Chris@0 85
Chris@0 86 /**
Chris@0 87 * Gets a lightweight map of fields across bundles filtered by field type.
Chris@0 88 *
Chris@0 89 * @param string $field_type
Chris@0 90 * The field type to filter by.
Chris@0 91 *
Chris@0 92 * @return array
Chris@0 93 * An array keyed by entity type. Each value is an array which keys are
Chris@0 94 * field names and value is an array with two entries:
Chris@0 95 * - type: The field type.
Chris@0 96 * - bundles: An associative array of the bundles in which the field
Chris@0 97 * appears, where the keys and values are both the bundle's machine name.
Chris@0 98 */
Chris@0 99 public function getFieldMapByFieldType($field_type);
Chris@0 100
Chris@0 101 /**
Chris@0 102 * Clears static and persistent field definition caches.
Chris@0 103 */
Chris@0 104 public function clearCachedFieldDefinitions();
Chris@0 105
Chris@0 106 /**
Chris@0 107 * Disable the use of caches.
Chris@0 108 *
Chris@0 109 * @param bool $use_caches
Chris@0 110 * FALSE to not use any caches.
Chris@0 111 */
Chris@0 112 public function useCaches($use_caches = FALSE);
Chris@0 113
Chris@0 114 /**
Chris@0 115 * Gets the "extra fields" for a bundle.
Chris@0 116 *
Chris@0 117 * @param string $entity_type_id
Chris@0 118 * The entity type ID.
Chris@0 119 * @param string $bundle
Chris@0 120 * The bundle name.
Chris@0 121 *
Chris@0 122 * @return array
Chris@0 123 * A nested array of 'pseudo-field' elements. Each list is nested within the
Chris@0 124 * following keys: entity type, bundle name, context (either 'form' or
Chris@0 125 * 'display'). The keys are the name of the elements as appearing in the
Chris@0 126 * renderable array (either the entity form or the displayed entity). The
Chris@0 127 * value is an associative array:
Chris@0 128 * - label: The human readable name of the element. Make sure you sanitize
Chris@0 129 * this appropriately.
Chris@0 130 * - description: A short description of the element contents.
Chris@0 131 * - weight: The default weight of the element.
Chris@0 132 * - visible: (optional) The default visibility of the element. Defaults to
Chris@0 133 * TRUE.
Chris@0 134 * - edit: (optional) String containing markup (normally a link) used as the
Chris@0 135 * element's 'edit' operation in the administration interface. Only for
Chris@0 136 * 'form' context.
Chris@0 137 * - delete: (optional) String containing markup (normally a link) used as the
Chris@0 138 * element's 'delete' operation in the administration interface. Only for
Chris@0 139 * 'form' context.
Chris@0 140 */
Chris@0 141 public function getExtraFields($entity_type_id, $bundle);
Chris@0 142
Chris@0 143 }