W3cubDocs

/Drupal 8

function _editor_get_formatted_text_fields

_editor_get_formatted_text_fields(FieldableEntityInterface $entity)

Determines the formatted text fields on an entity.

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.

File

core/modules/editor/editor.module, line 492
Adds bindings for client-side "text editors" to text formats.

Code

function _editor_get_formatted_text_fields(FieldableEntityInterface $entity) {
  $field_definitions = $entity->getFieldDefinitions();
  if (empty($field_definitions)) {
    return array();
  }

  // Only return formatted text fields.
  return array_keys(array_filter($field_definitions, function(FieldDefinitionInterface $definition) {
    return in_array($definition->getType(), array('text', 'text_long', 'text_with_summary'), TRUE);
  }));
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!editor!editor.module/function/_editor_get_formatted_text_fields/8.1.x