-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathDrupalCompatibility.php
More file actions
42 lines (34 loc) · 1.04 KB
/
DrupalCompatibility.php
File metadata and controls
42 lines (34 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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';
/**
* 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),
);
}
}