You are here

public function CacheContexts::getLabels in Render cache 7.2

Provides an array of available cache context labels.

To be used in cache configuration forms.

Return value

array An array of available cache contexts and corresponding labels.

File

lib/Drupal/Core/Cache/CacheContexts.php, line 68
Contains \Drupal\Core\Cache\CacheContexts.

Class

CacheContexts
Defines the CacheContexts service.

Namespace

Drupal\Core\Cache

Code

public function getLabels() {
  $with_labels = array();
  foreach ($this->contexts as $context) {
    $with_labels[$context] = $this
      ->getService($context)
      ->getLabel();
  }
  return $with_labels;
}