Version 1
[yaffs-website] / web / core / modules / quickedit / src / Plugin / InPlaceEditor / PlainTextEditor.php
diff --git a/web/core/modules/quickedit/src/Plugin/InPlaceEditor/PlainTextEditor.php b/web/core/modules/quickedit/src/Plugin/InPlaceEditor/PlainTextEditor.php
new file mode 100644 (file)
index 0000000..5217c20
--- /dev/null
@@ -0,0 +1,38 @@
+<?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',
+      ],
+    ];
+  }
+
+}