protected function InPlaceEditorDisplayBuilder::getDrupalSettings in Panels 8.3
Same name and namespace in other branches
- 8.4 panels_ipe/src/Plugin/DisplayBuilder/InPlaceEditorDisplayBuilder.php \Drupal\panels_ipe\Plugin\DisplayBuilder\InPlaceEditorDisplayBuilder::getDrupalSettings()
Compiles settings needed for the IPE to function.
Parameters
array $regions: The render array representing regions.
\Drupal\layout_plugin\Plugin\Layout\LayoutInterface $layout: The current layout.
\Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant $panels_display: The Panels display we are editing.
bool $unsaved: Whether or not there are unsaved changes.
Return value
array|bool An associative array representing the contents of drupalSettings, or FALSE if there was an error.
1 call to InPlaceEditorDisplayBuilder::getDrupalSettings()
- InPlaceEditorDisplayBuilder::build in panels_ipe/
src/ Plugin/ DisplayBuilder/ InPlaceEditorDisplayBuilder.php - Renders a Panels display.
File
- panels_ipe/
src/ Plugin/ DisplayBuilder/ InPlaceEditorDisplayBuilder.php, line 96
Class
- InPlaceEditorDisplayBuilder
- The In-place editor display builder for viewing and editing a PanelsDisplayVariant in the same place.
Namespace
Drupal\panels_ipe\Plugin\DisplayBuilderCode
protected function getDrupalSettings(array $regions, LayoutInterface $layout, PanelsDisplayVariant $panels_display, $unsaved) {
$settings = [
'regions' => [],
];
// Add current block IDs to settings sorted by region.
foreach ($regions as $region => $blocks) {
$settings['regions'][$region] = [
'name' => $region,
'label' => '',
'blocks' => [],
];
if (!$blocks) {
continue;
}
/** @var \Drupal\Core\Block\BlockPluginInterface[] $blocks */
foreach ($blocks as $block_uuid => $block) {
$configuration = $block
->getConfiguration();
$plugin_definition = $block
->getPluginDefinition();
$setting = [
'uuid' => $block_uuid,
'label' => $block
->label(),
'id' => $block
->getPluginId(),
'provider' => $configuration['provider'],
'plugin_id' => $plugin_definition['id'],
];
$settings['regions'][$region]['blocks'][$block_uuid] = $setting;
}
}
$storage_type = $panels_display
->getStorageType();
$storage_id = $panels_display
->getStorageId();
// Add the layout information.
$layout_definition = $layout
->getPluginDefinition();
$settings['layout'] = [
'id' => $layout
->getPluginId(),
'label' => $layout_definition['label'],
'original' => TRUE,
];
// Add information about the current user's permissions.
$settings['user_permission'] = [
'change_layout' => $this->panelsStorage
->access($storage_type, $storage_id, 'change layout', $this->account)
->isAllowed(),
'create_content' => $this->account
->hasPermission('administer blocks'),
];
// Add the display variant's config.
$settings['panels_display'] = [
'storage_type' => $storage_type,
'storage_id' => $storage_id,
'id' => $panels_display
->id(),
];
// Inform the App of our saved state.
$settings['unsaved'] = $unsaved;
return $settings;
}