You are here

function panelizer_update_8401 in Panelizer 8.5

Same name and namespace in other branches
  1. 8.4 panelizer.install \panelizer_update_8401()

Rename layout machine names in config entities to match layout discovery's default layouts.

File

./panelizer.install, line 12
Install, update and uninstall functions for the Panelizer module.

Code

function panelizer_update_8401(&$sandbox) {
  module_load_install('panels');
  $config_factory = \Drupal::configFactory();
  foreach ($config_factory
    ->listAll('core.entity_view_display.') as $entity_display_name) {
    $entity_display = $config_factory
      ->getEditable($entity_display_name);
    if ($displays = $entity_display
      ->get('third_party_settings.panelizer.displays')) {
      foreach ($displays as $display_name => $display) {
        if (isset($display['layout'])) {
          $new_layout = panels_convert_plugin_ids_to_layout_discovery($display['layout']);
          if ($new_layout) {
            $displays[$display_name]['layout'] = $new_layout;
          }
        }
      }
      $entity_display
        ->set('third_party_settings.panelizer.displays', $displays)
        ->save(TRUE);
    }
  }
}