function panels_page_variant_presave in Panels 8.3
Same name and namespace in other branches
- 8.4 panels.module \panels_page_variant_presave()
Implements hook_ENTITY_TYPE_presave().
Now that we have the id for the page variant, we need to set the storage information again.
See also
File
- ./
panels.module, line 61 - panels.module
Code
function panels_page_variant_presave(PageVariantInterface $page_variant) {
if ($page_variant
->getVariantPluginId() == 'panels_variant') {
/** @var \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant $panels_display */
$panels_display = $page_variant
->getVariantPlugin();
// Set the storage info now that we have the id.
$panels_display
->setStorage('page_manager', $page_variant
->id());
// It's ConfigEntityBase::preSave() that copies configuration from plugin
// collections to the config entity, and unfortunately, that runs just
// before invoking hook_entity_presave(). So, we have to copy the
// configuration from $panels_display to $page_variant again manually for
// it to be saved.
$page_variant
->set('variant_settings', $panels_display
->getConfiguration());
}
}