public function Theme::getCache in Express 8
Retrieves an individual item from a theme's cache in the database.
Parameters
string $name: The name of the item to retrieve from the theme cache.
array $context: Optional. An array of additional context to use for retrieving the cached storage.
mixed $default: Optional. The default value to use if $name does not exist.
Return value
mixed|\Drupal\bootstrap\Utility\StorageItem The cached value for $name.
3 calls to Theme::getCache()
- Theme::drupalSettings in themes/
contrib/ bootstrap/ src/ Theme.php - Retrieves the theme's settings array appropriate for drupalSettings.
- Theme::fileScan in themes/
contrib/ bootstrap/ src/ Theme.php - Wrapper for the core file_scan_directory() function.
- Theme::hasGlyphicons in themes/
contrib/ bootstrap/ src/ Theme.php - Determines whether or not if the theme has Bootstrap Framework Glyphicons.
File
- themes/
contrib/ bootstrap/ src/ Theme.php, line 378 - Contains \Drupal\bootstrap.
Class
- Theme
- Defines a theme object.
Namespace
Drupal\bootstrapCode
public function getCache($name, array $context = [], $default = []) {
static $cache = [];
// Prepend the theme name as the first context item, followed by cache name.
array_unshift($context, $name);
array_unshift($context, $this
->getName());
// Join context together with ":" and use it as the name.
$name = implode(':', $context);
if (!isset($cache[$name])) {
$storage = self::getStorage();
$value = $storage
->get($name);
if (!isset($value)) {
$value = is_array($default) ? new StorageItem($default, $storage) : $default;
$storage
->set($name, $value);
}
$cache[$name] = $value;
}
return $cache[$name];
}