diff --git a/core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginBase.php b/core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginBase.php index 91fdce4..99be1f0 100644 --- a/core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginBase.php +++ b/core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginBase.php @@ -51,8 +51,8 @@ public function getConfiguration() { * {@inheritdoc} */ public function setConfiguration(array $configuration) { - // Resolve BC level configurations, if any. - $this->resolveBcConfiguration($configuration); + // Resolve backward compatibility level configurations, if any. + $this->resolveBackwardCompatibilityConfiguration($configuration); // Merge in defaults. $this->configuration = NestedArray::mergeDeep( @@ -60,8 +60,8 @@ public function setConfiguration(array $configuration) { $configuration ); - // Assure a BC level configuration. - $this->assureBcConfiguration(); + // Ensure a backward compatibility level configuration. + $this->ensureBackwardCompatibilityConfiguration(); } /** @@ -94,7 +94,7 @@ public function submitConfigurationForm(array &$form, FormStateInterface $form_s public function entityQueryAlter(SelectInterface $query) { } /** - * Moves the BC level configurations in the right place. + * Moves the backward compatibility level configurations in the right place. * * In order to keep backward compatibility, we copy all settings, except * 'target_type', 'handler' and 'entity' under 'handler_settings', following @@ -120,7 +120,7 @@ public function entityQueryAlter(SelectInterface $query) { } * * @deprecated Scheduled for removal in Drupal 9.0.x. */ - protected function resolveBcConfiguration(array &$configuration) { + protected function resolveBackwardCompatibilityConfiguration(array &$configuration) { if (isset($this->defaultConfiguration()['handler_settings'])) { throw new \InvalidArgumentException("{$this->getPluginDefinition()['class']}::defaultConfiguration() should not contain a 'handler_settings' key. All settings should be placed in the root level."); } @@ -130,7 +130,7 @@ protected function resolveBcConfiguration(array &$configuration) { if (!is_array($configuration['handler_settings'])) { throw new \InvalidArgumentException("The setting 'handler_settings' is reserved and cannot be used."); } - @trigger_error("Settings under 'handler_settings' are deprecated since version 8.3.x and will be removed before 9.0.0. Move the settings in the root of the configuration array.", E_USER_DEPRECATED); + @trigger_error("Providing settings under 'handler_settings' is deprecated since version 8.3.x and will be removed before 9.0.0. Move the settings in the root of the configuration array.", E_USER_DEPRECATED); // Settings passed in the root level take precedence over BC settings. $configuration += $configuration['handler_settings']; @@ -139,11 +139,11 @@ protected function resolveBcConfiguration(array &$configuration) { } /** - * Assures a BC level configuration. + * Ensures a backward compatibility level configuration. * * @deprecated Scheduled for removal in Drupal 9.0.x. */ - protected function assureBcConfiguration() { + protected function ensureBackwardCompatibilityConfiguration() { // Synchronize back 'handler_settings'. foreach ($this->configuration as $key => $value) { // Filter out keys that belong strictly to the root level. diff --git a/core/tests/Drupal/Tests/Core/EntityReferenceSelection/EntityReferenceSelectionUnitTest.php b/core/tests/Drupal/Tests/Core/EntityReferenceSelection/EntityReferenceSelectionUnitTest.php index 61372d1..65556c3 100644 --- a/core/tests/Drupal/Tests/Core/EntityReferenceSelection/EntityReferenceSelectionUnitTest.php +++ b/core/tests/Drupal/Tests/Core/EntityReferenceSelection/EntityReferenceSelectionUnitTest.php @@ -35,7 +35,7 @@ protected function setUp() { * Tests invalid default configuration. * * @covers ::defaultConfiguration - * @covers ::resolveBcConfiguration + * @covers ::resolveBackwardCompatibilityConfiguration * @expectedException \InvalidArgumentException * @expectedExceptionMessage TestSelectionWithInvalidDefaultConfiguration::defaultConfiguration() should not contain a 'handler_settings' key. All settings should be placed in the root level. */ @@ -51,7 +51,7 @@ public function testInvalidDefaultConfiguration() { * Tests the selection handler with malformed 'handler_settings' value. * * @covers ::setConfiguration - * @covers ::resolveBcConfiguration + * @covers ::resolveBackwardCompatibilityConfiguration * @expectedException \InvalidArgumentException * @expectedExceptionMessage The setting 'handler_settings' is reserved and cannot be used. */ @@ -125,6 +125,8 @@ public function providerTestSetConfiguration() { * * @dataProvider providerTestSetConfiguration * @covers ::setConfiguration + * @covers ::resolveBackwardCompatibilityConfiguration + * @covers ::ensureBackwardCompatibilityConfiguration * * @param array $options * The configuration passed to the plugin. @@ -161,7 +163,8 @@ public function testSetConfiguration($options) { * Tests the selection handler plugin BC structure. * * @covers ::setConfiguration - * @covers ::resolveBcConfiguration + * @covers ::resolveBackwardCompatibilityConfiguration + * @covers ::ensureBackwardCompatibilityConfiguration */ public function testSetConfigurationBcLevel() { $config = [ @@ -201,20 +204,20 @@ public function testSetConfigurationBcLevel() { * Tests deprecation error triggering. * * @covers ::setConfiguration - * @covers ::resolveBcConfiguration + * @covers ::resolveBackwardCompatibilityConfiguration */ public function testDeprecationErrorTriggering() { // Configuration with no BC level. $config = ['setting1' => TRUE]; new TestSelection($config, 'test_selector', []); // Check that deprecation error has not been triggered. - $this->assertNoError("Settings under 'handler_settings' are deprecated since version 8.3.x and will be removed before 9.0.0. Move the settings in the root of the configuration array.", E_USER_DEPRECATED); + $this->assertNoError("Providing settings under 'handler_settings' is deprecated since version 8.3.x and will be removed before 9.0.0. Move the settings in the root of the configuration array.", E_USER_DEPRECATED); // Configuration with BC level. $config = ['handler_settings' => ['setting1' => TRUE]]; new TestSelection($config, 'test_selector', []); // Check that deprecation error has been triggered. - $this->assertError("Settings under 'handler_settings' are deprecated since version 8.3.x and will be removed before 9.0.0. Move the settings in the root of the configuration array.", E_USER_DEPRECATED); + $this->assertError("Providing settings under 'handler_settings' is deprecated since version 8.3.x and will be removed before 9.0.0. Move the settings in the root of the configuration array.", E_USER_DEPRECATED); } /** @@ -228,7 +231,7 @@ public function testDeprecationErrorTriggering() { protected function assertError($message, $severity) { $assertion_message = "Error '$message' (severity $severity) was triggered."; foreach ($this->errors as $error) { - if ($error['message'] === $message && $error['severity'] == $severity) { + if ($error['message'] === $message && $error['severity'] === $severity) { $this->assertTrue(TRUE, $assertion_message); return; } @@ -247,7 +250,7 @@ protected function assertError($message, $severity) { protected function assertNoError($message, $severity) { $assertion_message = "Error '$message' (severity $severity) was not triggered."; foreach ($this->errors as $error) { - if ($error['message'] === $message && $error['severity'] == $severity) { + if ($error['message'] === $message && $error['severity'] === $severity) { $this->fail($assertion_message); return; }