Skip to content
Snippets Groups Projects

fix: [#3436043] Update y styles defaults

Merged Avi Schwab requested to merge issue/y_facility-3436043:3436043-y-styles-defaults into 1.1.x
1 file
+ 38
0
Compare changes
  • Side-by-side
  • Inline
+ 38
0
@@ -152,6 +152,10 @@ function _y_facility_update_displays_on_install() {
->setThirdPartySetting('y_lb', 'styles', [
'colorway' => 'ws_colorway_blue',
'border_radius' => 'ws_border_radius_none',
'border_style_global' => 'ws_border_style_global_drop_shadow',
'text_alignment_global' => 'ws_text_alignment_global_left',
'button_position_global' => 'ws_button_position_global_inside',
'button_fill_global' => 'ws_button_fill_global_filled',
])
->setThirdPartySetting('layout_builder_restrictions', 'entity_view_mode_restriction', [
'allowed_layouts' => [
@@ -511,3 +515,37 @@ function y_facility_update_9003(&$sandbox = NULL) {
function y_facility_update_9004(&$sandbox = NULL) {
_y_facility_update_field_and_create();
}
/**
* Update default Y styles options if they're empty.
*/
function y_facility_update_9005(&$sandbox = NULL) {
$entity_display_repository = \Drupal::service('entity_display.repository');
// Update Facility content type style defaults.
$view_modes = $entity_display_repository
->getViewModeOptionsByBundle('node', 'facility');
foreach (array_keys($view_modes) as $view_mode) {
/** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $view_display */
$view_display = $entity_display_repository->getViewDisplay('node', 'facility', $view_mode);
if ($view_mode == 'full') {
$styles = $view_display->getThirdPartySetting('y_lb', 'styles');
$default_styles = [
'colorway' => 'ws_colorway_blue',
'border_radius' => 'ws_border_radius_none',
'border_style_global' => 'ws_border_style_global_drop_shadow',
'text_alignment_global' => 'ws_text_alignment_global_left',
'button_position_global' => 'ws_button_position_global_inside',
'button_fill_global' => 'ws_button_fill_global_filled',
];
// Merge the existing styles into the default. Any exising settings will
// override the defaults. NULL values will be filtered out.
$styles = array_merge($default_styles, array_filter($styles));
$view_display
->setThirdPartySetting('y_lb', 'styles', $styles);
}
$view_display->save();
}
}
Loading