ElementInterface.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Drupal\Core\Render\Element;
  3. use Drupal\Component\Plugin\PluginInspectionInterface;
  4. /**
  5. * Provides an interface for render element plugins.
  6. *
  7. * Render element plugins allow modules to declare their own Render API element
  8. * types and specify the default values for the properties. The values returned
  9. * by the getInfo() method of the element plugin will be merged with the
  10. * properties specified in render arrays. Thus, you can specify defaults for any
  11. * Render API keys, in addition to those explicitly documented by
  12. * \Drupal\Core\Render\ElementInfoManagerInterface::getInfo().
  13. *
  14. * Some render elements are specifically form input elements; see
  15. * \Drupal\Core\Render\Element\FormElementInterface for more information.
  16. *
  17. * @see \Drupal\Core\Render\ElementInfoManager
  18. * @see \Drupal\Core\Render\Annotation\RenderElement
  19. * @see \Drupal\Core\Render\Element\RenderElement
  20. * @see plugin_api
  21. *
  22. * @ingroup theme_render
  23. */
  24. interface ElementInterface extends PluginInspectionInterface {
  25. /**
  26. * Returns the element properties for this element.
  27. *
  28. * @return array
  29. * An array of element properties. See
  30. * \Drupal\Core\Render\ElementInfoManagerInterface::getInfo() for
  31. * documentation of the standard properties of all elements, and the
  32. * return value format.
  33. */
  34. public function getInfo();
  35. /**
  36. * Sets a form element's class attribute.
  37. *
  38. * Adds 'required' and 'error' classes as needed.
  39. *
  40. * @param array $element
  41. * The form element.
  42. * @param array $class
  43. * Array of new class names to be added.
  44. */
  45. public static function setAttributes(&$element, $class = []);
  46. }