5217c20f4a13697f8e56237732f6388afb5abf74
[yaffs-website] / web / core / modules / quickedit / src / Plugin / InPlaceEditor / PlainTextEditor.php
1 <?php
2
3 namespace Drupal\quickedit\Plugin\InPlaceEditor;
4
5 use Drupal\Core\Field\FieldItemListInterface;
6 use Drupal\quickedit\Plugin\InPlaceEditorBase;
7
8 /**
9  * Defines the plain text in-place editor.
10  *
11  * @InPlaceEditor(
12  *   id = "plain_text"
13  * )
14  */
15 class PlainTextEditor extends InPlaceEditorBase {
16
17   /**
18    * {@inheritdoc}
19    */
20   public function isCompatible(FieldItemListInterface $items) {
21     $field_definition = $items->getFieldDefinition();
22
23     // This editor is incompatible with multivalued fields.
24     return $field_definition->getFieldStorageDefinition()->getCardinality() == 1;
25   }
26
27   /**
28    * {@inheritdoc}
29    */
30   public function getAttachments() {
31     return [
32       'library' => [
33         'quickedit/quickedit.inPlaceEditor.plainText',
34       ],
35     ];
36   }
37
38 }