function populate_published_field in Modal 5.0.x
Same name and namespace in other branches
- 8.3 modal_page.install \populate_published_field()
- 8.2 modal_page.install \populate_published_field()
- 4.0.x modal_page.install \populate_published_field()
- 4.1.x modal_page.install \populate_published_field()
Set field published.
1 call to populate_published_field()
- modal_page_update_8202 in ./
modal_page.install - Implements hook_update_N().
File
- ./
modal_page.install, line 440 - Install, update and uninstall functions for the Modal Page.
Code
function populate_published_field() {
$modals = \Drupal::entityTypeManager()
->getStorage('modal_page_modal')
->loadMultiple();
foreach ($modals as $modal) {
$modal->published
->setValue(TRUE);
if ($modal->type->value == 'page' && empty(trim($modal->pages->value))) {
$modal->published
->setValue(FALSE);
}
if ($modal->type->value == 'parameter' && empty(trim($modal->paramenters->value))) {
$modal->published
->setValue(FALSE);
}
$modal
->save();
}
}