function EntityTypeManager::getFormObject
Same name in other branches
- 9 core/lib/Drupal/Core/Entity/EntityTypeManager.php \Drupal\Core\Entity\EntityTypeManager::getFormObject()
- 8.9.x core/lib/Drupal/Core/Entity/EntityTypeManager.php \Drupal\Core\Entity\EntityTypeManager::getFormObject()
- 10 core/lib/Drupal/Core/Entity/EntityTypeManager.php \Drupal\Core\Entity\EntityTypeManager::getFormObject()
Overrides EntityTypeManagerInterface::getFormObject
File
-
core/
lib/ Drupal/ Core/ Entity/ EntityTypeManager.php, line 204
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))) {
$handlers = $this->getDefinition($entity_type_id, TRUE)
->getHandlerClasses();
if (!isset($handlers['form'][$operation])) {
throw new InvalidPluginDefinitionException($entity_type_id, sprintf('The "%s" entity type did not specify a "%s" form class.', $entity_type_id, $operation));
}
throw new InvalidPluginDefinitionException($entity_type_id, sprintf('The "%s" form handler of the "%s" entity type specifies a non-existent class "%s".', $operation, $entity_type_id, $handlers['form'][$operation]));
}
$form_object = $this->classResolver
->getInstanceFromDefinition($class);
return $form_object->setStringTranslation($this->stringTranslation)
->setModuleHandler($this->moduleHandler)
->setEntityTypeManager($this)
->setOperation($operation);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.