function modal_page_update_40009 in Modal 4.0.x
Same name and namespace in other branches
- 4.1.x modal_page.install \modal_page_update_40009()
Update the "Languages to Show" field baseed on the old "language" field.
File
- ./
modal_page.install, line 555 - Install, update and uninstall functions for the Modal Page.
Code
function modal_page_update_40009() {
// Load all Modals.
$modals = \Drupal::entityTypeManager()
->getStorage('modal')
->loadMultiple();
foreach ($modals as $modal) {
// If there is no language code, skip.
if (empty($modal
->getlangcode())) {
continue;
}
// Get the Modal's language code.
$langCode = $modal
->getlangcode();
// Get Languages to Show.
$languagesToShow = $modal
->getLanguagesToShow();
// Include the new lang code.
$languagesToShow[$langCode] = $langCode;
// Store the new value.
$modal
->setLanguagesToShow($languagesToShow);
// Modal Save.
$modal
->save();
}
}