public function EntityStorageControllerInterface::getFieldDefinitions

Gets an array of entity field definitions.

If a 'bundle' key is present in the given entity definition, fields specific to this bundle are included. Entity fields are always multi-valued, so 'list' is TRUE for each returned field definition.

Parameters

array $constraints: An array of entity constraints as used for entities in typed data definitions, i.e. an array having an 'entity type' and optionally a 'bundle' key. For example:

array(
  'EntityType' => 'node',
  'Bundle' => 'article',
);

Return value

array An array of field definitions of entity fields, keyed by field name. In addition to the typed data definition keys as described at \Drupal::typedData()->create() the follow keys are supported:

  • queryable: Whether the field is queryable via QueryInterface. Defaults to TRUE if 'computed' is FALSE or not set, to FALSE otherwise.
  • translatable: Whether the field is translatable. Defaults to FALSE.
  • configurable: A boolean indicating whether the field is configurable via field.module. Defaults to FALSE.
  • property_constraints: An array of constraint arrays applying to the field item properties, keyed by property name. E.g. the following validates the value property to have a maximum length of 128:
array(
  'value' => array(
    'Length' => array(
      'max' => 128,
    ),
  ),
);

See also

Drupal\Core\TypedData\TypedDataManager::create()

\Drupal::typedData()

File

drupal/core/lib/Drupal/Core/Entity/EntityStorageControllerInterface.php, line 168
Contains \Drupal\Core\Entity\EntityStorageControllerInterface.

Class

EntityStorageControllerInterface
Defines a common interface for entity controller classes.

Namespace

Drupal\Core\Entity

Code

public function getFieldDefinitions(array $constraints);