Allow modules to define dashboard groups per layout region.

This commit is contained in:
paul121 2020-12-16 15:22:59 -08:00 committed by Michael Stenta
parent ae22af2c56
commit b66f0db401
2 changed files with 36 additions and 1 deletions

View File

@ -57,6 +57,40 @@ function hook_farm_dashboard_panes() {
];
}
/**
* Defines farm dashboard groups.
*
* @return array
* Returns an array of farm dashboard groups keyed by layout region.
*/
function hook_farm_dashboard_groups() {
return [
// Returns an associate array keyed by the layout region.
// Options are top, first, second, or bottom.
'first' => [
// Groups are defined as a render array keyed with a unique group
// machine name.
'my_group' => [
// The type. Defaults to container.
'#type' => 'details',
// Optionally specify a title.
'#title' => t('My group title'),
// Optionally specify a weight for sorting.
'#weight' => 100,
],
],
'bottom' => [
// Define groups for the bottom layout region.
],
];
}
/**
* @} End of "addtogroup hooks".
*/

View File

@ -47,7 +47,8 @@ class DashboardController extends ControllerBase {
public function dashboard() {
// Start a build array.
$build = [];
// Ask modules for dashboard groups.
$build = $this->moduleHandler()->invokeAll('farm_dashboard_groups');
// Ask modules for dashboard panes.
$panes = $this->moduleHandler()->invokeAll('farm_dashboard_panes');