public function PanelsIPEPageController::getLayouts in Panels 8.3
Same name and namespace in other branches
- 8.4 panels_ipe/src/Controller/PanelsIPEPageController.php \Drupal\panels_ipe\Controller\PanelsIPEPageController::getLayouts()
Gets a list of available Layouts, without wrapping HTML.
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
\Symfony\Component\HttpFoundation\JsonResponse
1 string reference to 'PanelsIPEPageController::getLayouts'
- panels_ipe.routing.yml in panels_ipe/
panels_ipe.routing.yml - panels_ipe/panels_ipe.routing.yml
File
- panels_ipe/
src/ Controller/ PanelsIPEPageController.php, line 166
Class
- PanelsIPEPageController
- Contains all JSON endpoints required for Panels IPE + Page Manager.
Namespace
Drupal\panels_ipe\ControllerCode
public function getLayouts($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 = !empty($layout['icon']) ? $layout['icon'] : drupal_get_path('module', 'panels') . '/images/no-layout-preview.png';
$data[] = [
'id' => $id,
'label' => $layout['label'],
'icon' => $base_path . $icon,
'current' => $id == $current_layout_id,
'category' => $layout['category'],
];
}
// Return a structured JSON response for our Backbone App.
return new JsonResponse($data);
}