EditorInterface.php 1.67 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
<?php

/**
 * @file
 * Contains \Drupal\edit\EditorInterface.
 */

namespace Drupal\edit;

use Drupal\Component\Plugin\PluginInspectionInterface;
11
use Drupal\field\Plugin\Core\Entity\FieldInstance;
12
13
14
15
16
17
18
19
20
21
22
23

/**
 * Defines an interface for in-place editors (Create.js PropertyEditor widgets).
 *
 * A PropertyEditor widget is a user-facing interface to edit an entity property
 * through Create.js.
 */
interface EditorInterface extends PluginInspectionInterface {

  /**
   * Checks whether this editor is compatible with a given field instance.
   *
24
   * @param \Drupal\field\Plugin\Core\Entity\FieldInstance $instance
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
   *   The field instance of the field being edited.
   * @param array $items
   *   The field's item values.
   *
   * @return bool
   *   TRUE if it is compatible, FALSE otherwise.
   */
  public function isCompatible(FieldInstance $instance, array $items);

  /**
   * Generates metadata that is needed specifically for this editor.
   *
   * Will only be called by \Drupal\edit\MetadataGeneratorInterface::generate()
   * when the passed in field instance & item values will use this editor.
   *
40
   * @param \Drupal\field\Plugin\Core\Entity\FieldInstance $instance
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
   *   The field instance of the field being edited.
   * @param array $items
   *   The field's item values.
   *
   * @return array
   *   A keyed array with metadata. Each key should be prefixed with the plugin
   *   ID of the editor.
   */
  public function getMetadata(FieldInstance $instance, array $items);

  /**
   * Returns the attachments for this editor.
   *
   * @return array
   *   An array of attachments, for use with #attached.
   *
   * @see drupal_process_attached()
   */
  public function getAttachments();
}