summaryrefslogtreecommitdiffstats
path: root/core/lib/Drupal/Core/TypedData/ListDataDefinitionInterface.php
blob: 858d20543c2edfab1367a282e8597febb310a9c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php

namespace Drupal\Core\TypedData;

/**
 * Interface for data definitions of lists.
 *
 * This interface is present on a data definition if it describes a list. The
 * actual lists implement the \Drupal\Core\TypedData\ListInterface.
 *
 * @see \Drupal\Core\TypedData\ListDefinition
 * @see \Drupal\Core\TypedData\ListInterface
 *
 * @ingroup typed_data
 */
interface ListDataDefinitionInterface extends DataDefinitionInterface {

  /**
   * Creates a new list data definition for items of the given data type.
   *
   * This method is typically used by
   * \Drupal\Core\TypedData\TypedDataManager::createListDataDefinition() to
   * build a definition object for an arbitrary item type. When the definition
   * class is known, it is recommended to directly use the static create()
   * method on that class instead; e.g.:
   * @code
   *   $list_definition = \Drupal\Core\TypedData\ListDataDefinition::create('string');
   * @endcode
   *
   * @param string $item_type
   *   The item type, for which a list data definition should be created.
   *
   * @return static
   *
   * @throws \InvalidArgumentException
   *   If an unsupported data type gets passed to the class; e.g., 'string' to a
   *   definition class handling lists of 'field_item:* data types.
   */
  public static function createFromItemType($item_type);

  /**
   * Gets the data definition of an item of the list.
   *
   * @return \Drupal\Core\TypedData\DataDefinitionInterface
   *   A data definition describing the list items.
   */
  public function getItemDefinition();

}