summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2014-10-07 16:26:04 (GMT)
committerAlex Pott2014-10-07 16:26:04 (GMT)
commit15cc5bd85ac975d87bb8167bcbd32b0c4938a8c0 (patch)
tree746c5122c24e4ec8c88b35a05ba9c6d7ca41e766
parent046bf09b430669084b5173d9fee0ad7d09f58ede (diff)
Issue #2345879 by marcvangend: Added Enhance ThirdPartySettingsTrait with a get-all-settings method.
-rw-r--r--core/lib/Drupal/Core/Config/Entity/ThirdPartySettingsTrait.php13
-rw-r--r--core/tests/Drupal/Tests/Core/Config/Entity/ThirdPartySettingsTraitTest.php5
2 files changed, 18 insertions, 0 deletions
diff --git a/core/lib/Drupal/Core/Config/Entity/ThirdPartySettingsTrait.php b/core/lib/Drupal/Core/Config/Entity/ThirdPartySettingsTrait.php
index 3f63794..cc12885 100644
--- a/core/lib/Drupal/Core/Config/Entity/ThirdPartySettingsTrait.php
+++ b/core/lib/Drupal/Core/Config/Entity/ThirdPartySettingsTrait.php
@@ -68,6 +68,19 @@ trait ThirdPartySettingsTrait {
}
/**
+ * Gets all third-party settings of a given module.
+ *
+ * @param string $module
+ * The module providing the third-party settings.
+ *
+ * @return array
+ * An array of key-value pairs.
+ */
+ public function getThirdPartySettings($module) {
+ return isset($this->third_party_settings[$module]) ? $this->third_party_settings[$module] : array();
+ }
+
+ /**
* Unsets a third-party setting.
*
* @param string $module
diff --git a/core/tests/Drupal/Tests/Core/Config/Entity/ThirdPartySettingsTraitTest.php b/core/tests/Drupal/Tests/Core/Config/Entity/ThirdPartySettingsTraitTest.php
index 2cdf90e..bcbe12b 100644
--- a/core/tests/Drupal/Tests/Core/Config/Entity/ThirdPartySettingsTraitTest.php
+++ b/core/tests/Drupal/Tests/Core/Config/Entity/ThirdPartySettingsTraitTest.php
@@ -19,6 +19,7 @@ class ThirdPartySettingsTraitTest extends UnitTestCase {
/**
* @covers ::getThirdPartySetting
* @covers ::setThirdPartySetting
+ * @covers ::getThirdPartySettings
* @covers ::unsetThirdPartySetting
* @covers ::getThirdPartyProviders
*/
@@ -38,6 +39,10 @@ class ThirdPartySettingsTraitTest extends UnitTestCase {
$this->assertEquals($value, $trait_object->getThirdPartySetting($third_party, $key));
$this->assertEquals($value, $trait_object->getThirdPartySetting($third_party, $key, $this->randomGenerator->string()));
+ // Test getThirdPartySettings().
+ $trait_object->setThirdPartySetting($third_party, 'test2', 'value2');
+ $this->assertEquals(array($key => $value, 'test2' => 'value2'), $trait_object->getThirdPartySettings($third_party));
+
// Test getThirdPartyProviders().
$trait_object->setThirdPartySetting('test_provider2', $key, $value);
$this->assertEquals(array($third_party, 'test_provider2'), $trait_object->getThirdPartyProviders());