You are here

public function Caching::get in Schema 8

Parameters

bool $rebuild: Whether to force a rebuild of schema data.

Return value

array Array of schema information, keyed by table.

Overrides SchemaProviderInterface::get

File

src/Plugin/Schema/Caching.php, line 26
Contains Drupal\schema\Plugin\Schema\Caching.

Class

Caching
Provides schema information for database cache tables.

Namespace

Drupal\schema\Plugin\Schema

Code

public function get($rebuild = FALSE) {
  $complete_schema = array();
  $cache_bins = Cache::getBins();
  foreach ($cache_bins as $name => $cache) {

    // If we have a chained backend, check if the persistent backend is a
    // DatabaseBackend.
    if ($cache instanceof ChainedFastBackend) {
      $reflection = new ReflectionClass(get_class($cache));
      $property = $reflection
        ->getProperty('consistentBackend');
      $property
        ->setAccessible(TRUE);
      $cache = $property
        ->getValue($cache);
    }

    // If we have a DatabaseBackend, add it's schema information.
    if ($cache instanceof DatabaseBackend) {
      $schema = $cache
        ->schemaDefinition();
      $complete_schema['cache_' . $name] = $schema;
    }
  }
  return $complete_schema;
}