You are here

function lightning_layout_layout_alter in Lightning Layout 8.2

Implements hook_layout_alter().

@todo Remove when we require Panels 4.5 or later, since it implements and tests this functionality itself.

File

./lightning_layout.module, line 247
Contains layout functionality for Lightning.

Code

function lightning_layout_layout_alter(array &$definitions) {
  $core_layouts = [
    'layout_onecol',
    'layout_twocol',
    'layout_twocol_bricks',
    'layout_threecol_25_50_25',
    'layout_threecol_33_34_33',
  ];
  foreach ($definitions as $layout_name => $layout) {

    // Verify that the layout definition is a LayoutDefinition
    if (!$definitions[$layout_name] instanceof LayoutDefinition) {
      continue;
    }
    if (in_array($layout_name, $core_layouts) && empty($definitions[$layout_name]
      ->getIcon())) {
      $definitions[$layout_name]
        ->setIconPath(drupal_get_path('module', 'panels') . '/layouts/' . $layout_name . '/' . $layout_name . '.png');
    }
    if (empty($definitions[$layout_name]
      ->getIcon())) {
      $definitions[$layout_name]
        ->setIconPath(drupal_get_path('module', 'panels') . '/layouts/no-layout-preview.png');
    }
  }
}