[beta6] Replace PHP hooks by more themer-friendly solutions

Created on 8 February 2023, almost 2 years ago
Updated 7 December 2023, about 1 year ago

Problem/Motivation

27 hooks in the .theme file is a lot of PHP code for a codebase which must be owned by a front developer.

After an analysis, we understood that every one of those hooks is useful and must stay for now. But we also have to prepare the future.

Hooks which can be kept

  • ui_suite_dsfr_preprocess_pattern_pagination(array &$variables) > we have the same current variable typing issue in Bootstrap 4
  • ui_suite_dsfr_preprocess_pattern_link(array &$variables) > detect external link with UrlHelper
  • ui_suite_dsfr_preprocess_pattern_button(array &$variables) > detect external link with UrlHelper
  • ui_suite_dsfr_preprocess_pattern_footer(array &$variables) > default value related to the current website state
  • ui_suite_dsfr_preprocess_pattern_header(array &$variables) > default value related to the current website state
  • ui_suite_dsfr_preprocess_pattern_consent_banner(array &$variables) > Preview mode adjustment

Hooks which can be kept until we have a better solution

Can be kept until UI Skins is able to manage theming and page layout:

  • ui_suite_dsfr_preprocess_html(&$variables)
  • ui_suite_dsfr_preprocess_page(&$variables)
  • ui_suite_dsfr_form_system_theme_settings_alter(&$form, $form_state)

Can be kept until we add an UI Forms module to UI Suite (see current works on Bootstrap 5):

  • ui_suite_dsfr_form_alter(&$form, &$form_state, $form_id)
  • ui_suite_dsfr_preprocess_input(array &$variables)
  • ui_suite_dsfr_preprocess_select(array &$variables)
  • ui_suite_dsfr_theme_suggestions_form_element_alter(array &$suggestions, array $variables, $hook)
  • ui_suite_dsfr_theme_suggestions_input_alter(&$suggestions, array $variables)
  • ui_suite_dsfr_preprocess_form_element(array &$variables)
  • ui_suite_dsfr_preprocess_fieldset(array &$variables)
  • ui_suite_dsfr_preprocess_form_element_label(array &$variables)
  • ui_suite_dsfr_preprocess_form(&$vars)
  • ui_suite_dsfr_form_search_block_form_alter(&$form, &$form_state)

Can be kept until Reduce preprocess hooks usage by adding add_class() & set_attributes() filters Fixed lands in UI Patterns:

  • ui_suite_dsfr_preprocess_pattern_card(array &$variables)
  • ui_suite_dsfr_preprocess_pattern_quote(array &$variables)
  • ui_suite_dsfr_preprocess_pattern_tile(array &$variables)
  • ui_suite_dsfr_preprocess_pattern_responsive_media(array &$variables)
  • ui_suite_dsfr_preprocess_pattern_breadcrumb(array &$variables)
  • ui_suite_dsfr_preprocess_pattern_summary(array &$variables)
  • ui_suite_dsfr_preprocess_pattern_follow(array &$variables)
  • ui_suite_dsfr_preprocess_pattern_share(array &$variables)

But those related function must be replaced by more generic ones will be replaced more easily later:

  • _ui_suite_dsfr_add_class(&$element, string $class)
  • _ui_suite_dsfr_add_elements_attributes(&$elements)
  • _ui_suite_dsfr_add_link_class(&$element, string $class)

First tasks

Replace those 3 functions and put the issue on hold.

📌 Task
Status

Fixed

Version

1.0

Component

Code

Created by

🇫🇷France pdureau Paris

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024