public function ContextManager::getContextsByGroup in Context 8.4
Same name and namespace in other branches
- 8 src/ContextManager.php \Drupal\context\ContextManager::getContextsByGroup()
- 8.0 src/ContextManager.php \Drupal\context\ContextManager::getContextsByGroup()
Get all contexts sorted by their group.
It also sort the contexts by their weight inside of each group.
Return value
array An array with all contexts by group.
File
- src/
ContextManager.php, line 186
Class
- ContextManager
- This is the manager service for the context module.
Namespace
Drupal\contextCode
public function getContextsByGroup() {
$contexts = $this
->getContexts();
$groups = [];
// Add each context to their respective groups.
foreach ($contexts as $context_id => $context) {
$group = $context
->getGroup();
if ($group === Context::CONTEXT_GROUP_NONE) {
$group = 'not_grouped';
}
$groups[$group][$context_id] = $context;
}
return $groups;
}