SchemaCache.php 820 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
<?php

/**
 * @file
 * Definition of SchemaCache
 */

namespace Drupal\Core\Utility;

use Drupal\Core\Utility\CacheArray;

/**
13
 * Extends CacheArray to allow for dynamic building of the schema cache.
14
15
16
17
18
19
20
21
 */
class SchemaCache extends CacheArray {

  /**
   * Constructs a SchemaCache object.
   */
  public function __construct() {
    // Cache by request method.
22
    parent::__construct('schema:runtime:' . ($_SERVER['REQUEST_METHOD'] == 'GET'), 'cache', array('schema' => TRUE));
23
24
25
  }

  /**
26
   * Implements CacheArray::resolveCacheMiss().
27
28
29
30
31
32
33
34
35
   */
  protected function resolveCacheMiss($offset) {
    $complete_schema = drupal_get_complete_schema();
    $value = isset($complete_schema[$offset]) ? $complete_schema[$offset] :  NULL;
    $this->storage[$offset] = $value;
    $this->persist($offset);
    return $value;
  }
}