You are here

function dropdown_language_update_8201 in Dropdown Language 3.0.x

Same name and namespace in other branches
  1. 8.2 dropdown_language.install \dropdown_language_update_8201()

Update labels block schema.

File

./dropdown_language.install, line 13
Install, update, and uninstall functions for dropdown_language.

Code

function dropdown_language_update_8201() {

  /** @var \Drupal\block\Entity\Block[] $blocks */
  $blocks = \Drupal::entityTypeManager()
    ->getStorage('block')
    ->loadByProperties([
    'plugin' => 'dropdown_language:language_interface',
  ]);
  foreach ($blocks as $block) {
    $settings = $block
      ->get('settings');
    if ($settings['labels'] === NULL) {
      $settings['labels'] = [];
      $block
        ->set('settings', $settings);
      $block
        ->save();
    }
  }
}