public static function BlazyAlter::configSchemaInfoAlter in Blazy 8.2
Implements hook_config_schema_info_alter().
3 calls to BlazyAlter::configSchemaInfoAlter()
- Blazy::configSchemaInfoAlter in src/
Blazy.php - Implements hook_config_schema_info_alter().
- blazy_config_schema_info_alter in ./
blazy.module - Implements hook_config_schema_info_alter().
- blazy_test_config_schema_info_alter in tests/
modules/ blazy_test/ blazy_test.module - Implements hook_config_schema_info_alter().
File
- src/
BlazyAlter.php, line 22
Class
- BlazyAlter
- Provides hook_alter() methods for Blazy.
Namespace
Drupal\blazyCode
public static function configSchemaInfoAlter(array &$definitions, $formatter = 'blazy_base', array $settings = []) {
if (isset($definitions[$formatter])) {
$mappings =& $definitions[$formatter]['mapping'];
$settings = $settings ?: BlazyDefault::extendedSettings() + BlazyDefault::gridSettings();
foreach ($settings as $key => $value) {
// Seems double is ignored, and causes a missing schema, unlike float.
$type = gettype($value);
$type = $type == 'double' ? 'float' : $type;
$mappings[$key]['type'] = $key == 'breakpoints' ? 'mapping' : (is_array($value) ? 'sequence' : $type);
if (!is_array($value)) {
$mappings[$key]['label'] = Unicode::ucfirst(str_replace('_', ' ', $key));
}
}
// @todo remove custom breakpoints anytime before 3.x as per #3105243.
if (isset($mappings['breakpoints'])) {
foreach ([
'xs',
'sm',
'md',
'lg',
'xl',
] as $breakpoint) {
$mappings['breakpoints']['mapping'][$breakpoint]['type'] = 'mapping';
foreach ([
'breakpoint',
'width',
'image_style',
] as $item) {
$mappings['breakpoints']['mapping'][$breakpoint]['mapping'][$item]['type'] = 'string';
$mappings['breakpoints']['mapping'][$breakpoint]['mapping'][$item]['label'] = Unicode::ucfirst(str_replace('_', ' ', $item));
}
}
}
}
}