- Issue created by @mvonfrie
- 🇦🇹Austria mvonfrie
This might be related to ✨ Dashboards should have the ability to customize path (alias) Postponed and require a meta discussion before implementation.
Even if the Dashboard is a config entity type, it should support the common entity hooks. For example I need to add some extra styling to the dashboards, no matter whether they are displayed with the admin theme (Gin) or the custom theme. Because of that I need to apply the extra styling via a module and libraries-extend
only works for themes.
As the Dashboard entity doesn't support the hook_prepocess_HOOK() to attach a library with the custom styling, the only possibility which works is
/**
* Implements hook_preprocess_HOOK().
*/
function mymodule_preprocess_container(array &$variables): void {
$libraries = $variables['element']['#attached']['library'] ?? [];
if (in_array('dashboard/dashboard', $libraries)) {
// Note!
// Adding a library to $variables['element']['#attached']['library'] doesn't work, only
// to $variables['#attached']['library'].
$variables['#attached']['library'][] = 'mymodule/dashboard';
}
}
which is very strange and hacky as I have to preprocess the container, test it's element having the dashboard/dashboard
library and if so attach my custom library. But to make it even weirder, I cannot attach my library to the container element as that already has been processed, but only on the container directly.
Maybe I could implement hook_page_attachments_alter() and attach my library there if the dashboard/dashboard is present. But that would make it even harder if I needed to attach it only to specific dashboards.
Implement the common hooks for the Dashboard entity type, such as hook_preprocess_HOOK()
or hook_entity_view()
(and related ones).
Active
2.0
Code
This might be related to ✨ Dashboards should have the ability to customize path (alias) Postponed and require a meta discussion before implementation.