src/Drupal/functions field.php

Functions

field_create_field()

field_create_field(array{field_name: string, type: string}  $field) : \Drupal\field\FieldStorageConfigInterface

Parameters

array{field_name: string, type: string} $field

Returns

\Drupal\field\FieldStorageConfigInterface —

field_create_instance()

field_create_instance(array{field_name: string, entity_type: string, bundle: string}  $instance) : \Drupal\field\FieldConfigInterface

Parameters

array{field_name: string, entity_type: string, bundle: string} $instance

Returns

\Drupal\field\FieldConfigInterface —

anachron_field_storage_for()

anachron_field_storage_for(string  $entity_type, string  $field_name) : void

Copies a field's storage to another entity type.

A Drupal 7 field belongs to no entity type and any instance may use it. A Drupal 11 storage is per entity type, and field_create_field() makes it for node. When the instance names another type, its storage is the node one made again for that type.

Parameters

string $entity_type
string $field_name

Returns

void —

field_info_field()

field_info_field(string  $field_name) : array<string,mixed>|null

Answers one field as the array `field_info_fields()` lists, or null when no field has the name.

Parameters

string $field_name

Returns

array|null —

field_info_field_types()

field_info_field_types(?string  $field_type = null) : array<string,mixed>

Lists the field types in the Drupal 7 shape; see `LegacyFieldTypes`.

Parameters

?string $field_type

Returns

array —

field_info_widget_types()

field_info_widget_types(?string  $widget_type = null) : array<string,mixed>

Lists the widget types in the Drupal 7 shape; see `LegacyFieldTypes`.

Parameters

?string $widget_type

Returns

array —

field_info_formatter_types()

field_info_formatter_types(?string  $formatter_type = null) : array<string,mixed>

Lists the formatter types in the Drupal 7 shape; see `LegacyFieldTypes`.

Parameters

?string $formatter_type

Returns

array —

anachron_legacy_field_types()

anachron_legacy_field_types() : \Drupflare\Anachron\Drupal\Field\LegacyFieldTypes

Returns

\Drupflare\Anachron\Drupal\Field\LegacyFieldTypes —

anachron_field_instance_gaps()

anachron_field_instance_gaps() : array{unmapped: array<string,int>, refusals: array<string,int>}

Reports the instance keys read with no mapping and the writes refused, since the last reset.

Returns

array{unmapped: array, refusals: array} —

field_info_fields()

field_info_fields() : array<string,array<string,mixed>>

Lists every field the way Drupal 7 did, as arrays keyed by field name.

A name used on several entity types lists the bundles of each under its entity type. The keys are the ones a Drupal 7 module reads: id, field_name, deleted (always false), type, module, settings, cardinality, translatable, locked, indexes, columns and bundles. A call made from inside this function's own load answers an empty list, for the reason field_info_instances() gives.

Returns

array> —

field_info_instance()

field_info_instance(string  $entity_type, string  $field_name, string  $bundle_name) : ?\Drupflare\Anachron\Drupal\Field\LegacyFieldInstance

Parameters

string $entity_type
string $field_name
string $bundle_name

Returns

?\Drupflare\Anachron\Drupal\Field\LegacyFieldInstance —

field_read_instances()

field_read_instances(array  $params = [], array  $include_additional = []) : list<\Drupflare\Anachron\Drupal\Field\LegacyFieldInstance>

Reads field instances matching Drupal 7 conditions, as a flat list.

Only entity_type, bundle, field_name and deleted are conditions here. Drupal 11 keeps no deleted instances to read, so deleted true answers an empty list. Another key is refused and recorded, and the read answers an empty list rather than every instance.

Parameters

array $params
array $include_additional

Returns

list<\Drupflare\Anachron\Drupal\Field\LegacyFieldInstance> —

field_info_instances()

field_info_instances(?string  $entity_type = null, ?string  $bundle_name = null) : array

Lists field instances the way Drupal 7 grouped them, each one an array-like `LegacyFieldInstance`.

Drupal 11 calls hook_entity_load for config entities too, and a Drupal 7 implementation often reads the instances from there, which loads the instances again without end. A call made from inside this function's own load answers an empty list.

Parameters

?string $entity_type
?string $bundle_name

Returns

array —

Keyed by entity type, bundle and field name, with the levels you named left out.