public function EntityTypeManager::getFormObject in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Entity/EntityTypeManager.php \Drupal\Core\Entity\EntityTypeManager::getFormObject()
Creates a new form instance.
Parameters
string $entity_type_id: The entity type ID for this form.
string $operation: The name of the operation to use, e.g., 'default'.
Return value
\Drupal\Core\Entity\EntityFormInterface A form instance.
Overrides EntityTypeManagerInterface::getFormObject
File
- core/
lib/ Drupal/ Core/ Entity/ EntityTypeManager.php, line 221
Class
- EntityTypeManager
- Manages entity type plugin definitions.
Namespace
Drupal\Core\EntityCode
public function getFormObject($entity_type_id, $operation) {
if (!($class = $this
->getDefinition($entity_type_id, TRUE)
->getFormClass($operation))) {
throw new InvalidPluginDefinitionException($entity_type_id, sprintf('The "%s" entity type did not specify a "%s" form class.', $entity_type_id, $operation));
}
$form_object = $this->classResolver
->getInstanceFromDefinition($class);
return $form_object
->setStringTranslation($this->stringTranslation)
->setModuleHandler($this->moduleHandler)
->setEntityTypeManager($this)
->setOperation($operation);
}