Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SH-5972: Use default Drupal layouts in Dashboard #1697

Merged
1 change: 1 addition & 0 deletions docroot/modules/humsci/hs_layouts/hs_layouts.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ version: 8.2.7
package: 'Humanities & Sciences'
dependencies:
- layout_discovery
- dashboard:dashboard

components:
namespaces:
Expand Down
18 changes: 16 additions & 2 deletions docroot/modules/humsci/hs_layouts/hs_layouts.module
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

use Drupal\Component\Utility\Html;
use Drupal\dashboard\Plugin\SectionStorage\DashboardSectionStorage;
mariannuar marked this conversation as resolved.
Show resolved Hide resolved
use Drupal\paragraphs\ParagraphInterface;

/**
Expand All @@ -14,8 +15,21 @@ use Drupal\paragraphs\ParagraphInterface;
function hs_layouts_plugin_filter_layout__layout_builder_alter(&$definitions, &$extra, &$consumer) {
/** @var \Drupal\Core\Layout\LayoutDefinition $definition */
foreach ($definitions as $id => $definition) {
if ($definition->getProvider() !== 'hs_layouts') {
unset($definitions[$id]);
$provider = $definition->getProvider();
if ($extra['section_storage'] instanceof DashboardSectionStorage) {
// Define providers to unset for the dashboard.
$providers_to_unset = [
'ui_patterns_library',
'hs_layouts',
'ds',
];
if (in_array($provider, $providers_to_unset)) {
unset($definitions[$id]);
}
} else {
if ($provider !== 'hs_layouts') {
unset($definitions[$id]);
}
}
}
}
Expand Down
Loading