summaryrefslogtreecommitdiffstatshomepage
path: root/core/lib/Drupal/Core/Render/ElementInfoManagerInterface.php
blob: ea6f21b849cd75ae99553049c59fff761e5282f3 (plain) (blame)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php

namespace Drupal\Core\Render;

use Drupal\Component\Plugin\Discovery\DiscoveryInterface;

/**
 * Collects available render array element types.
 */
interface ElementInfoManagerInterface extends DiscoveryInterface {

  /**
   * Retrieves the default properties for the defined element type.
   *
   * Each of the element types defined by this hook is assumed to have a
   * matching theme hook, which should be registered with hook_theme() as
   * normal.
   *
   * For more information about custom element types see the explanation at
   * https://www.drupal.org/node/169815.
   *
   * @param string $type
   *   The machine name of an element type plugin.
   *
   * @return array
   *   An associative array describing the element type being defined. The
   *   array has a number of possible attributes:
   *   - #input: boolean indicating whether this element carries a value
   *     (even if it's hidden).
   *   - #process: array of callback functions taking $element, $form_state,
   *     and $complete_form.
   *   - #after_build: array of callables taking $element and $form_state.
   *   - #validate: array of callback functions taking $form and $form_state.
   *   - #element_validate: array of callback functions taking $element and
   *     $form_state.
   *   - #pre_render: array of callables taking $element.
   *   - #post_render: array of callables taking $children and $element.
   *   - #submit: array of callback functions taking $form and $form_state.
   *   - #title_display: optional string indicating if and how #title should be
   *     displayed (see form-element.html.twig).
   *
   * @see \Drupal\Core\Render\Element\ElementInterface
   * @see \Drupal\Core\Render\Element\ElementInterface::getInfo()
   */
  public function getInfo($type);

  /**
   * Retrieves a single property for the defined element type.
   *
   * @param string $type
   *   An element type as defined by an element plugin.
   * @param string $property_name
   *   The property within the element type that should be returned.
   * @param mixed|null $default
   *   (Optional) The value to return if the element type does not specify a
   *   value for the property. Defaults to NULL.
   *
   * @return mixed
   *   The property value of the defined element type. Or the provided
   *   default value, which can be NULL.
   */
  public function getInfoProperty($type, $property_name, $default = NULL);

}