Filter out disabled grid layouts.
function paragraphs_collection_update_8003() {
$config_factory = \Drupal::configFactory();
// Loop over all paragraph types.
foreach ($config_factory
->listAll('paragraphs.paragraphs_type.') as $name) {
$paragraph_type = $config_factory
->getEditable($name);
if ($paragraph_type
->get('behavior_plugins.grid_layout')) {
$available_grid_layouts = $paragraph_type
->get('behavior_plugins.grid_layout.available_grid_layouts');
if (!empty($available_grid_layouts)) {
// Filter out disabled grid layouts.
$paragraph_type
->set('behavior_plugins.grid_layout.available_grid_layouts', array_filter($available_grid_layouts));
$paragraph_type
->save();
}
}
}
}