-
Notifications
You must be signed in to change notification settings - Fork 13
OEL-4511: Update to Drupal 11.3.x. #541
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
base: 1.x
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,6 +86,7 @@ toolkit: | |
| - ~10.5.0 | ||
| - ~10.6.0 | ||
| - ~11.2.0 | ||
| - ~11.3.0 | ||
| PUBLISH: false | ||
| BEHAT: false | ||
| PHPUNIT: true | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Drupal\oe_bootstrap_theme; | ||
|
|
||
| use Drupal\Component\Utility\DeprecationHelper; | ||
|
|
||
| /** | ||
| * Handles Drupal core compatibility behaviors. | ||
| */ | ||
| final class DrupalCompatibility { | ||
|
|
||
| /** | ||
| * Service id for the Drupal 11.3+ theme settings provider. | ||
| */ | ||
| private const THEME_SETTINGS_PROVIDER_SERVICE = 'Drupal\\Core\\Extension\\ThemeSettingsProvider'; | ||
|
|
||
| /** | ||
| * Core version where ThemeSettingsProvider::getSetting() should be used. | ||
| */ | ||
| private const THEME_SETTINGS_PROVIDER_VERSION = '11.3.0'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see a value of having this in a constant. |
||
|
|
||
| /** | ||
| * Gets a theme setting across supported Drupal core versions. | ||
| * | ||
| * @param string $setting | ||
| * The setting name. | ||
| * | ||
| * @return mixed | ||
| * The setting value. | ||
| */ | ||
| public static function themeGetSetting(string $setting): mixed { | ||
| return DeprecationHelper::backwardsCompatibleCall( | ||
| \Drupal::VERSION, | ||
| self::THEME_SETTINGS_PROVIDER_VERSION, | ||
| fn () => \Drupal::service(self::THEME_SETTINGS_PROVIDER_SERVICE)->getSetting($setting), | ||
| fn () => theme_get_setting($setting), | ||
| ); | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
|
|
||
| use Drupal\Core\Form\FormStateInterface; | ||
| use Drupal\oe_bootstrap_theme\BackwardCompatibility; | ||
| use Drupal\oe_bootstrap_theme\DrupalCompatibility; | ||
|
|
||
| /** | ||
| * Implements hook_form_system_theme_settings_alter(). | ||
|
|
@@ -25,7 +26,7 @@ function oe_bootstrap_theme_form_system_theme_settings_alter(&$form, FormStateIn | |
| '#type' => 'checkbox', | ||
| '#title' => t('Style all tables using Bootstrap.'), | ||
| '#description' => t('Applies Bootstrap classes to all tables rendered using this theme. Note that some table instances (such as calendars) might not render correctly when Bootstrap is applied to them.'), | ||
| '#default_value' => theme_get_setting('bootstrap_tables.enable'), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am sorry for my dead-end and wrong advice earlier. I tried this with both 11.3 and 11.2. The reason this works is that I also found that
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another interesting fact: ThemeSettingsForm extends ConfigFormBase, which has its own mechanism to read form values and write them to config on submit. To do that, it looks at the ThemeSettingsForm calls the parent submit method, but that is completely pointless, because generally none of the elements have #config_target. Olivero sets #config_target to e.g. olivero.settings:site_branding_bg_color, which is wrong. |
||
| '#default_value' => DrupalCompatibility::themeGetSetting('bootstrap_tables.enable'), | ||
| ]; | ||
|
|
||
| $form['bootstrap_tables']['responsive'] = [ | ||
|
|
@@ -41,7 +42,7 @@ function oe_bootstrap_theme_form_system_theme_settings_alter(&$form, FormStateIn | |
| 'xxl' => t('Extra extra large'), | ||
| ], | ||
| '#empty_option' => t('Never'), | ||
| '#default_value' => theme_get_setting('bootstrap_tables.responsive') ?? '', | ||
| '#default_value' => DrupalCompatibility::themeGetSetting('bootstrap_tables.responsive') ?? '', | ||
| ]; | ||
|
|
||
| $form['backward_compatibility'] = [ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need for this constant.
Also we should import the class and use
ThemeSettingsProvider::class.Actually the earlier version was fine, where we had
\Drupal::service(ThemeSettingsProvider::class).Or was there a problem?