1.20.x layout.api.php hook_layout_revert(Layout $old_layout)

Respond to a layout being reverted.

Layouts can be reverted only if the configuration is provided by a module. Layouts created in the Layout Builder User Interface cannot be reverted. A layout revert operation results in deletion of the existing layout configuration and replacement with the default configuration from the providing module. This hook is invoked from Layout::revert() after a layout has been reverted and the new configuration has been inserted into the live config directory and the layout cache has been cleared.

Parameters

Layout $layout: The old layout object that has just been deleted.

Related topics

File

modules/layout/layout.api.php, line 220
Describe hooks provided by the Layout module.

Code

function hook_layout_revert(Layout $old_layout) {
  if ($old_layout->name == 'my_layout') {
    my_custom_function();
  }
  // Get the new (reverted) configuration.
  $new_config = config_get('layout.layout.' . $old_layout->name);
}