DatabaseStorage
class DatabaseStorage implements StorageInterface (View source)
Defines the Database storage.
Traits
Provides dependency injection friendly methods for serialization.
Properties
| protected array | $_serviceIds | An array of service IDs keyed by property name used for serialization. |
from DependencySerializationTrait |
| protected array | $_entityStorages | An array of entity type IDs keyed by the property name of their storages. |
from DependencySerializationTrait |
| protected Connection | $connection | The database connection. |
|
| protected string | $table | The database table name. |
|
| protected array | $options | Additional database connection options to use in queries. |
|
| protected string | $collection | The storage collection. |
Methods
Constructs a new DatabaseStorage.
Returns whether a configuration object exists.
Reads configuration data from the storage.
Reads configuration data from the storage.
Writes configuration data to the storage.
Helper method so we can re-try a write.
Check if the config table exists and create it if not.
Defines the schema for the configuration table.
Implements Drupal\Core\Config\StorageInterface::delete().
Implements Drupal\Core\Config\StorageInterface::rename().
Encodes configuration data into the storage-specific format.
Implements Drupal\Core\Config\StorageInterface::decode().
Gets configuration object names starting with a given prefix.
Deletes configuration objects whose names start with a given prefix.
Creates a collection on the storage.
Gets the name of the current collection the storage is using.
Gets the existing collections.
Details
__sleep()
{@inheritdoc}
__wakeup()
{@inheritdoc}
__construct(Connection $connection, string $table, array $options = [], string $collection = StorageInterface::DEFAULT_COLLECTION)
Constructs a new DatabaseStorage.
bool
exists(string $name)
Returns whether a configuration object exists.
array|bool
read(string $name)
Reads configuration data from the storage.
array
readMultiple(array $names)
Reads configuration data from the storage.
bool
write(string $name, array $data)
Writes configuration data to the storage.
protected bool
doWrite(string $name, string $data)
Helper method so we can re-try a write.
protected bool
ensureTableExists()
Check if the config table exists and create it if not.
static protected
schemaDefinition()
| internal |
Defines the schema for the configuration table.
bool
delete(string $name)
Implements Drupal\Core\Config\StorageInterface::delete().
bool
rename(string $name, string $new_name)
Implements Drupal\Core\Config\StorageInterface::rename().
string
encode(array $data)
Encodes configuration data into the storage-specific format.
This is a publicly accessible static method to allow for alternative usages in data conversion scripts and also tests.
array
decode(string $raw)
Implements Drupal\Core\Config\StorageInterface::decode().
array
listAll(string $prefix = '')
Gets configuration object names starting with a given prefix.
Given the following configuration objects:
- node.type.article
- node.type.page
Passing the prefix 'node.type.' will return an array containing the above names.
bool
deleteAll(string $prefix = '')
Deletes configuration objects whose names start with a given prefix.
Given the following configuration object names:
- node.type.article
- node.type.page
Passing the prefix 'node.type.' will delete the above configuration objects.
$this
createCollection(string $collection)
Creates a collection on the storage.
A configuration storage can contain multiple sets of configuration objects in partitioned collections. The collection name identifies the current collection used.
Implementations of this method must provide a new instance to avoid side effects caused by the fact that Config objects have their storage injected.
string
getCollectionName()
Gets the name of the current collection the storage is using.
array
getAllCollectionNames()
Gets the existing collections.
A configuration storage can contain multiple sets of configuration objects in partitioned collections. The collection key name identifies the current collection used.