Version 1
[yaffs-website] / web / modules / contrib / diff / src / FieldDiffBuilderInterface.php
1 <?php
2
3 namespace Drupal\diff;
4
5 use Drupal\Core\Field\FieldItemListInterface;
6 use Drupal\Core\Field\FieldStorageDefinitionInterface;
7 use Drupal\Core\Plugin\PluginFormInterface;
8 use Drupal\Component\Plugin\ConfigurablePluginInterface;
9
10 /**
11  * Builds a diff from field item list.
12  */
13 interface FieldDiffBuilderInterface extends PluginFormInterface, ConfigurablePluginInterface {
14
15   /**
16    * Builds an array of strings.
17    *
18    * This method is responsible for transforming a FieldItemListInterface object
19    * into an array of strings. The resulted array of strings is then compared by
20    * the Diff component with another such array of strings and the result
21    * represents the difference between two entity fields.
22    *
23    * Example of FieldItemListInterface built into an array of strings:
24    * @code
25    * array(
26    *   0 => "This is an example string",
27    *   1 => "Field values or properties",
28    * )
29    * @endcode
30    *
31    * @see \Drupal\diff\Plugin\diff\Field\TextFieldBuilder
32    *
33    * @param FieldItemListInterface $field_items
34    *   Represents an entity field.
35    *
36    * @return mixed
37    *   An array of strings to be compared. If an empty array is returned it
38    *   means that a field is either empty or no properties need to be compared
39    *   for that field.
40    */
41   public function build(FieldItemListInterface $field_items);
42
43   /**
44    * Returns if the plugin can be used for the provided field.
45    *
46    * @param \Drupal\Core\Field\FieldStorageDefinitionInterface $field_definition
47    *   The field definition that should be checked.
48    *
49    * @return bool
50    *   TRUE if the plugin can be used, FALSE otherwise.
51    */
52   public static function isApplicable(FieldStorageDefinitionInterface $field_definition);
53
54 }