function _editor_get_formatted_text_fields

Same name in other branches
  1. 9 core/modules/editor/editor.module \_editor_get_formatted_text_fields()
  2. 10 core/modules/editor/editor.module \_editor_get_formatted_text_fields()
  3. 11.x core/modules/editor/editor.module \_editor_get_formatted_text_fields()

Determines the formatted text fields on an entity.

A field type is considered to provide formatted text if its class is a subclass of Drupal\text\Plugin\Field\FieldType\TextItemBase.

Parameters

\Drupal\Core\Entity\FieldableEntityInterface $entity: An entity whose fields to analyze.

Return value

array The names of the fields on this entity that support formatted text.

1 call to _editor_get_formatted_text_fields()
_editor_get_file_uuids_by_field in core/modules/editor/editor.module
Finds all files referenced (data-entity-uuid) by formatted text fields.

File

core/modules/editor/editor.module, line 600

Code

function _editor_get_formatted_text_fields(FieldableEntityInterface $entity) {
    $field_definitions = $entity->getFieldDefinitions();
    if (empty($field_definitions)) {
        return [];
    }
    // Only return formatted text fields.
    // @todo: improve as part of https://www.drupal.org/node/2732429
    $field_type_manager = \Drupal::service('plugin.manager.field.field_type');
    return array_keys(array_filter($field_definitions, function (FieldDefinitionInterface $definition) use ($field_type_manager) {
        $type = $definition->getType();
        $plugin_class = $field_type_manager->getPluginClass($type);
        return is_subclass_of($plugin_class, TextItemBase::class);
    }));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.