summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwebchick2014-08-26 05:24:55 (GMT)
committerwebchick2014-08-26 05:24:55 (GMT)
commitc7013bdaee767fd303e33b1658822b34044a678f (patch)
tree9b2cc2b13f86f5dc4f7ebc75084acfb7d25bf26f
parentcd240fd2dee5ac783c2faa6ddde4633709229c60 (diff)
Issue #2313931 by Berdir: Merge ['controller'] with ['build_info']['callback_object'] and add a method for it.
-rw-r--r--core/lib/Drupal/Core/Entity/EntityForm.php9
-rw-r--r--core/lib/Drupal/Core/Form/FormState.php10
-rw-r--r--core/lib/Drupal/Core/Form/FormStateInterface.php8
-rw-r--r--core/modules/book/book.module4
-rw-r--r--core/modules/contact/contact.module4
-rw-r--r--core/modules/content_translation/content_translation.module25
-rw-r--r--core/modules/content_translation/src/ContentTranslationHandler.php26
-rw-r--r--core/modules/editor/editor.module6
-rw-r--r--core/modules/field_ui/field_ui.module2
-rw-r--r--core/modules/forum/forum.module4
-rw-r--r--core/modules/menu_ui/menu_ui.module6
-rw-r--r--core/modules/node/src/NodeForm.php2
-rw-r--r--core/modules/node/src/NodeTranslationHandler.php8
-rw-r--r--core/modules/node/src/ParamConverter/NodePreviewConverter.php2
-rw-r--r--core/modules/path/path.module2
-rw-r--r--core/modules/system/system.api.php2
-rw-r--r--core/modules/system/system.module2
-rw-r--r--core/modules/system/tests/modules/entity_test/entity_test.module2
-rw-r--r--core/modules/taxonomy/src/TermTranslationHandler.php2
-rw-r--r--core/modules/user/src/ProfileTranslationHandler.php2
-rw-r--r--core/themes/seven/seven.theme2
21 files changed, 66 insertions, 64 deletions
diff --git a/core/lib/Drupal/Core/Entity/EntityForm.php b/core/lib/Drupal/Core/Entity/EntityForm.php
index 75d9014..41f1c30 100644
--- a/core/lib/Drupal/Core/Entity/EntityForm.php
+++ b/core/lib/Drupal/Core/Entity/EntityForm.php
@@ -89,7 +89,7 @@ class EntityForm extends FormBase implements EntityFormInterface {
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 @@ class EntityForm extends FormBase implements EntityFormInterface {
* 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 @@ class EntityForm extends FormBase implements EntityFormInterface {
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 50b75f7..d4c29e2 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.
@@ -808,6 +808,14 @@ class FormState implements FormStateInterface, \ArrayAccess {
}
/**
+ * {@inheritdoc}
+ */
+ public function getFormObject() {
+ $build_info = $this->get('build_info');
+ return $build_info['callback_object'];
+ }
+
+ /**
* Wraps drupal_set_message().
*
* @return array|null
diff --git a/core/lib/Drupal/Core/Form/FormStateInterface.php b/core/lib/Drupal/Core/Form/FormStateInterface.php
index 164078a..a154f3b 100644
--- a/core/lib/Drupal/Core/Form/FormStateInterface.php
+++ b/core/lib/Drupal/Core/Form/FormStateInterface.php
@@ -470,4 +470,12 @@ interface FormStateInterface {
*/
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 ab0a5fe..5e87f43 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 129d42a..368ad0f 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 d218a8d..5c86c4e 100644
--- a/core/modules/content_translation/content_translation.module
+++ b/core/modules/content_translation/content_translation.module
@@ -335,22 +335,6 @@ function content_translation_controller($entity_type_id) {
}
/**
- * 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.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
@@ -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 c1f638f..60eb6f3 100644
--- a/core/modules/content_translation/src/ContentTranslationHandler.php
+++ b/core/modules/content_translation/src/ContentTranslationHandler.php
@@ -84,8 +84,8 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface {
* {@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 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface {
// 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 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface {
* @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 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface {
* 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 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface {
* 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 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface {
* 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 7a729cc..ae20c49 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 033832c..696d07a 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 ed2f05a..039c305 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 5790899..820887a 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 dff1d4f..5bf0506 100644
--- a/core/modules/node/src/NodeForm.php
+++ b/core/modules/node/src/NodeForm.php
@@ -95,7 +95,7 @@ class NodeForm extends ContentEntityForm {
// 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 cdcf11f..1b27e84 100644
--- a/core/modules/node/src/NodeTranslationHandler.php
+++ b/core/modules/node/src/NodeTranslationHandler.php
@@ -40,8 +40,8 @@ class NodeTranslationHandler extends ContentTranslationHandler {
$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 @@ class NodeTranslationHandler extends ContentTranslationHandler {
*/
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 1b0f118..adf22ee 100644
--- a/core/modules/node/src/ParamConverter/NodePreviewConverter.php
+++ b/core/modules/node/src/ParamConverter/NodePreviewConverter.php
@@ -41,7 +41,7 @@ class NodePreviewConverter implements ParamConverterInterface {
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 aeba50b..0bf3781 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 86336f6..59922b7 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 ddf052e..dc372f8 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 21d6508..c7db020 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 565ace8..ec4bfe6 100644
--- a/core/modules/taxonomy/src/TermTranslationHandler.php
+++ b/core/modules/taxonomy/src/TermTranslationHandler.php
@@ -33,7 +33,7 @@ class TermTranslationHandler extends ContentTranslationHandler {
*/
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 6e467b3..cd8befc 100644
--- a/core/modules/user/src/ProfileTranslationHandler.php
+++ b/core/modules/user/src/ProfileTranslationHandler.php
@@ -33,7 +33,7 @@ class ProfileTranslationHandler extends ContentTranslationHandler {
*/
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 18652ad..5ac883f 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';