ContentEntityFormInterface.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace Drupal\Core\Entity;
  3. use Drupal\Core\Entity\Display\EntityFormDisplayInterface;
  4. use Drupal\Core\Form\FormStateInterface;
  5. /**
  6. * Defines a common interface for content entity form classes.
  7. */
  8. interface ContentEntityFormInterface extends EntityFormInterface {
  9. /**
  10. * Gets the form display.
  11. *
  12. * @param \Drupal\Core\Form\FormStateInterface $form_state
  13. * The current state of the form.
  14. *
  15. * @return \Drupal\Core\Entity\Display\EntityFormDisplayInterface
  16. * The current form display.
  17. */
  18. public function getFormDisplay(FormStateInterface $form_state);
  19. /**
  20. * Sets the form display.
  21. *
  22. * Sets the form display which will be used for populating form element
  23. * defaults.
  24. *
  25. * @param \Drupal\Core\Entity\Display\EntityFormDisplayInterface $form_display
  26. * The form display that the current form operates with.
  27. * @param \Drupal\Core\Form\FormStateInterface $form_state
  28. * The current state of the form.
  29. *
  30. * @return $this
  31. */
  32. public function setFormDisplay(EntityFormDisplayInterface $form_display, FormStateInterface $form_state);
  33. /**
  34. * Gets the code identifying the active form language.
  35. *
  36. * @param \Drupal\Core\Form\FormStateInterface $form_state
  37. * The current state of the form.
  38. *
  39. * @return string
  40. * The form language code.
  41. */
  42. public function getFormLangcode(FormStateInterface $form_state);
  43. /**
  44. * Checks whether the current form language matches the entity one.
  45. *
  46. * @param \Drupal\Core\Form\FormStateInterface $form_state
  47. * The current state of the form.
  48. *
  49. * @return bool
  50. * Returns TRUE if the entity form language matches the entity one.
  51. */
  52. public function isDefaultFormLangcode(FormStateInterface $form_state);
  53. /**
  54. * {@inheritdoc}
  55. *
  56. * Note that extending classes should not override this method to add entity
  57. * validation logic, but define further validation constraints using the
  58. * entity validation API and/or provide a new validation constraint if
  59. * necessary. This is the only way to ensure that the validation logic
  60. * is correctly applied independently of form submissions; e.g., for REST
  61. * requests.
  62. * For more information about entity validation, see
  63. * https://www.drupal.org/node/2015613.
  64. *
  65. * @return \Drupal\Core\Entity\ContentEntityTypeInterface
  66. * The built entity.
  67. */
  68. public function validateForm(array &$form, FormStateInterface $form_state);
  69. }