Commit bb691f62 authored by catch's avatar catch
Browse files

Issue #1567812 by sun: Remove 'Verified' from configuration class names.

parent db79496a
<?php
use Drupal\Core\Config\DrupalVerifiedStorageSQL;
use Drupal\Core\Config\DatabaseStorage;
/**
* @file
......@@ -48,8 +48,8 @@ function config_install_default_config($module) {
$file = array_pop($parts);
$config_name = str_replace('.xml', '', $file);
$verified_storage = new DrupalVerifiedStorageSQL($config_name);
$verified_storage->write(file_get_contents($module_config_dir . '/' . $file));
$storage = new DatabaseStorage($config_name);
$storage->write(file_get_contents($module_config_dir . '/' . $file));
}
}
}
......@@ -88,8 +88,8 @@ function config_get_files_with_prefix($prefix = '') {
* @return
* @todo
*/
function config_get_verified_storage_names_with_prefix($prefix = '') {
return DrupalVerifiedStorageSQL::getNamesWithPrefix($prefix);
function config_get_storage_names_with_prefix($prefix = '') {
return DatabaseStorage::getNamesWithPrefix($prefix);
}
/**
......@@ -114,7 +114,7 @@ function config_get_verified_storage_names_with_prefix($prefix = '') {
* alternate storage engines..
*/
function config($name, $class = 'Drupal\Core\Config\DrupalConfig') {
return new $class(new DrupalVerifiedStorageSQL($name));
return new $class(new DatabaseStorage($name));
}
/**
......
......@@ -2,16 +2,16 @@
namespace Drupal\Core\Config;
use Drupal\Core\Config\DrupalConfigVerifiedStorage;
use Drupal\Core\Config\StorageBase;
use Exception;
/**
* Represents an SQL-based configuration storage object.
*/
class DrupalVerifiedStorageSQL extends DrupalConfigVerifiedStorage {
class DatabaseStorage extends StorageBase {
/**
* Overrides DrupalConfigVerifiedStorage::read().
* Overrides StorageBase::read().
*/
public function read() {
// There are situations, like in the installer, where we may attempt a
......@@ -26,7 +26,7 @@ public function read() {
}
/**
* Implements DrupalConfigVerifiedStorageInterface::writeToActive().
* Implements StorageInterface::writeToActive().
*/
public function writeToActive($data) {
return db_merge('config')
......@@ -45,7 +45,7 @@ public function deleteFromActive() {
}
/**
* Implements DrupalConfigVerifiedStorageInterface::getNamesWithPrefix().
* Implements StorageInterface::getNamesWithPrefix().
*/
static public function getNamesWithPrefix($prefix = '') {
return db_query('SELECT name FROM {config} WHERE name LIKE :name', array(':name' => db_like($prefix) . '%'))->fetchCol();
......
......@@ -2,7 +2,7 @@
namespace Drupal\Core\Config;
use Drupal\Core\Config\DrupalConfigVerifiedStorageInterface;
use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Config\ConfigException;
/**
......@@ -13,22 +13,22 @@ class DrupalConfig {
/**
* The storage engine to save this config object to.
*
* @var DrupalConfigVerifiedStorageInterface
* @var StorageInterface
*/
protected $_verifiedStorage;
protected $storage;
protected $data = array();
/**
* Constructs a DrupalConfig object.
*
* @param DrupalConfigVerifiedStorageInterface $verified_storage
* @param StorageInterface $storage
* The storage engine where this config object should be saved.
*
* @todo $this should really know about $name and make it publicly accessible.
*/
public function __construct(DrupalConfigVerifiedStorageInterface $verified_storage) {
$this->_verifiedStorage = $verified_storage;
public function __construct(StorageInterface $storage) {
$this->storage = $storage;
$this->read();
}
......@@ -36,7 +36,7 @@ public function __construct(DrupalConfigVerifiedStorageInterface $verified_stora
* Reads config data from the active store into our object.
*/
public function read() {
$active = (array) config_decode($this->_verifiedStorage->read());
$active = (array) config_decode($this->storage->read());
foreach ($active as $key => $value) {
// If the setting is empty, return an empty string rather than an array.
// This is necessary because SimpleXML's default behavior is to return
......@@ -89,7 +89,7 @@ public function isOverridden($key) {
public function get($key = '') {
global $conf;
$name = $this->_verifiedStorage->getName();
$name = $this->storage->getName();
if (isset($conf[$name])) {
$merged_data = drupal_array_merge_deep($this->data, $conf[$name]);
}
......@@ -201,7 +201,7 @@ public function clear($key) {
* Saves the configuration object to disk as XML.
*/
public function save() {
$this->_verifiedStorage->write(config_encode($this->data));
$this->storage->write(config_encode($this->data));
}
/**
......@@ -209,6 +209,6 @@ public function save() {
*/
public function delete() {
$this->data = array();
$this->_verifiedStorage->delete();
$this->storage->delete();
}
}
......@@ -32,7 +32,7 @@ public function __construct($name) {
protected function readData() {
$data = file_get_contents($this->getFilePath());
if ($data === FALSE) {
throw new \Exception('Read file is invalid.');
throw new FileStorageReadException('Read file is invalid.');
}
return $data;
}
......@@ -68,7 +68,7 @@ public function getFilePath() {
*/
public function write($data) {
if (!file_put_contents($this->getFilePath(), $data)) {
throw new \Exception('Failed to write configuration file: ' . $this->getFilePath());
throw new FileStorageException('Failed to write configuration file: ' . $this->getFilePath());
}
}
......
......@@ -7,4 +7,4 @@
/**
* @todo
*/
class ConfigFileStorageException extends ConfigException {}
class FileStorageException extends ConfigException {}
......@@ -2,9 +2,9 @@
namespace Drupal\Core\Config;
use Drupal\Core\Config\ConfigFileStorageException;
use Drupal\Core\Config\FileStorageException;
/**
* @todo
*/
class ConfigFileStorageReadException extends ConfigFileStorageException {}
class FileStorageReadException extends FileStorageException {}
......@@ -2,13 +2,13 @@
namespace Drupal\Core\Config;
use Drupal\Core\Config\DrupalConfigVerifiedStorageInterface;
use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Config\FileStorage;
/**
* @todo
*/
abstract class DrupalConfigVerifiedStorage implements DrupalConfigVerifiedStorageInterface {
abstract class StorageBase implements StorageInterface {
protected $name;
......@@ -20,7 +20,7 @@ abstract class DrupalConfigVerifiedStorage implements DrupalConfigVerifiedStorag
protected $fileStorage;
/**
* Implements DrupalConfigVerifiedStorageInterface::__construct().
* Implements StorageInterface::__construct().
*/
function __construct($name) {
$this->name = $name;
......@@ -40,21 +40,21 @@ protected function fileStorage() {
}
/**
* Implements DrupalConfigVerifiedStorageInterface::copyToFile().
* Implements StorageInterface::copyToFile().
*/
public function copyToFile() {
return $this->writeToFile($this->read());
}
/**
* Implements DrupalConfigVerifiedStorageInterface::deleteFile().
* Implements StorageInterface::deleteFile().
*/
public function deleteFile() {
return $this->fileStorage()->delete();
}
/**
* Implements DrupalConfigVerifiedStorageInterface::copyFromFile().
* Implements StorageInterface::copyFromFile().
*/
public function copyFromFile() {
return $this->writeToActive($this->readFromFile());
......@@ -71,14 +71,14 @@ public function readFromFile() {
}
/**
* Implements DrupalConfigVerifiedStorageInterface::isOutOfSync().
* Implements StorageInterface::isOutOfSync().
*/
public function isOutOfSync() {
return $this->read() !== $this->readFromFile();
}
/**
* Implements DrupalConfigVerifiedStorageInterface::write().
* Implements StorageInterface::write().
*/
public function write($data) {
$this->writeToActive($data);
......@@ -86,14 +86,14 @@ public function write($data) {
}
/**
* Implements DrupalConfigVerifiedStorageInterface::writeToFile().
* Implements StorageInterface::writeToFile().
*/
public function writeToFile($data) {
return $this->fileStorage()->write($data);
}
/**
* Implements DrupalConfigVerifiedStorageInterface::delete().
* Implements StorageInterface::delete().
*/
public function delete() {
$this->deleteFromActive();
......@@ -101,7 +101,7 @@ public function delete() {
}
/**
* Implements DrupalConfigVerifiedStorageInterface::getName().
* Implements StorageInterface::getName().
*/
public function getName() {
return $this->name;
......
......@@ -3,15 +3,15 @@
namespace Drupal\Core\Config;
/**
* Defines an interface for verified storage manipulation.
* Defines an interface for configuration storage manipulation.
*
* This class allows reading and writing configuration data from/to the
* verified storage and copying to/from the file storing the same data.
* storage and copying to/from the file storing the same data.
*/
interface DrupalConfigVerifiedStorageInterface {
interface StorageInterface {
/**
* Constructs a verified storage manipulation class.
* Constructs a storage manipulation class.
*
* @param $name
* Lowercase string, the name for the configuration data.
......@@ -19,17 +19,17 @@ interface DrupalConfigVerifiedStorageInterface {
function __construct($name);
/**
* Reads the configuration data from the verified storage.
* Reads the configuration data from the storage.
*/
function read();
/**
* Copies the configuration data from the verified storage into a file.
* Copies the configuration data from the storage into a file.
*/
function copyToFile();
/**
* Copies the configuration data from the file into the verified storage.
* Copies the configuration data from the file into the storage.
*/
function copyFromFile();
......@@ -39,10 +39,10 @@ function copyFromFile();
function deleteFile();
/**
* Checks whether the file and the verified storage is in sync.
* Checks whether the file and the storage is in sync.
*
* @return
* TRUE if the file and the verified storage contains the same data, FALSE
* TRUE if the file and the storage contains the same data, FALSE
* if not.
*/
function isOutOfSync();
......
......@@ -516,7 +516,7 @@ function image_styles() {
$styles = array();
// Select the styles we have configured.
$configured_styles = config_get_verified_storage_names_with_prefix('image.style');
$configured_styles = config_get_storage_names_with_prefix('image.style');
foreach ($configured_styles as $config_name) {
// @todo Allow to retrieve the name without prefix only.
$style = image_style_load(str_replace('image.style.', '', $config_name));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment