Version 1
[yaffs-website] / web / core / modules / quickedit / src / Plugin / InPlaceEditorInterface.php
1 <?php
2
3 namespace Drupal\quickedit\Plugin;
4
5 use Drupal\Component\Plugin\PluginInspectionInterface;
6 use Drupal\Core\Field\FieldItemListInterface;
7
8 /**
9  * Defines an interface for in-place editors plugins.
10  *
11  * @see \Drupal\quickedit\Annotation\InPlaceEditor
12  * @see \Drupal\quickedit\Plugin\InPlaceEditorBase
13  * @see \Drupal\quickedit\Plugin\InPlaceEditorManager
14  * @see plugin_api
15  */
16 interface InPlaceEditorInterface extends PluginInspectionInterface {
17
18   /**
19    * Checks whether this in-place editor is compatible with a given field.
20    *
21    * @param \Drupal\Core\Field\FieldItemListInterface $items
22    *   The field values to be in-place edited.
23    *
24    * @return bool
25    *   TRUE if it is compatible, FALSE otherwise.
26    */
27   public function isCompatible(FieldItemListInterface $items);
28
29   /**
30    * Generates metadata that is needed specifically for this editor.
31    *
32    * Will only be called by \Drupal\quickedit\MetadataGeneratorInterface::generate()
33    * when the passed in field & item values will use this editor.
34    *
35    * @param \Drupal\Core\Field\FieldItemListInterface $items
36    *   The field values to be in-place edited.
37    *
38    * @return array
39    *   A keyed array with metadata. Each key should be prefixed with the plugin
40    *   ID of the editor.
41    */
42   public function getMetadata(FieldItemListInterface $items);
43
44   /**
45    * Returns the attachments for this editor.
46    *
47    * @return array
48    *   An array of attachments, for use with #attached.
49    *
50    * @see \Drupal\Core\Render\AttachmentsResponseProcessorInterface::processAttachments()
51    */
52   public function getAttachments();
53
54 }