You are here

PlainTextEditor.php in Drupal 9

Same filename and directory in other branches
  1. 8 core/modules/quickedit/src/Plugin/InPlaceEditor/PlainTextEditor.php

File

core/modules/quickedit/src/Plugin/InPlaceEditor/PlainTextEditor.php
View source
<?php

namespace Drupal\quickedit\Plugin\InPlaceEditor;

use Drupal\Core\Field\FieldItemListInterface;
use Drupal\quickedit\Plugin\InPlaceEditorBase;

/**
 * Defines the plain text in-place editor.
 *
 * @InPlaceEditor(
 *   id = "plain_text"
 * )
 */
class PlainTextEditor extends InPlaceEditorBase {

  /**
   * {@inheritdoc}
   */
  public function isCompatible(FieldItemListInterface $items) {
    $field_definition = $items
      ->getFieldDefinition();

    // This editor is incompatible with multivalued fields.
    return $field_definition
      ->getFieldStorageDefinition()
      ->getCardinality() == 1;
  }

  /**
   * {@inheritdoc}
   */
  public function getAttachments() {
    return [
      'library' => [
        'quickedit/quickedit.inPlaceEditor.plainText',
      ],
    ];
  }

}

Classes

Namesort descending Description
PlainTextEditor Defines the plain text in-place editor.