You are here

function panels_everywhere_update_8400 in Panels Everywhere 8.4

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

File

./panels_everywhere.install, line 16
Install, update, etc hooks for Panels Everywhere.

Code

function panels_everywhere_update_8400() {
  $names = \Drupal::configFactory()
    ->listAll('page_manager.page_variant');
  foreach ($names as $name) {
    $config = \Drupal::configFactory()
      ->getEditable($name);
    if ($config
      ->get('variant') === 'panels_everywhere_variant') {
      module_load_install('panels');
      if (!function_exists('panels_convert_plugin_ids_to_layout_discovery')) {
        throw new \Exception('Panels helper function does not exist, the latest Panels 4.x-dev snapshot is required to run this update.');
      }
      $layout_id = $config
        ->get('variant_settings.layout');
      if ($new_layout_id = panels_convert_plugin_ids_to_layout_discovery($layout_id)) {
        $config
          ->set('variant_settings.layout', $new_layout_id);
        $config
          ->save();
      }
    }
  }
}