public function BlazyManager::typecast in Blazy 7
Typecast the needed settings, blazy-related module can override.
Performance wise, typecasting should be at the form submit as calling self::config() can be called multiple times. See sample below.
Overrides BlazyManagerBase::typecast
See also
Drupal\blazy_ui\Form\BlazySettingsForm::submitForm()
Drupal\slick_ui\Form\SlickSettingsForm::submitForm()
File
- src/
BlazyManager.php, line 24
Class
- BlazyManager
- Implements a public facing blazy manager.
Namespace
Drupal\blazyCode
public function typecast(array &$config, $id = 'blazy.settings') {
if ($id == 'blazy.settings') {
$defaults = BlazyDefault::formSettings();
foreach ($defaults as $key => $value) {
if (isset($config[$key])) {
if ($key == 'blazy' || $key == 'io') {
foreach ($defaults[$key] as $k => $v) {
settype($config[$key][$k], gettype($v));
}
}
elseif ($key == 'filters') {
foreach ($defaults[$key] as $k => $v) {
// Has nested array [filters][format][grid|column|media_switch].
foreach ($config[$key] as $sk => $format) {
foreach ($format as $ssk => $ignore) {
settype($config[$key][$sk][$ssk], gettype($v));
}
}
}
}
else {
settype($config[$key], gettype($value));
}
}
}
}
}