X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrupal%2Fdrupal-extension%2Fsrc%2FDrupal%2FDrupalExtension%2FContext%2FConfigContext.php;fp=vendor%2Fdrupal%2Fdrupal-extension%2Fsrc%2FDrupal%2FDrupalExtension%2FContext%2FConfigContext.php;h=256865e7943723e30eaf32151b6d995e6a174db2;hp=0000000000000000000000000000000000000000;hb=1270d9129ce8f27c9b28b10518e32132c58e0aca;hpb=c27c0f0cdaa3f354b1fe54a56ae7e854be6e3f68 diff --git a/vendor/drupal/drupal-extension/src/Drupal/DrupalExtension/Context/ConfigContext.php b/vendor/drupal/drupal-extension/src/Drupal/DrupalExtension/Context/ConfigContext.php new file mode 100644 index 000000000..256865e79 --- /dev/null +++ b/vendor/drupal/drupal-extension/src/Drupal/DrupalExtension/Context/ConfigContext.php @@ -0,0 +1,107 @@ +config as $name => $key_value) { + foreach ($key_value as $key => $value) { + $this->getDriver()->configSet($name, $key, $value); + } + } + $this->config = array(); + } + + /** + * Sets basic configuration item. + * + * @param string $name + * The name of the configuration object. + * @param string $key + * Identifier to store value in configuration. + * @param mixed $value + * Value to associate with identifier. + * + * @Given I set the configuration item :name with key :key to :value + */ + public function setBasicConfig($name, $key, $value) { + $this->setConfig($name, $key, $value); + } + + /** + * Sets complex configuration. + * + * @param string $name + * The name of the configuration object. + * @param string $key + * Identifier to store value in configuration. + * @param TableNode $config_table + * The table listing configuration keys and values. + * + * @Given I set the configuration item :name with key :key with values: + * + * Provide configuration data in the following format: + * | key | value | + * | foo | bar | + */ + public function setComplexConfig($name, $key, TableNode $config_table) { + $value = array(); + foreach ($config_table->getHash() as $row) { + // Allow json values for extra complexity. + if (json_decode($row['value'])) { + $row['value'] = json_decode($row['value'], TRUE); + } + $value[$row['key']] = $row['value']; + } + $this->setConfig($name, $key, $value); + } + + /** + * Sets a value in a configuration object. + * + * @param string $name + * The name of the configuration object. + * @param string $key + * Identifier to store value in configuration. + * @param mixed $value + * Value to associate with identifier. + */ + public function setConfig($name, $key, $value) { + $backup = $this->getDriver()->configGet($name, $key); + $this->getDriver()->configSet($name, $key, $value); + $this->config[$name][$key] = $backup; + } + +} \ No newline at end of file