function Editor::isCompatible

Same name in this branch
  1. 9 core/modules/quickedit/src/Plugin/InPlaceEditor/Editor.php \Drupal\quickedit\Plugin\InPlaceEditor\Editor::isCompatible()
Same name in other branches
  1. 8.9.x core/modules/editor/src/Plugin/InPlaceEditor/Editor.php \Drupal\editor\Plugin\InPlaceEditor\Editor::isCompatible()

Overrides InPlaceEditorInterface::isCompatible

File

core/modules/editor/src/Plugin/InPlaceEditor/Editor.php, line 36

Class

Editor
Defines the formatted text in-place editor.

Namespace

Drupal\editor\Plugin\InPlaceEditor

Code

public function isCompatible(FieldItemListInterface $items) {
    $field_definition = $items->getFieldDefinition();
    // This editor is incompatible with multivalued fields.
    if ($field_definition->getFieldStorageDefinition()
        ->getCardinality() != 1) {
        return FALSE;
    }
    elseif ($editor = editor_load($items[0]->format)) {
        $definition = \Drupal::service('plugin.manager.editor')->getDefinition($editor->getEditor());
        if ($definition['supports_inline_editing'] === TRUE) {
            return TRUE;
        }
    }
    return FALSE;
}

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