function DatabaseStorage::getAllCollectionNames

Same name in other branches
  1. 9 core/lib/Drupal/Core/Config/DatabaseStorage.php \Drupal\Core\Config\DatabaseStorage::getAllCollectionNames()
  2. 8.9.x core/lib/Drupal/Core/Config/DatabaseStorage.php \Drupal\Core\Config\DatabaseStorage::getAllCollectionNames()
  3. 10 core/lib/Drupal/Core/Config/DatabaseStorage.php \Drupal\Core\Config\DatabaseStorage::getAllCollectionNames()

Overrides StorageInterface::getAllCollectionNames

File

core/lib/Drupal/Core/Config/DatabaseStorage.php, line 334

Class

DatabaseStorage
Defines the Database storage.

Namespace

Drupal\Core\Config

Code

public function getAllCollectionNames() {
    try {
        return $this->connection
            ->query('SELECT DISTINCT [collection] FROM {' . $this->connection
            ->escapeTable($this->table) . '} WHERE [collection] <> :collection ORDER by [collection]', [
            ':collection' => StorageInterface::DEFAULT_COLLECTION,
        ])
            ->fetchCol();
    } catch (\Exception $e) {
        if ($this->connection
            ->schema()
            ->tableExists($this->table)) {
            throw $e;
        }
        // If we attempt a read without actually having the table available,
        // return an empty array so the caller can handle it.
        return [];
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.