Pull merge.
[yaffs-website] / web / core / lib / Drupal / Core / Entity / EntityFormBuilderInterface.php
1 <?php
2
3 namespace Drupal\Core\Entity;
4
5 /**
6  * Builds entity forms.
7  *
8  * This is like \Drupal\Core\Form\FormBuilderInterface but instead of looking
9  * up the form class by class name, it looks up the form class based on the
10  * entity type and operation.
11  */
12 interface EntityFormBuilderInterface {
13
14   /**
15    * Gets the built and processed entity form for the given entity.
16    *
17    * The form may also be retrieved from the cache if the form was built in a
18    * previous page load. The form is then passed on for processing, validation,
19    * and submission if there is proper input.
20    *
21    * @param \Drupal\Core\Entity\EntityInterface $entity
22    *   The entity to be created or edited.
23    * @param string $operation
24    *   (optional) The operation identifying the form variation to be returned.
25    *   Defaults to 'default'. This is typically used in routing:
26    *   @code
27    *   _entity_form: node.book_outline
28    *   @endcode
29    *   where "book_outline" is the value of $operation. The class name for the
30    *   form for each operation (edit, delete, etc.) can be found in the form
31    *   section of the handlers entity annotation. For example:
32    *   @code
33    *   handlers = {
34    *     "form" = {
35    *       "delete" = "Drupal\node\Form\NodeDeleteForm",
36    *   @endcode
37    *   Alternatively, the form class can be set from hook_entity_type_build().
38    * @param array $form_state_additions
39    *   (optional) An associative array used to build the current state of the
40    *   form. Use this to pass additional information to the form, such as the
41    *   langcode. Defaults to an empty array.
42    *
43    * @code
44    *   $form_state_additions['langcode'] = $langcode;
45    *   $form = \Drupal::service('entity.form_builder')->getForm($entity, 'default', $form_state_additions);
46    * @endcode
47    *
48    * @return array
49    *   The processed form for the given entity and operation.
50    *
51    * @see \Drupal\Core\Form\FormBuilderInterface::getForm()
52    * @see \Drupal\Core\Entity\EntityTypeInterface::getFormClass()
53    * @see \Drupal\Core\Entity\EntityTypeInterface::setFormClass()
54    * @see system_entity_type_build()
55    */
56   public function getForm(EntityInterface $entity, $operation = 'default', array $form_state_additions = []);
57
58 }