diff --git a/core/lib/Drupal/Core/Entity/EntityForm.php b/core/lib/Drupal/Core/Entity/EntityForm.php index 75d901469e84a012ab5d90817872a0aacff42892..41f1c30ff374020283c3f0886de629fda5858cdb 100644 --- a/core/lib/Drupal/Core/Entity/EntityForm.php +++ b/core/lib/Drupal/Core/Entity/EntityForm.php @@ -89,7 +89,7 @@ public function getFormId() { public function buildForm(array $form, FormStateInterface $form_state) { // During the initial form build, add this form object to the form state and // allow for initial preparation before form building and processing. - if (!isset($form_state['controller'])) { + if (!isset($form_state['entity_form_initialized'])) { $this->init($form_state); } @@ -115,9 +115,8 @@ public function submitForm(array &$form, FormStateInterface $form_state) { * Initialize the form state and the entity before the first form build. */ protected function init(FormStateInterface $form_state) { - // Add the form object to the form state so it can be easily accessed by - // module-provided form handlers there. - $form_state['controller'] = $this; + // Flag that this form has been initialized. + $form_state['entity_form_initialized'] = TRUE; // Prepare the entity to be presented in the entity form. $this->prepareEntity(); @@ -158,7 +157,7 @@ public function form(array $form, FormStateInterface $form_state) { public function processForm($element, FormStateInterface $form_state, $form) { // If the form is cached, process callbacks may not have a valid reference // to the entity object, hence we must restore it. - $this->entity = $form_state['controller']->getEntity(); + $this->entity = $form_state->getFormObject()->getEntity(); return $element; } diff --git a/core/lib/Drupal/Core/Form/FormState.php b/core/lib/Drupal/Core/Form/FormState.php index 50b75f7c222ce2c45a2f812c482eb7858bafc3f2..d4c29e2e9e93a3a5b19f35f2918379b99eee3a3b 100644 --- a/core/lib/Drupal/Core/Form/FormState.php +++ b/core/lib/Drupal/Core/Form/FormState.php @@ -326,7 +326,7 @@ class FormState implements FormStateInterface, \ArrayAccess { * conflict with ones used by the Form API or other modules is to use the * module name as the key name or a prefix for the key name. For example, the * entity form classes use $this->entity in entity forms, or - * $form_state['controller']->getEntity() outside the controller, to store + * $form_state->getFormObject()->getEntity() outside the controller, to store * information about the entity being edited, and this information stays * available across successive clicks of the "Preview" button (if available) * as well as when the "Save" button is finally clicked. @@ -807,6 +807,14 @@ public function prepareCallback($callback) { return $callback; } + /** + * {@inheritdoc} + */ + public function getFormObject() { + $build_info = $this->get('build_info'); + return $build_info['callback_object']; + } + /** * Wraps drupal_set_message(). * diff --git a/core/lib/Drupal/Core/Form/FormStateInterface.php b/core/lib/Drupal/Core/Form/FormStateInterface.php index 164078a20a1c4cc288c992424d1df067a749731f..a154f3b3f183ca69976dafa15a6e6453e47e2ce0 100644 --- a/core/lib/Drupal/Core/Form/FormStateInterface.php +++ b/core/lib/Drupal/Core/Form/FormStateInterface.php @@ -470,4 +470,12 @@ public function setRebuild($rebuild = TRUE); */ public function prepareCallback($callback); + /** + * Returns the form object that is responsible for building this form. + * + * @return \Drupal\Core\Form\FormInterface + * The form object. + */ + public function getFormObject(); + } diff --git a/core/modules/book/book.module b/core/modules/book/book.module index ab0a5fe33e1b9d301bf3af01b19143efd7a227cc..5e87f43a0b594b8d08825c831ce1232bcaa59592 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -161,7 +161,7 @@ function book_node_links_alter(array &$node_links, NodeInterface $node, array &$ * @see book_pick_book_nojs_submit() */ function book_form_node_form_alter(&$form, FormStateInterface $form_state, $form_id) { - $node = $form_state['controller']->getEntity(); + $node = $form_state->getFormObject()->getEntity(); $account = \Drupal::currentUser(); $access = $account->hasPermission('administer book outlines'); if (!$access) { @@ -217,7 +217,7 @@ function book_node_builder($entity_type, NodeInterface $entity, &$form, FormStat * @see book_form_node_form_alter() */ function book_pick_book_nojs_submit($form, FormStateInterface $form_state) { - $node = $form_state['controller']->getEntity(); + $node = $form_state->getFormObject()->getEntity(); $node->book = $form_state->getValue('book'); $form_state['rebuild'] = TRUE; } diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index 129d42a43bab765075a1ae93a3bb5bf3a2bdae6a..368ad0f9f0e3d525bfd4812027d2704da1edd9e1 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -170,7 +170,7 @@ function contact_form_user_form_alter(&$form, FormStateInterface $form_state) { '#open' => TRUE, '#weight' => 5, ); - $account = $form_state['controller']->getEntity(); + $account = $form_state->getFormObject()->getEntity(); if (!\Drupal::currentUser()->isAnonymous() && $account->id()) { $account_data = \Drupal::service('user.data')->get('contact', $account->id(), 'enabled'); } @@ -187,7 +187,7 @@ function contact_form_user_form_alter(&$form, FormStateInterface $form_state) { * Submit callback for the user profile form to save the contact page setting. */ function contact_user_profile_form_submit($form, FormStateInterface $form_state) { - $account = $form_state['controller']->getEntity(); + $account = $form_state->getFormObject()->getEntity(); if ($account->id() && $form_state->hasValue('contact')) { \Drupal::service('user.data')->set('contact', $account->id(), 'enabled', (int) $form_state->getValue('contact')); } diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index d218a8d7bf9918a2e5808750e6a525f2b79bea2a..5c86c4e4be70faf6170025b30101d2e8eb85f142 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -334,22 +334,6 @@ function content_translation_controller($entity_type_id) { return new $class($entity_type); } -/** - * Returns the entity form for the given form. - * - * @param \Drupal\Core\Form\FormStateInterface $form_state - * The current form state holding the entity form. - * - * @return \Drupal\Core\Entity\EntityFormInterface; - * An instance of the content translation form interface or FALSE if not an - * entity form. - * - * @todo Move to \Drupal\content_translation\ContentTranslationManager. - */ -function content_translation_form_controller(FormStateInterface $form_state) { - return isset($form_state['controller']) && $form_state['controller'] instanceof EntityFormInterface ? $form_state['controller'] : FALSE; -} - /** * Checks whether a content translation is accessible. * @@ -430,8 +414,11 @@ function content_translation_permission() { * Implements hook_form_alter(). */ function content_translation_form_alter(array &$form, FormStateInterface $form_state) { - $form_controller = content_translation_form_controller($form_state); - $entity = $form_controller ? $form_controller->getEntity() : NULL; + $form_object = $form_state->getFormObject(); + if (!($form_object instanceof EntityFormInterface)) { + return; + } + $entity = $form_object->getEntity(); if ($entity instanceof ContentEntityInterface && $entity->isTranslatable() && count($entity->getTranslationLanguages()) > 1) { $controller = content_translation_controller($entity->getEntityTypeId()); @@ -440,7 +427,7 @@ function content_translation_form_alter(array &$form, FormStateInterface $form_s // @todo Move the following lines to the code generating the property form // elements once we have an official #multilingual FAPI key. $translations = $entity->getTranslationLanguages(); - $form_langcode = $form_controller->getFormLangcode($form_state); + $form_langcode = $form_object->getFormLangcode($form_state); // Handle fields shared between translations when there is at least one // translation available or a new one is being created. diff --git a/core/modules/content_translation/src/ContentTranslationHandler.php b/core/modules/content_translation/src/ContentTranslationHandler.php index c1f638f84aac05ca30877d34bea6dfdf923c6df5..60eb6f3590ee2d5bd863295063c4c9e6edeec3a1 100644 --- a/core/modules/content_translation/src/ContentTranslationHandler.php +++ b/core/modules/content_translation/src/ContentTranslationHandler.php @@ -84,8 +84,8 @@ public function getSourceLangcode(FormStateInterface $form_state) { * {@inheritdoc} */ public function entityFormAlter(array &$form, FormStateInterface $form_state, EntityInterface $entity) { - $form_controller = content_translation_form_controller($form_state); - $form_langcode = $form_controller->getFormLangcode($form_state); + $form_object = $form_state->getFormObject(); + $form_langcode = $form_object->getFormLangcode($form_state); $entity_langcode = $entity->getUntranslated()->language()->id; $source_langcode = $this->getSourceLangcode($form_state); @@ -95,7 +95,7 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, En // Make sure a new translation does not appear as existing yet. unset($translations[$form_langcode]); } - $is_translation = !$form_controller->isDefaultFormLangcode($form_state); + $is_translation = !$form_object->isDefaultFormLangcode($form_state); $has_translations = count($translations) > 1; // Adjust page title to specify the current language being edited, if we @@ -377,8 +377,8 @@ protected function addTranslatabilityClue(&$element) { * @see \Drupal\content_translation\ContentTranslationHandler::entityFormAlter() */ public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, FormStateInterface $form_state) { - $form_controller = content_translation_form_controller($form_state); - $form_langcode = $form_controller->getFormLangcode($form_state); + $form_object = $form_state->getFormObject(); + $form_langcode = $form_object->getFormLangcode($form_state); if (!isset($entity->translation[$form_langcode])) { $entity->translation[$form_langcode] = array(); @@ -435,15 +435,15 @@ function entityFormValidate($form, FormStateInterface $form_state) { * Takes care of the source language change. */ public function entityFormSourceChange($form, FormStateInterface $form_state) { - $form_controller = content_translation_form_controller($form_state); - $entity = $form_controller->getEntity(); + $form_object = $form_state->getFormObject(); + $entity = $form_object->getEntity(); $source = $form_state->getValue(array('source_langcode', 'source')); $entity_type_id = $entity->getEntityTypeId(); $form_state->setRedirect('content_translation.translation_add_' . $entity_type_id, array( $entity_type_id => $entity->id(), 'source' => $source, - 'target' => $form_controller->getFormLangcode($form_state), + 'target' => $form_object->getFormLangcode($form_state), )); $languages = language_list(); drupal_set_message(t('Source language set to: %language', array('%language' => $languages[$source]->name))); @@ -455,8 +455,8 @@ public function entityFormSourceChange($form, FormStateInterface $form_state) { * Takes care of entity deletion. */ function entityFormDelete($form, FormStateInterface $form_state) { - $form_controller = content_translation_form_controller($form_state); - $entity = $form_controller->getEntity(); + $form_object = $form_state->getFormObject()->getEntity(); + $entity = $form_object->getEntity(); if (count($entity->getTranslationLanguages()) > 1) { drupal_set_message(t('This will delete all the translations of %label.', array('%label' => $entity->label())), 'warning'); } @@ -468,12 +468,12 @@ function entityFormDelete($form, FormStateInterface $form_state) { * Takes care of content translation deletion. */ function entityFormDeleteTranslation($form, FormStateInterface $form_state) { - $form_controller = content_translation_form_controller($form_state); - $entity = $form_controller->getEntity(); + $form_object = $form_state->getFormObject(); + $entity = $form_object->getEntity(); $entity_type_id = $entity->getEntityTypeId(); $form_state->setRedirect('content_translation.translation_delete_' . $entity_type_id, array( $entity_type_id => $entity->id(), - 'language' => $form_controller->getFormLangcode($form_state), + 'language' => $form_object->getFormLangcode($form_state), )); } diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module index 7a729cc93f2fa2396045408581a148761736cefb..ae20c491b0b51d91f51e34c44510a122e50b6dc1 100644 --- a/core/modules/editor/editor.module +++ b/core/modules/editor/editor.module @@ -91,7 +91,7 @@ function editor_form_filter_admin_overview_alter(&$form, FormStateInterface $for */ function editor_form_filter_format_form_alter(&$form, FormStateInterface $form_state) { if (!isset($form_state['editor'])) { - $format_id = $form_state['controller']->getEntity()->id(); + $format_id = $form_state->getFormObject()->getEntity()->id(); $form_state['editor'] = editor_load($format_id); } $editor = $form_state['editor']; @@ -174,7 +174,7 @@ function editor_form_filter_admin_format_editor_configure($form, FormStateInterf } elseif (empty($editor) || $editor_value !== $editor->getEditor()) { $editor = entity_create('editor', array( - 'format' => $form_state['controller']->getEntity()->id(), + 'format' => $form_state->getFormObject()->getEntity()->id(), 'editor' => $editor_value, )); $form_state['editor'] = $editor; @@ -213,7 +213,7 @@ function editor_form_filter_admin_format_validate($form, FormStateInterface $for */ function editor_form_filter_admin_format_submit($form, FormStateInterface $form_state) { // Delete the existing editor if disabling or switching between editors. - $format_id = $form_state['controller']->getEntity()->id(); + $format_id = $form_state->getFormObject()->getEntity()->id(); $original_editor = editor_load($format_id); if ($original_editor && $original_editor->getEditor() != $form_state->getValue('editor')) { $original_editor->delete(); diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module index 033832cac5219693dd0f964aafc422b716a2f0f8..696d07a45fe13e9944c12972be53cee39d546b83 100644 --- a/core/modules/field_ui/field_ui.module +++ b/core/modules/field_ui/field_ui.module @@ -151,7 +151,7 @@ function field_ui_entity_bundle_rename($entity_type, $bundle_old, $bundle_new) { */ function field_ui_form_node_type_form_alter(&$form, FormStateInterface $form_state) { // We want to display the button only on add page. - if ($form_state['controller']->getEntity()->isNew()) { + if ($form_state->getFormObject()->getEntity()->isNew()) { $form['actions']['save_continue'] = $form['actions']['submit']; $form['actions']['save_continue']['#value'] = t('Save and manage fields'); $form['actions']['save_continue']['#weight'] = $form['actions']['save_continue']['#weight'] + 5; diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index ed2f05a3d566c44d6ec341db57e2e4ca543a66e5..039c305ea334e06211fbb526ddff11044cd7c871 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -387,7 +387,7 @@ function forum_comment_delete(CommentInterface $comment) { */ function forum_form_taxonomy_vocabulary_form_alter(&$form, FormStateInterface $form_state, $form_id) { $vid = \Drupal::config('forum.settings')->get('vocabulary'); - $vocabulary = $form_state['controller']->getEntity(); + $vocabulary = $form_state->getFormObject()->getEntity(); if ($vid == $vocabulary->id()) { $form['help_forum_vocab'] = array( '#markup' => t('This is the designated forum vocabulary. Some of the normal vocabulary options have been removed.'), @@ -419,7 +419,7 @@ function forum_form_taxonomy_term_form_alter(&$form, FormStateInterface $form_st * Implements hook_form_BASE_FORM_ID_alter() for node_form(). */ function forum_form_node_form_alter(&$form, FormStateInterface $form_state, $form_id) { - $node = $form_state['controller']->getEntity(); + $node = $form_state->getFormObject()->getEntity(); if (isset($node->taxonomy_forums) && !$node->isNew()) { $forum_terms = $node->taxonomy_forums; // If editing, give option to leave shadows. diff --git a/core/modules/menu_ui/menu_ui.module b/core/modules/menu_ui/menu_ui.module index 5790899bb6fbea6485f898e85b6931db46d19799..820887ae3e4185f5921e9e8f3b46e2954e895c12 100644 --- a/core/modules/menu_ui/menu_ui.module +++ b/core/modules/menu_ui/menu_ui.module @@ -321,7 +321,7 @@ function menu_ui_node_prepare_form(NodeInterface $node, $operation, FormStateInt function menu_ui_form_node_form_alter(&$form, FormStateInterface $form_state) { // Generate a list of possible parents (not including this link or descendants). // @todo This must be handled in a #process handler. - $node = $form_state['controller']->getEntity(); + $node = $form_state->getFormObject()->getEntity(); $definition = $form_state['menu_link_definition']; $type = $node->getType(); /** @var \Drupal\Core\Menu\MenuParentFormSelectorInterface $menu_parent_selector */ @@ -446,7 +446,7 @@ function menu_ui_form_node_type_form_alter(&$form, FormStateInterface $form_stat /** @var \Drupal\Core\Menu\MenuParentFormSelectorInterface $menu_parent_selector */ $menu_parent_selector = \Drupal::service('menu.parent_form_selector'); $menu_options = menu_ui_get_menus(); - $type = $form_state['controller']->getEntity(); + $type = $form_state->getFormObject()->getEntity(); if ($type->id()) { $config_values = \Drupal::config('menu.entity.node.' . $type->id())->get(); } @@ -516,7 +516,7 @@ function menu_ui_form_node_type_form_validate(&$form, FormStateInterface $form_s * @see menu_ui_form_node_type_form_alter(). */ function menu_ui_form_node_type_form_submit(&$form, FormStateInterface $form_state) { - $type = $form_state['controller']->getEntity(); + $type = $form_state->getFormObject()->getEntity(); \Drupal::config('menu.entity.node.' . $type->id()) ->set('available_menus', array_values(array_filter($form_state->getValue('menu_options')))) ->set('parent', $form_state->getValue('menu_parent')) diff --git a/core/modules/node/src/NodeForm.php b/core/modules/node/src/NodeForm.php index dff1d4f67cf76e99e56bda483ad482613c41dc4c..5bf0506c6d7aeb18d1435e363ce7e8bec38497d5 100644 --- a/core/modules/node/src/NodeForm.php +++ b/core/modules/node/src/NodeForm.php @@ -95,7 +95,7 @@ public function form(array $form, FormStateInterface $form_state) { // Rebuild the form. $form_state['rebuild'] = TRUE; - $this->entity = $preview['controller']->getEntity(); + $this->entity = $preview->getFormObject()->getEntity(); unset($this->entity->in_preview); } diff --git a/core/modules/node/src/NodeTranslationHandler.php b/core/modules/node/src/NodeTranslationHandler.php index cdcf11f4d7ee4d09fd3717a0ad6212679a63bf5b..1b27e847964dadaec98f8b020ceb0bb620debde9 100644 --- a/core/modules/node/src/NodeTranslationHandler.php +++ b/core/modules/node/src/NodeTranslationHandler.php @@ -40,8 +40,8 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, En $form['content_translation']['created']['#access'] = FALSE; } - $form_controller = content_translation_form_controller($form_state); - $form_langcode = $form_controller->getFormLangcode($form_state); + $form_object = $form_state->getFormObject(); + $form_langcode = $form_object->getFormLangcode($form_state); $translations = $entity->getTranslationLanguages(); $status_translatable = NULL; // Change the submit button labels if there was a status field they affect @@ -76,9 +76,9 @@ protected function entityFormTitle(EntityInterface $entity) { */ public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, FormStateInterface $form_state) { if ($form_state->hasValue('content_translation')) { - $form_controller = content_translation_form_controller($form_state); + $form_object = $form_state->getFormObject(); $translation = &$form_state->getValue('content_translation'); - $translation['status'] = $form_controller->getEntity()->isPublished(); + $translation['status'] = $form_object->getEntity()->isPublished(); // $form['content_translation']['name'] is the equivalent field // for translation author uid. $translation['name'] = $form_state->getValue('uid'); diff --git a/core/modules/node/src/ParamConverter/NodePreviewConverter.php b/core/modules/node/src/ParamConverter/NodePreviewConverter.php index 1b0f1181025e501fa9a1f1cb0c682293a4c32366..adf22ee823688fb5100172acc2b9a018c2840407 100644 --- a/core/modules/node/src/ParamConverter/NodePreviewConverter.php +++ b/core/modules/node/src/ParamConverter/NodePreviewConverter.php @@ -41,7 +41,7 @@ public function __construct(TempStoreFactory $temp_store_factory) { public function convert($value, $definition, $name, array $defaults, Request $request) { $store = $this->tempStoreFactory->get('node_preview'); if ($form_state = $store->get($value)) { - return $form_state['controller']->getEntity(); + return $form_state->getFormObject()->getEntity(); } } diff --git a/core/modules/path/path.module b/core/modules/path/path.module index aeba50b294d7b8def4d788246b1d30e62fceb6eb..0bf3781e4256b1edc7472356068599a7ff176f75 100644 --- a/core/modules/path/path.module +++ b/core/modules/path/path.module @@ -56,7 +56,7 @@ function path_permission() { * Implements hook_form_BASE_FORM_ID_alter() for node_form(). */ function path_form_node_form_alter(&$form, FormStateInterface $form_state) { - $node = $form_state['controller']->getEntity(); + $node = $form_state->getFormObject()->getEntity(); if ($node->hasField('path') && $node->get('path')->access('edit')) { $form['path_settings'] = array( '#type' => 'details', diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php index 86336f66d5c48d87bebe9180040182ecd03933bc..59922b7c776d2a66aabd3e434a217f0d67b7a754 100644 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -675,7 +675,7 @@ function hook_page_alter(&$page) { * * One popular use of this hook is to add form elements to the node form. When * altering a node form, the node entity can be retrieved by invoking - * $form_state['controller']->getEntity(). + * $form_state->getFormObject()->getEntity(). * * In addition to hook_form_alter(), which is called for all forms, there are * two more specific form hooks available. The first, diff --git a/core/modules/system/system.module b/core/modules/system/system.module index ddf052eac74b393618e8d802b66de3aa6b1a4fe7..dc372f8d6ee6eff75824f439889934582089bfd9 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -1024,7 +1024,7 @@ function system_user_login($account) { function system_user_timezone(&$form, FormStateInterface $form_state) { $user = \Drupal::currentUser(); - $account = $form_state['controller']->getEntity(); + $account = $form_state->getFormObject()->getEntity(); $form['timezone'] = array( '#type' => 'details', '#title' => t('Locale settings'), diff --git a/core/modules/system/tests/modules/entity_test/entity_test.module b/core/modules/system/tests/modules/entity_test/entity_test.module index 21d6508ecfdca3995545b26604f5d054c284d4d3..c7db020079483d59b095b77b4733e50ab6161447 100644 --- a/core/modules/system/tests/modules/entity_test/entity_test.module +++ b/core/modules/system/tests/modules/entity_test/entity_test.module @@ -247,7 +247,7 @@ function entity_test_permission() { * Implements hook_form_BASE_FORM_ID_alter(). */ function entity_test_form_node_form_alter(&$form, FormStateInterface $form_state, $form_id) { - $langcode = $form_state['controller']->getFormLangcode($form_state); + $langcode = $form_state->getFormObject()->getFormLangcode($form_state); \Drupal::state()->set('entity_test.form_langcode', $langcode); } diff --git a/core/modules/taxonomy/src/TermTranslationHandler.php b/core/modules/taxonomy/src/TermTranslationHandler.php index 565ace8db34521364f18c24abbd5eb26f15c2ee1..ec4bfe6a2d37bb7dd29ead1d7babe659a29ccbbf 100644 --- a/core/modules/taxonomy/src/TermTranslationHandler.php +++ b/core/modules/taxonomy/src/TermTranslationHandler.php @@ -33,7 +33,7 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, En */ function entityFormSave(array $form, FormStateInterface $form_state) { if ($this->getSourceLangcode($form_state)) { - $entity = content_translation_form_controller($form_state)->getEntity(); + $entity = $form_state->getFormObject()->getEntity(); // We need a redirect here, otherwise we would get an access denied page, // since the current URL would be preserved and we would try to add a // translation for a language that already has a translation. diff --git a/core/modules/user/src/ProfileTranslationHandler.php b/core/modules/user/src/ProfileTranslationHandler.php index 6e467b3c764eb4c2ee912e20e8ff92bbec0a2ebb..cd8befc6e96531428fe5be85d29e239ab3a7b6e4 100644 --- a/core/modules/user/src/ProfileTranslationHandler.php +++ b/core/modules/user/src/ProfileTranslationHandler.php @@ -33,7 +33,7 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, En */ function entityFormSave(array $form, FormStateInterface $form_state) { if ($this->getSourceLangcode($form_state)) { - $entity = content_translation_form_controller($form_state)->getEntity(); + $entity = $form_state->getFormObject()->getEntity(); // We need a redirect here, otherwise we would get an access denied page // since the current URL would be preserved and we would try to add a // translation for a language that already has a translation. diff --git a/core/themes/seven/seven.theme b/core/themes/seven/seven.theme index 18652ad54006598c60e529758e96c08924b85a4d..5ac883fe27214690f5170c43a238430dd5970d6f 100644 --- a/core/themes/seven/seven.theme +++ b/core/themes/seven/seven.theme @@ -268,7 +268,7 @@ function seven_preprocess_maintenance_page(&$variables) { */ function seven_form_node_form_alter(&$form, FormStateInterface $form_state) { /** @var \Drupal\node\NodeInterface $node */ - $node = $form_state->get('controller')->getEntity(); + $node = $form_state->getFormObject()->getEntity(); $form['#theme'] = array('node_edit_form'); $form['#attached']['css'][] = drupal_get_path('module', 'node') . '/css/node.module.css';