You are here

function layout_builder_styles_update_8004 in Layout Builder Styles 8

Add newly-available weight value to existing style entities.

File

./layout_builder_styles.install, line 145
Layout Builder Styles install file.

Code

function layout_builder_styles_update_8004() {
  $styles = \Drupal::entityTypeManager()
    ->getStorage('layout_builder_style')
    ->loadByProperties();
  $weight = 0;
  foreach ($styles as $style) {

    // Re-save styles with weight value.
    $style
      ->set('weight', $weight);
    $style
      ->save();
    $weight++;
  }
}