class EntityFormBuilder in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Entity/EntityFormBuilder.php \Drupal\Core\Entity\EntityFormBuilder
Builds entity forms.
Hierarchy
- class \Drupal\Core\Entity\EntityFormBuilder implements EntityFormBuilderInterface
Expanded class hierarchy of EntityFormBuilder
1 file declares its use of EntityFormBuilder
- EntityFormBuilderTest.php in core/
tests/ Drupal/ Tests/ Core/ Entity/ EntityFormBuilderTest.php - Contains \Drupal\Tests\Core\Entity\EntityFormBuilderTest.
1 string reference to 'EntityFormBuilder'
- core.services.yml in core/
core.services.yml - core/core.services.yml
1 service uses EntityFormBuilder
File
- core/
lib/ Drupal/ Core/ Entity/ EntityFormBuilder.php, line 16 - Contains \Drupal\Core\Entity\EntityFormBuilder.
Namespace
Drupal\Core\EntityView source
class EntityFormBuilder implements EntityFormBuilderInterface {
/**
* The entity manager.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
*/
protected $entityManager;
/**
* The form builder.
*
* @var \Drupal\Core\Form\FormBuilderInterface
*/
protected $formBuilder;
/**
* Constructs a new EntityFormBuilder.
*
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
* @param \Drupal\Core\Form\FormBuilderInterface $form_builder
* The form builder.
*/
public function __construct(EntityManagerInterface $entity_manager, FormBuilderInterface $form_builder) {
$this->entityManager = $entity_manager;
$this->formBuilder = $form_builder;
}
/**
* {@inheritdoc}
*/
public function getForm(EntityInterface $entity, $operation = 'default', array $form_state_additions = array()) {
$form_object = $this->entityManager
->getFormObject($entity
->getEntityTypeId(), $operation);
$form_object
->setEntity($entity);
$form_state = (new FormState())
->setFormState($form_state_additions);
return $this->formBuilder
->buildForm($form_object, $form_state);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityFormBuilder:: |
protected | property | The entity manager. | |
EntityFormBuilder:: |
protected | property | The form builder. | |
EntityFormBuilder:: |
public | function |
Gets the built and processed entity form for the given entity. Overrides EntityFormBuilderInterface:: |
|
EntityFormBuilder:: |
public | function | Constructs a new EntityFormBuilder. |