function hook_blazy_base_settings_alter in Blazy 8
Same name and namespace in other branches
- 8.2 blazy.api.php \hook_blazy_base_settings_alter()
- 7 blazy.api.php \hook_blazy_base_settings_alter()
Alters blazy-related formatter form options to make site-builders happier.
A less robust alternative to third party settings to pass the options to blazy-related formatters within the designated compact form. While third party settings offer more fine-grained control over a specific formatter, this offers a swap to various blazy-related formatters at one go. Any class extending \Drupal\blazy\BlazyDefault will be capable to modify both form and UI options at one go.
This requires 4 things: option definitions (this alter), schema, extended forms, and front-end implementation of the provided options which can be done via regular hook_preprocess().
Accordingly update the schema via core hook_config_schema_info_alter(), or regular module.schema.yml file to have a valid schema.
function hook_config_schema_info_alter(array &$definitions) {
$settings = [
'color' => '',
'arrowpos' => '',
'dotpos' => '',
];
Blazy::configSchemaInfoAlter($definitions, 'slick_base', SlickDefault::extendedSettings() + $settings);
}
In addition to the schema, implement hook_blazy_complete_form_element_alter() to provide the actual extended forms, see far below. And lastly, implement the options at front-end via hook_preprocess().
Parameters
array $settings: The settings being modified.
array $context: The array containing class which defines or limit the scope of the options.
Related topics
1 invocation of hook_blazy_base_settings_alter()
- BlazyDefault::alterableSettings in src/
BlazyDefault.php - Returns alterable plugin settings to pass the tests.
File
- ./
blazy.api.php, line 216 - Hooks and API provided by the Blazy module.
Code
function hook_blazy_base_settings_alter(array &$settings, array $context = []) {
// One override for both various Slick field formatters and Slick views style.
// SlickDefault extends BlazyDefault, hence capable to modify/ extend options.
// These options will be available at many Slick formatters at one go.
if ($context['class'] == 'Drupal\\slick\\SlickDefault') {
$settings += [
'color' => '',
'arrowpos' => '',
'dotpos' => '',
];
}
}