3 namespace Drupal\Core\Field;
5 use Drupal\Component\Plugin\CategorizingPluginManagerInterface;
6 use Drupal\Component\Plugin\PluginManagerInterface;
7 use Drupal\Core\Entity\FieldableEntityInterface;
10 * Defines an interface for the field type plugin manager.
12 * @ingroup field_types
14 interface FieldTypePluginManagerInterface extends PluginManagerInterface, CategorizingPluginManagerInterface {
17 * Creates a new field item list.
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.
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.
31 * @return \Drupal\Core\Field\FieldItemListInterface
32 * The instantiated object.
34 public function createFieldItemList(FieldableEntityInterface $entity, $field_name, $values = NULL);
37 * Creates a new field item as part of a field item list.
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.
43 * @param \Drupal\Core\Field\FieldItemListInterface $items
44 * The field item list, for which to create a new item.
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.
50 * @return \Drupal\Core\Field\FieldItemInterface
51 * The instantiated object.
53 public function createFieldItem(FieldItemListInterface $items, $index, $values = NULL);
56 * Returns the default field-level settings for a field type.
62 * The field's default settings, as provided by the plugin definition, or
63 * an empty array if type or settings are undefined.
65 public function getDefaultFieldSettings($type);
68 * Returns the default storage-level settings for a field type.
74 * The type's default settings, as provided by the plugin definition, or an
75 * empty array if type or settings are undefined.
77 public function getDefaultStorageSettings($type);
80 * Gets the definition of all field types that can be added via UI.
83 * An array of field type definitions.
85 public function getUiDefinitions();
88 * Returns preconfigured field options for a field type.
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().
95 * @param string $field_type
96 * The field type plugin ID.
99 * A multi-dimensional array as returned from
100 * \Drupal\Core\Field\PreconfiguredFieldUiOptionsInterface::getPreconfiguredOptions().
102 * @see \Drupal\Core\Field\PreconfiguredFieldUiOptionsInterface::getPreconfiguredOptions()
103 * @see hook_field_ui_preconfigured_options_alter()
105 public function getPreconfiguredOptions($field_type);
108 * Returns the PHP class that implements the field type plugin.
110 * @param string $type
114 * Field type plugin class name.
116 public function getPluginClass($type);