class UpdateLayoutRequestHandler in Panels 8.3
Same name and namespace in other branches
- 8.4 panels_ipe/src/Helpers/UpdateLayoutRequestHandler.php \Drupal\panels_ipe\Helpers\UpdateLayoutRequestHandler
Hierarchy
- class \Drupal\panels_ipe\Helpers\RequestHandlerBase implements RequestHandlerInterface
- class \Drupal\panels_ipe\Helpers\UpdateLayoutRequestHandler
Expanded class hierarchy of UpdateLayoutRequestHandler
2 files declare their use of UpdateLayoutRequestHandler
- PanelsIPEPageController.php in panels_ipe/
src/ Controller/ PanelsIPEPageController.php - UpdateLayoutRequestHandlerTest.php in tests/
src/ Unit/ panels_ipe/ UpdateLayoutRequestHandlerTest.php
File
- panels_ipe/
src/ Helpers/ UpdateLayoutRequestHandler.php, line 11
Namespace
Drupal\panels_ipe\HelpersView source
class UpdateLayoutRequestHandler extends RequestHandlerBase {
/**
* @inheritdoc
*/
protected function handle(PanelsDisplayVariant $panels_display, $decodedRequest, $save_to_temp_store = FALSE) {
$this
->updateLayout($panels_display, $decodedRequest, $save_to_temp_store);
}
/**
* Changes the layout for the given Panels Display.
*
* @param \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant $panels_display
* @param $layout_model
* @param bool $save_to_temp_store
*/
private function updateLayout(PanelsDisplayVariant $panels_display, $layout_model, $save_to_temp_store = FALSE) {
$panels_display = self::updatePanelsDisplay($panels_display, $layout_model);
$this
->invokeHook('panels_ipe_panels_display_presave', [
$panels_display,
$layout_model,
]);
if ($save_to_temp_store) {
$this
->savePanelsDisplayToTempStore($panels_display);
}
else {
$this
->savePanelsDisplay($panels_display);
}
}
/**
* Updates the current Panels display based on the changes done in our app.
*
* @param \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant $panels_display
* The current Panels display.
* @param array $layout_model
* The decoded LayoutModel from our App.
*
* @return \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant
*/
private static function updatePanelsDisplay(PanelsDisplayVariant $panels_display, array $layout_model) {
// Set our weight and region based on the metadata in our Backbone app.
foreach ($layout_model['regionCollection'] as $region) {
$weight = 0;
foreach ($region['blockCollection'] as $block) {
/** @var \Drupal\Core\Block\BlockBase $block_instance */
$block_instance = $panels_display
->getBlock($block['uuid']);
$block_instance
->setConfigurationValue('region', $region['name']);
$block_instance
->setConfigurationValue('weight', ++$weight);
$panels_display
->updateBlock($block['uuid'], $block_instance
->getConfiguration());
}
}
return $panels_display;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RequestHandlerBase:: |
private | property | @var \Drupal\Core\Extension\ModuleHandlerInterface | |
RequestHandlerBase:: |
private | property | @var \Drupal\panels\Storage\PanelsStorageManagerInterface | |
RequestHandlerBase:: |
private | property | @var array | |
RequestHandlerBase:: |
private | property | @var int | |
RequestHandlerBase:: |
private | property | @var \Drupal\user\SharedTempStore | |
RequestHandlerBase:: |
protected static | function | Attempts to decode the incoming request's content as JSON. | |
RequestHandlerBase:: |
protected | function | Deletes the given Panels Display from TempStore. | |
RequestHandlerBase:: |
public | function |
Returns the current response data as a JSON Response. Overrides RequestHandlerInterface:: |
|
RequestHandlerBase:: |
public | function |
@inheritdoc Overrides RequestHandlerInterface:: |
|
RequestHandlerBase:: |
protected | function | Helper function for invoking hooks for all enabled modules. | |
RequestHandlerBase:: |
protected | function | Deletes TempStore and saves the current Panels display. | |
RequestHandlerBase:: |
protected | function | Saves the given Panels Display to TempStore. | |
RequestHandlerBase:: |
protected | function | Updates our response and response status code properties. | |
RequestHandlerBase:: |
public | function | ||
UpdateLayoutRequestHandler:: |
protected | function |
@inheritdoc Overrides RequestHandlerBase:: |
|
UpdateLayoutRequestHandler:: |
private | function | Changes the layout for the given Panels Display. | |
UpdateLayoutRequestHandler:: |
private static | function | Updates the current Panels display based on the changes done in our app. |