public function ContextGroupsManager::getParams in Context groups 8
Same name and namespace in other branches
- 8.2 src/ContextGroupsManager.php \Drupal\context_groups\ContextGroupsManager::getParams()
Get list of context groups from specified context.
Parameters
Context $context: Context object.
FormStateInterface $form_state: FormState object.
Return value
object Parameters regarding groups in th context.
File
- src/
ContextGroupsManager.php, line 52
Class
- ContextGroupsManager
- Class ContextGroupsManager.
Namespace
Drupal\context_groupsCode
public function getParams(Context $context, FormStateInterface $form_state) {
// Selected theme.
$theme = $this
->getCurrentTheme($form_state);
// Get all context groups.
$groups = $context
->getThirdPartySettings('context_groups');
if (empty($groups)) {
return FALSE;
}
// Filter context groups to only that, which belongs to selected theme.
$group_list[''] = t('None');
foreach ($groups as $group_name => $value) {
if ($value['theme'] == $theme) {
$group_list[$group_name] = $value['label'];
$group_data[$group_name] = $value;
$group_data[$group_name]['id'] = $group_name;
}
}
if (!isset($group_data)) {
return FALSE;
}
$params = new stdClass();
$params->groups = $group_data;
$params->group_list = $group_list;
// Gather groups by regions.
$params->groups_by_region = [];
foreach ($params->groups as $group) {
$params->groups_by_region['region-' . $group['region']][] = $group;
}
return $params;
}