panelizer.install in Panelizer 8.5
Same filename and directory in other branches
Install, update and uninstall functions for the Panelizer module.
File
panelizer.installView source
<?php
/**
* @file
* Install, update and uninstall functions for the Panelizer module.
*/
/**
* Rename layout machine names in config entities to match layout discovery's
* default layouts.
*/
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);
}
}
}
/**
* Implements hook_requirements().
*/
function panelizer_requirements($phase) {
$requirements = [];
if ($phase === 'update') {
$available_modules = Drupal::service('extension.list.module')
->getAllAvailableInfo();
if (!array_key_exists('layout_library', $available_modules)) {
$requirements['panelizer_layout_library_not_installed'] = [
'title' => t('Layout Library module required'),
'description' => t('Panelizer 5.0 requires the <a href="@url">Layout builder library</a> module.', [
'@url' => 'https://drupal.org/project/layout_library',
]),
'severity' => REQUIREMENT_ERROR,
];
}
if (!array_key_exists('core_context', $available_modules)) {
$requirements['panelizer_core_context_not_installed'] = [
'title' => t('Core Context module required'),
'description' => t('Panelizer 5.0 requires the <a href="@url">Core Context</a> module.', [
'@url' => 'https://drpual.org/project/core_context',
]),
'severity' => REQUIREMENT_ERROR,
];
}
}
return $requirements;
}
Functions
Name | Description |
---|---|
panelizer_requirements | Implements hook_requirements(). |
panelizer_update_8401 | Rename layout machine names in config entities to match layout discovery's default layouts. |