diff --git a/core/lib/Drupal/Core/Entity/EntityTypeManager.php b/core/lib/Drupal/Core/Entity/EntityTypeManager.php index 3a24e0e86f72d7d73b879162196640ba180bf210..25f9cff0db7c50b8b2bcd49dc5092d5bcc59197f 100644 --- a/core/lib/Drupal/Core/Entity/EntityTypeManager.php +++ b/core/lib/Drupal/Core/Entity/EntityTypeManager.php @@ -177,25 +177,20 @@ public function getListBuilder($entity_type) { * {@inheritdoc} */ public function getFormObject($entity_type, $operation) { - if (!isset($this->handlers['form'][$operation][$entity_type])) { - if (!$class = $this->getDefinition($entity_type, TRUE)->getFormClass($operation)) { - throw new InvalidPluginDefinitionException($entity_type, sprintf('The "%s" entity type did not specify a "%s" form class.', $entity_type, $operation)); - } - - $form_object = $this->classResolver->getInstanceFromDefinition($class); - - $form_object - ->setStringTranslation($this->stringTranslation) - ->setModuleHandler($this->moduleHandler) - ->setEntityTypeManager($this) - ->setOperation($operation) - // The entity manager cannot be injected due to a circular dependency. - // @todo Remove this set call in https://www.drupal.org/node/2603542. - ->setEntityManager(\Drupal::entityManager()); - $this->handlers['form'][$operation][$entity_type] = $form_object; + if (!$class = $this->getDefinition($entity_type, TRUE)->getFormClass($operation)) { + throw new InvalidPluginDefinitionException($entity_type, sprintf('The "%s" entity type did not specify a "%s" form class.', $entity_type, $operation)); } - return $this->handlers['form'][$operation][$entity_type]; + $form_object = $this->classResolver->getInstanceFromDefinition($class); + + return $form_object + ->setStringTranslation($this->stringTranslation) + ->setModuleHandler($this->moduleHandler) + ->setEntityTypeManager($this) + ->setOperation($operation) + // The entity manager cannot be injected due to a circular dependency. + // @todo Remove this set call in https://www.drupal.org/node/2603542. + ->setEntityManager(\Drupal::entityManager()); } /**