ListDataDefinitionInterface.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace Drupal\Core\TypedData;
  3. /**
  4. * Interface for data definitions of lists.
  5. *
  6. * This interface is present on a data definition if it describes a list. The
  7. * actual lists implement the \Drupal\Core\TypedData\ListInterface.
  8. *
  9. * @see \Drupal\Core\TypedData\ListDefinition
  10. * @see \Drupal\Core\TypedData\ListInterface
  11. *
  12. * @ingroup typed_data
  13. */
  14. interface ListDataDefinitionInterface extends DataDefinitionInterface {
  15. /**
  16. * Creates a new list data definition for items of the given data type.
  17. *
  18. * This method is typically used by
  19. * \Drupal\Core\TypedData\TypedDataManager::createListDataDefinition() to
  20. * build a definition object for an arbitrary item type. When the definition
  21. * class is known, it is recommended to directly use the static create()
  22. * method on that class instead; e.g.:
  23. * @code
  24. * $list_definition = \Drupal\Core\TypedData\ListDataDefinition::create('string');
  25. * @endcode
  26. *
  27. * @param string $item_type
  28. * The item type, for which a list data definition should be created.
  29. *
  30. * @return static
  31. *
  32. * @throws \InvalidArgumentException
  33. * If an unsupported data type gets passed to the class; e.g., 'string' to a
  34. * definition class handling lists of 'field_item:* data types.
  35. */
  36. public static function createFromItemType($item_type);
  37. /**
  38. * Gets the data definition of an item of the list.
  39. *
  40. * @return \Drupal\Core\TypedData\DataDefinitionInterface
  41. * A data definition describing the list items.
  42. */
  43. public function getItemDefinition();
  44. }