function ControllerBase::keyValue

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

Returns a key/value storage collection.

Parameters

string $collection: Name of the key/value collection to return.

Return value

\Drupal\Core\KeyValueStore\KeyValueStoreInterface

File

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

Class

ControllerBase
Utility base class for thin controllers.

Namespace

Drupal\Core\Controller

Code

protected function keyValue($collection) {
    if (!$this->keyValue) {
        $this->keyValue = $this->container()
            ->get('keyvalue')
            ->get($collection);
    }
    return $this->keyValue;
}

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