diff --git a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php index babd2ff..3f28a78 100644 --- a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php +++ b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php @@ -450,9 +450,9 @@ public function onDependencyRemoval(array $dependencies) { if ($renderer->onDependencyRemoval($component_removed_dependencies)) { // Update component settings to reflect changes. $component['settings'] = $renderer->getSettings(); - $component['thirdPartySettings'] = []; + $component['third_party_settings'] = []; foreach ($renderer->getThirdPartyProviders() as $module) { - $component['thirdPartySettings'][$module] = $renderer->getThirdPartySettings($module); + $component['third_party_settings'][$module] = $renderer->getThirdPartySettings($module); } $this->setComponent($name, $component); $changed = TRUE; diff --git a/core/modules/field_ui/src/Tests/ManageDisplayTest.php b/core/modules/field_ui/src/Tests/ManageDisplayTest.php index 55ba2c2..2c1e40f 100644 --- a/core/modules/field_ui/src/Tests/ManageDisplayTest.php +++ b/core/modules/field_ui/src/Tests/ManageDisplayTest.php @@ -8,6 +8,7 @@ namespace Drupal\field_ui\Tests; use Drupal\Component\Utility\Unicode; +use Drupal\Core\Entity\Entity\EntityViewDisplay; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\node\Entity\NodeType; @@ -168,12 +169,26 @@ function testFormatterUI() { $this->drupalPostAjaxForm(NULL, array(), "field_test_settings_edit"); $this->drupalPostAjaxForm(NULL, $edit, "field_test_plugin_settings_update"); - // Uninstall the module providing third party settings and ensure the button - // is no longer there. + // When a module providing third-party settings to a formatter (or widget) + // is uninstalled, the formatter remain enabled but the provided settings, + // together with the corresponding form elements, are removed from the + // display component. \Drupal::service('module_installer')->uninstall(array('field_third_party_test')); + + // Ensure the button is still there after the module as been disabled. $this->drupalGet($manage_display); $this->assertResponse(200); - $this->assertNoFieldByName('field_test_settings_edit'); + $this->assertFieldByName('field_test_settings_edit'); + + // Ensure that third-party form elements are not present anymore. + $this->drupalPostAjaxForm(NULL, array(), 'field_test_settings_edit'); + $fieldname = 'fields[field_test][settings_edit_form][third_party_settings][field_third_party_test][field_test_field_formatter_third_party_settings_form]'; + $this->assertNoField($fieldname, 'The field added in hook_field_formatter_third_party_settings_form() is present on the settings form.'); + + // Ensure that third-party settings were removed from the formatter. + $display = EntityViewDisplay::load("node.{$this->type}.default"); + $component = $display->getComponent('field_test'); + $this->assertFalse(array_key_exists('field_third_party_test', $component['third_party_settings'])); } /**