protected function RestfulBase::newCacheObject in RESTful 7
Get the default cache object based on the plugin configuration.
By default, this returns an instance of the DrupalDatabaseCache class. Classes implementing DrupalCacheInterface can register themselves both as a default implementation and for specific bins.
Return value
\DrupalCacheInterface The cache object associated with the specified bin.
See also
2 calls to RestfulBase::newCacheObject()
- RestfulBase::__construct in plugins/
restful/ RestfulBase.php - Constructs a RestfulEntityBase object.
- RestfulEntityBaseMultipleBundles::__construct in plugins/
restful/ RestfulEntityBaseMultipleBundles.php - Constructs a RestfulDataProviderEFQ object.
File
- plugins/
restful/ RestfulBase.php, line 1247 - Contains RestfulBase.
Class
- RestfulBase
- Class \RestfulBase
Code
protected function newCacheObject() {
// We do not use drupal_static() here because we do not want to change the
// storage of a cache bin mid-request.
static $cache_object;
if (isset($cache_object)) {
// Return cached object.
return $cache_object;
}
$cache_info = $this
->getPluginKey('render_cache');
$class = $cache_info['class'];
if (empty($class)) {
$class = variable_get('cache_class_' . $cache_info['bin']);
if (empty($class)) {
$class = variable_get('cache_default_class', 'DrupalDatabaseCache');
}
}
$cache_object = new $class($cache_info['bin']);
return $cache_object;
}