function easy_breadcrumb_update_8006 in Easy Breadcrumb 2.x
Same name and namespace in other branches
- 8 easy_breadcrumb.install \easy_breadcrumb_update_8006()
Fix configuration.
1 call to easy_breadcrumb_update_8006()
- EasyBreabcrumbConfigureTest::doUpdateTest in tests/
src/ Functional/ EasyBreabcrumbConfigureTest.php - Tests easy_breadcrumb_update_8006().
File
- ./
easy_breadcrumb.install, line 74 - Add installation messages to help users get started and update.
Code
function easy_breadcrumb_update_8006() {
$config = \Drupal::configFactory()
->getEditable(EasyBreadcrumbConstants::MODULE_SETTINGS);
$config
->clear('add_structured_data_jsonld')
->clear('dependencies');
// Add missing keys if not present.
$potentially_missing_keys = [
EasyBreadcrumbConstants::ADD_STRUCTURED_DATA_JSON_LD => FALSE,
EasyBreadcrumbConstants::CAPITALIZATOR_FORCED_WORDS => [],
EasyBreadcrumbConstants::INCLUDE_INVALID_PATHS => FALSE,
EasyBreadcrumbConstants::EXCLUDED_PATHS => '',
EasyBreadcrumbConstants::REPLACED_TITLES => '',
EasyBreadcrumbConstants::CUSTOM_PATHS => '',
EasyBreadcrumbConstants::TITLE_SEGMENT_AS_LINK => FALSE,
];
$data = $config
->get();
foreach ($potentially_missing_keys as $key => $default) {
if (!isset($data[$key])) {
$config
->set($key, $default);
}
}
// Fix variable types.
$config
->set(EasyBreadcrumbConstants::CAPITALIZATOR_FORCED_WORDS_FIRST_LETTER, (bool) $config
->get(EasyBreadcrumbConstants::CAPITALIZATOR_FORCED_WORDS_FIRST_LETTER));
$config
->set(EasyBreadcrumbConstants::CAPITALIZATOR_FORCED_WORDS_CASE_SENSITIVITY, (bool) $config
->get(EasyBreadcrumbConstants::CAPITALIZATOR_FORCED_WORDS_CASE_SENSITIVITY));
$config
->set(EasyBreadcrumbConstants::ADD_STRUCTURED_DATA_JSON_LD, (bool) $config
->get(EasyBreadcrumbConstants::ADD_STRUCTURED_DATA_JSON_LD));
// Change 'capitalizator_ignored_words' and 'capitalizator_forced_words' to be
// lists rather than maps.
$config
->set(EasyBreadcrumbConstants::CAPITALIZATOR_IGNORED_WORDS, array_values($config
->get(EasyBreadcrumbConstants::CAPITALIZATOR_IGNORED_WORDS) ?: []));
$config
->set(EasyBreadcrumbConstants::CAPITALIZATOR_FORCED_WORDS, array_values($config
->get(EasyBreadcrumbConstants::CAPITALIZATOR_FORCED_WORDS) ?: []));
$config
->save(TRUE);
}