function ControllerBase::cache

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Controller/ControllerBase.php \Drupal\Core\Controller\ControllerBase::cache()
  2. 10 core/lib/Drupal/Core/Controller/ControllerBase.php \Drupal\Core\Controller\ControllerBase::cache()
  3. 11.x core/lib/Drupal/Core/Controller/ControllerBase.php \Drupal\Core\Controller\ControllerBase::cache()

Returns the requested cache bin.

Parameters

string $bin: (optional) The cache bin for which the cache object should be returned, defaults to 'default'.

Return value

\Drupal\Core\Cache\CacheBackendInterface The cache object associated with the specified bin.

File

core/lib/Drupal/Core/Controller/ControllerBase.php, line 148

Class

ControllerBase
Utility base class for thin controllers.

Namespace

Drupal\Core\Controller

Code

protected function cache($bin = 'default') {
    return $this->container()
        ->get('cache.' . $bin);
}

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