public function DynamicLayoutSettings::purgeColumnWidthNumbers in Dynamic Layouts 8
Purge all column width numbers from all rows.
This is needed if the frontend library is changed.
Parameters
string $last_column_number: The last column number we need to set when purging the old classes.
string $new_column_prefix: The new column prefix.
Overrides DynamicLayoutSettingsInterface::purgeColumnWidthNumbers
File
- src/
Entity/ DynamicLayoutSettings.php, line 168
Class
- DynamicLayoutSettings
- Defines the DynamicLayoutSettings entity.
Namespace
Drupal\dynamic_layouts\EntityCode
public function purgeColumnWidthNumbers($last_column_number, $new_column_prefix = '') {
if (!($layout_config_entities = \Drupal::entityTypeManager()
->getStorage('dynamic_layout')
->loadMultiple())) {
return NULL;
}
/* @var \Drupal\dynamic_layouts\DynamicLayoutInterface $layout_config_entity */
foreach ($layout_config_entities as $layout_config_entity) {
// Loop over the rows and their columns.
$rows = $layout_config_entity
->getRows();
if ($rows) {
foreach ($rows as $row_key => $row) {
$columns = $row[Constants::COLUMNS];
foreach ($columns as $column_key => $column) {
$rows[$row_key][Constants::COLUMNS][$column_key]['column_width_number'] = $last_column_number;
if ($new_column_prefix) {
$rows[$row_key][Constants::COLUMNS][$column_key]['column_width_prefix'] = $new_column_prefix;
}
if (isset($rows[$row_key][Constants::COLUMNS][$column_key]['custom_column_width_number'])) {
unset($rows[$row_key][Constants::COLUMNS][$column_key]['custom_column_width_number']);
}
}
}
}
$layout_config_entity->regions = serialize($rows);
$layout_config_entity
->save();
}
}