You are here

function paragraphs_collection_update_8003 in Paragraphs Collection 8

Filter out disabled grid layouts.

File

./paragraphs_collection.install, line 79
Installation hooks for paragraphs collection module.

Code

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();
      }
    }
  }
}