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