_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 578
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);
  }));
}
doc_Drupal
2016-10-29 09:57:11
Comments
Leave a Comment

Please login to continue.