Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / lib / Drupal / Core / Field / FieldTypePluginManagerInterface.php
1 <?php
2
3 namespace Drupal\Core\Field;
4
5 use Drupal\Component\Plugin\CategorizingPluginManagerInterface;
6 use Drupal\Component\Plugin\PluginManagerInterface;
7 use Drupal\Core\Entity\FieldableEntityInterface;
8
9 /**
10  * Defines an interface for the field type plugin manager.
11  *
12  * @ingroup field_types
13  */
14 interface FieldTypePluginManagerInterface extends PluginManagerInterface, CategorizingPluginManagerInterface {
15
16   /**
17    * Creates a new field item list.
18    *
19    * The provided entity is assigned as the parent of the created item list.
20    * However, it is the responsibility of the caller (usually the parent entity
21    * itself) to make the parent aware of the field as a new child.
22    *
23    * @param \Drupal\Core\Entity\FieldableEntityInterface $entity
24    *   The entity this field item list will be part of.
25    * @param string $field_name
26    *   The name of the field.
27    * @param mixed $values
28    *   (optional) The data value. If set, it has to match one of the supported
29    *   data type format as documented for the data type classes.
30    *
31    * @return \Drupal\Core\Field\FieldItemListInterface
32    *   The instantiated object.
33    */
34   public function createFieldItemList(FieldableEntityInterface $entity, $field_name, $values = NULL);
35
36   /**
37    * Creates a new field item as part of a field item list.
38    *
39    * The provided item list is assigned as the parent of the created item. It
40    * However, it is the responsibility of the caller (usually the parent list
41    * itself) to have the parent aware of the item as a new child.
42    *
43    * @param \Drupal\Core\Field\FieldItemListInterface $items
44    *   The field item list, for which to create a new item.
45    * @param int $index
46    *   The list index at which the item is created.
47    * @param array|null $values
48    *   (optional) The values to assign to the field item properties.
49    *
50    * @return \Drupal\Core\Field\FieldItemInterface
51    *   The instantiated object.
52    */
53   public function createFieldItem(FieldItemListInterface $items, $index, $values = NULL);
54
55   /**
56    * Returns the default field-level settings for a field type.
57    *
58    * @param string $type
59    *   A field type name.
60    *
61    * @return array
62    *   The field's default settings, as provided by the plugin definition, or
63    *   an empty array if type or settings are undefined.
64    */
65   public function getDefaultFieldSettings($type);
66
67   /**
68    * Returns the default storage-level settings for a field type.
69    *
70    * @param string $type
71    *   A field type name.
72    *
73    * @return array
74    *   The type's default settings, as provided by the plugin definition, or an
75    *   empty array if type or settings are undefined.
76    */
77   public function getDefaultStorageSettings($type);
78
79   /**
80    * Gets the definition of all field types that can be added via UI.
81    *
82    * @return array
83    *   An array of field type definitions.
84    */
85   public function getUiDefinitions();
86
87   /**
88    * Returns preconfigured field options for a field type.
89    *
90    * This is a wrapper around
91    * \Drupal\Core\Field\PreconfiguredFieldUiOptionsInterface::getPreconfiguredOptions()
92    * allowing modules to alter the result of this method by implementing
93    * hook_field_ui_preconfigured_options_alter().
94    *
95    * @param string $field_type
96    *   The field type plugin ID.
97    *
98    * @return array
99    *   A multi-dimensional array as returned from
100    *   \Drupal\Core\Field\PreconfiguredFieldUiOptionsInterface::getPreconfiguredOptions().
101    *
102    * @see \Drupal\Core\Field\PreconfiguredFieldUiOptionsInterface::getPreconfiguredOptions()
103    * @see hook_field_ui_preconfigured_options_alter()
104    */
105   public function getPreconfiguredOptions($field_type);
106
107   /**
108    * Returns the PHP class that implements the field type plugin.
109    *
110    * @param string $type
111    *   A field type name.
112    *
113    * @return string
114    *   Field type plugin class name.
115    */
116   public function getPluginClass($type);
117
118 }