diff --git a/core/lib/Drupal/Core/Config/DrupalConfig.php b/core/lib/Drupal/Core/Config/DrupalConfig.php deleted file mode 100644 index f5a9220..0000000 --- a/core/lib/Drupal/Core/Config/DrupalConfig.php +++ /dev/null @@ -1,220 +0,0 @@ -storage = $storage; - $this->read(); - } - - /** - * Reads config data from the active store into our object. - */ - public function read() { - $data = $this->storage->read(); - $this->setData($data !== FALSE ? $data : array()); - return $this; - } - - /** - * Checks whether a particular value is overridden. - * - * @param $key - * @todo - * - * @return - * @todo - */ - public function isOverridden($key) { - return isset($this->_overrides[$key]); - } - - /** - * Gets data from this config object. - * - * @param $key - * A string that maps to a key within the configuration data. - * For instance in the following configuation array: - * @code - * array( - * 'foo' => array( - * 'bar' => 'baz', - * ), - * ); - * @endcode - * A key of 'foo.bar' would return the string 'baz'. However, a key of 'foo' - * would return array('bar' => 'baz'). - * If no key is specified, then the entire data array is returned. - * - * The configuration system does not retain data types. Every saved value is - * casted to a string. In most cases this is not an issue; however, it can - * cause issues with Booleans, which are casted to "1" (TRUE) or "0" (FALSE). - * In particular, code relying on === or !== will no longer function properly. - * - * @see http://php.net/manual/language.operators.comparison.php. - * - * @return - * The data that was requested. - */ - public function get($key = '') { - global $conf; - - $name = $this->storage->getName(); - if (isset($conf[$name])) { - $merged_data = drupal_array_merge_deep($this->data, $conf[$name]); - } - else { - $merged_data = $this->data; - } - - if (empty($key)) { - return $merged_data; - } - else { - $parts = explode('.', $key); - if (count($parts) == 1) { - return isset($merged_data[$key]) ? $merged_data[$key] : NULL; - } - else { - $key_exists = NULL; - $value = drupal_array_get_nested_value($merged_data, $parts, $key_exists); - return $key_exists ? $value : NULL; - } - } - } - - /** - * Replaces the data of this configuration object. - * - * @param array $data - * The new configuration data. - */ - public function setData(array $data) { - $this->data = $data; - return $this; - } - - /** - * Sets value in this config object. - * - * @param $key - * @todo - * @param $value - * @todo - */ - public function set($key, $value) { - // Type-cast value into a string. - $value = $this->castValue($value); - - // The dot/period is a reserved character; it may appear between keys, but - // not within keys. - $parts = explode('.', $key); - if (count($parts) == 1) { - $this->data[$key] = $value; - } - else { - drupal_array_set_nested_value($this->data, $parts, $value); - } - return $this; - } - - /** - * Casts a saved value to a string. - * - * The configuration system only saves strings or arrays. Any scalar - * non-string value is cast to a string. The one exception is boolean FALSE - * which would normally become '' when cast to a string, but is manually - * cast to '0' here for convenience and consistency. - * - * Any non-scalar value that is not an array (aka objects) gets cast - * to an array. - * - * @param $value - * A value being saved into the configuration system. - * @param $value - * The value cast to a string or array. - */ - public function castValue($value) { - if (is_scalar($value)) { - // Handle special case of FALSE, which should be '0' instead of ''. - if ($value === FALSE) { - $value = '0'; - } - else { - $value = (string) $value; - } - } - else { - // Any non-scalar value must be an array. - if (!is_array($value)) { - $value = (array) $value; - } - // Recurse into any nested keys. - foreach ($value as $key => $nested_value) { - $value[$key] = $this->castValue($nested_value); - } - } - return $value; - } - - /** - * Unsets value in this config object. - * - * @param $key - * Name of the key whose value should be unset. - */ - public function clear($key) { - $parts = explode('.', $key); - if (count($parts) == 1) { - unset($this->data[$key]); - } - else { - drupal_array_unset_nested_value($this->data, $parts); - } - } - - /** - * Saves the configuration object. - */ - public function save() { - $this->storage->write($this->data); - } - - /** - * Deletes the configuration object. - */ - public function delete() { - $this->data = array(); - $this->storage->delete(); - } -} diff --git a/core/lib/Drupal/Core/Config/FileStorageException.php b/core/lib/Drupal/Core/Config/FileStorageException.php deleted file mode 100644 index bf3ae5f..0000000 --- a/core/lib/Drupal/Core/Config/FileStorageException.php +++ /dev/null @@ -1,10 +0,0 @@ -name = $name; - } - - /** - * Instantiates a new file storage object or returns the existing one. - * - * @return Drupal\Core\Config\FileStorage - * The file object for this configuration object. - */ - protected function fileStorage() { - if (!isset($this->fileStorage)) { - $this->fileStorage = new FileStorage($this->name); - } - return $this->fileStorage; - } - - /** - * Implements StorageInterface::copyToFile(). - */ - public function copyToFile() { - return $this->writeToFile($this->read()); - } - - /** - * Implements StorageInterface::deleteFile(). - */ - public function deleteFile() { - return $this->fileStorage()->delete(); - } - - /** - * Implements StorageInterface::copyFromFile(). - */ - public function copyFromFile() { - return $this->writeToActive($this->readFromFile()); - } - - /** - * @todo - * - * @return - * @todo - */ - public function readFromFile() { - return $this->fileStorage()->read($this->name); - } - - /** - * Implements StorageInterface::isOutOfSync(). - */ - public function isOutOfSync() { - return $this->read() !== $this->readFromFile(); - } - - /** - * Implements StorageInterface::write(). - */ - public function write($data) { - $this->writeToActive($data); - $this->writeToFile($data); - } - - /** - * Implements StorageInterface::writeToFile(). - */ - public function writeToFile($data) { - return $this->fileStorage()->write($data); - } - - /** - * Implements StorageInterface::delete(). - */ - public function delete() { - $this->deleteFromActive(); - $this->deleteFile(); - } - - /** - * Implements StorageInterface::getName(). - */ - public function getName() { - return $this->name; - } - - /** - * Implements StorageInterface::setName(). - */ - public function setName($name) { - $this->name = $name; - } -} diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigFileSecurityTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigFileSecurityTest.php deleted file mode 100644 index 5f9ec07..0000000 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigFileSecurityTest.php +++ /dev/null @@ -1,51 +0,0 @@ - 'Good morning, Denver!'); - - public static function getInfo() { - return array( - 'name' => 'File security', - 'description' => 'Tests security of saved configuration files.', - 'group' => 'Configuration', - ); - } - - /** - * Tests that a file written by this system can be successfully read back. - */ - function testFilePersist() { - $file = new FileStorage($this->filename); - $file->write($this->testContent); - - unset($file); - - // Reading should throw an exception in case of bad validation. - // Note that if any other exception is thrown, we let the test system - // handle catching and reporting it. - try { - $file = new FileStorage($this->filename); - $saved_content = $file->read(); - - $this->assertEqual($saved_content, $this->testContent); - } - catch (Exception $e) { - $this->fail('File failed verification when being read.'); - } - } -}