public function PanelsIPEPageController::getLayoutsData in Panels 8.4
Gets a list of available Layouts as a data array.
Parameters
string $panels_storage_type: The id of the storage plugin.
string $panels_storage_id: The id within the storage plugin for the requested Panels display.
Return value
array
1 call to PanelsIPEPageController::getLayoutsData()
- PanelsIPEPageController::getLayouts in panels_ipe/
src/ Controller/ PanelsIPEPageController.php - Gets a list of available Layouts as JSON.
File
- panels_ipe/
src/ Controller/ PanelsIPEPageController.php, line 164
Class
- PanelsIPEPageController
- Contains all JSON endpoints required for Panels IPE + Page Manager.
Namespace
Drupal\panels_ipe\ControllerCode
public function getLayoutsData($panels_storage_type, $panels_storage_id) {
$panels_display = $this
->loadPanelsDisplay($panels_storage_type, $panels_storage_id);
// Get the current layout.
$current_layout_id = $panels_display
->getLayout()
->getPluginId();
// Get a list of all available layouts.
$layouts = $this->layoutPluginManager
->getDefinitions();
$base_path = base_path();
$data = [];
foreach ($layouts as $id => $layout) {
$icon = $layout
->getIconPath() ?: drupal_get_path('module', 'panels') . '/layouts/no-layout-preview.png';
$data[] = [
'id' => $id,
'label' => $layout
->getLabel(),
'icon' => $base_path . $icon,
'current' => $id == $current_layout_id,
'category' => $layout
->getCategory(),
];
}
// Trigger hook_panels_ipe_layouts_alter(). Allows other modules to change
// the list of layouts that are visible.
\Drupal::moduleHandler()
->alter('panels_ipe_layouts', $data, $panels_display);
// Reindex the blocks after they were altered in case one of them was
// removed.
$data = array_values($data);
return $data;
}