public function ContextManager::getContexts in Context 8
Same name and namespace in other branches
- 8.4 src/ContextManager.php \Drupal\context\ContextManager::getContexts()
- 8.0 src/ContextManager.php \Drupal\context\ContextManager::getContexts()
Get all contexts.
Return value
Context[]
2 calls to ContextManager::getContexts()
- ContextManager::evaluateContexts in src/
ContextManager.php - Evaluate all context conditions.
- ContextManager::getContextsByGroup in src/
ContextManager.php - Get all contexts sorted by their group and sorted by their weight inside of each group.
File
- src/
ContextManager.php, line 114
Class
- ContextManager
- This is the manager service for the context module and should not be confused with the built in contexts in Drupal.
Namespace
Drupal\contextCode
public function getContexts() {
$contextIds = $this->entityQuery
->get('context')
->execute();
$contexts = $this->entityManager
->getStorage('context')
->loadMultiple($contextIds);
// Sort the contexts by their weight.
uasort($contexts, [
$this,
'sortContextsByWeight',
]);
return $contexts;
}