PlainTextEditor.php

Same filename in other branches
  1. 8.9.x core/modules/quickedit/src/Plugin/InPlaceEditor/PlainTextEditor.php

Namespace

Drupal\quickedit\Plugin\InPlaceEditor

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

Title Deprecated Summary
PlainTextEditor Defines the plain text in-place editor.

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