You are here

public function DeletedFieldsRepository::getFieldDefinitions in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Field/DeletedFieldsRepository.php \Drupal\Core\Field\DeletedFieldsRepository::getFieldDefinitions()

Returns a list of deleted field definitions.

Parameters

string $field_storage_unique_id: (optional) A unique ID of field storage definition for filtering the deleted fields. Defaults to NULL.

Return value

\Drupal\Core\Field\FieldDefinitionInterface[] An array of field definition objects, keyed by their unique identifier.

Overrides DeletedFieldsRepositoryInterface::getFieldDefinitions

File

core/lib/Drupal/Core/Field/DeletedFieldsRepository.php, line 34

Class

DeletedFieldsRepository
Provides a repository for deleted field and field storage objects.

Namespace

Drupal\Core\Field

Code

public function getFieldDefinitions($field_storage_unique_id = NULL) {
  $deleted_field_definitions = $this->state
    ->get('field.field.deleted', []);
  if ($field_storage_unique_id) {
    $deleted_field_definitions = array_filter($deleted_field_definitions, function (FieldDefinitionInterface $field_definition) use ($field_storage_unique_id) {
      return $field_definition
        ->getFieldStorageDefinition()
        ->getUniqueStorageIdentifier() === $field_storage_unique_id;
    });
  }
  return $deleted_field_definitions;
}