function panels_everywhere_page_variant_presave in Panels Everywhere 8.4
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_everywhere.module, line 33
Code
function panels_everywhere_page_variant_presave(PageVariantInterface $page_variant) {
if ($page_variant
->getVariantPluginId() == 'panels_everywhere_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());
}
}