You are here

function content_browser_post_update_default_uuid in Content Browser 8

Update default config with default uuid.

File

./content_browser.post_update.php, line 16
Post update functions for Content Browser.

Code

function content_browser_post_update_default_uuid() {
  $configuration = \Drupal::configFactory()
    ->getEditable('embed.button.content_browser');

  // Default uuid in the config.
  $uuid = 'db2cad05-1e3b-4b35-b163-99d7d036130d';

  // Set file uuid in the config.
  $configuration
    ->set('icon_uuid', $uuid);
  $configuration
    ->save();

  // Load the file_browser_icon form the storage.
  $files = \Drupal::entityTypeManager()
    ->getStorage('file')
    ->loadByProperties([
    'uri' => 'public://content_browser_icon.png',
  ]);
  if (!empty($files)) {
    $file = reset($files);

    // Set file uuid same as default config.
    $file
      ->set('uuid', $uuid);
    $file
      ->save();
  }
}