public function ContextManager::getContexts in Context 8.4
Same name and namespace in other branches
- 8 src/ContextManager.php \Drupal\context\ContextManager::getContexts()
- 8.0 src/ContextManager.php \Drupal\context\ContextManager::getContexts()
Get all contexts.
Return value
\Drupal\context\ContextInterface[] List of contexts, keyed by id.
3 calls to ContextManager::getContexts()
- ContextManager::evaluateContexts in src/ContextManager.php 
- Evaluate all context conditions.
- ContextManager::getContext in src/ContextManager.php 
- Get a single context by id.
- ContextManager::getContextsByGroup in src/ContextManager.php 
- Get all contexts sorted by their group.
File
- src/ContextManager.php, line 130 
Class
- ContextManager
- This is the manager service for the context module.
Namespace
Drupal\contextCode
public function getContexts() {
  if (!empty($this->contexts)) {
    return $this->contexts;
  }
  $this->contexts = $this->entityTypeManager
    ->getStorage('context')
    ->loadByProperties();
  // Sort the contexts by their weight.
  uasort($this->contexts, [
    $this,
    'sortContextsByWeight',
  ]);
  return $this->contexts;
}