You are here

content_browser.post_update.php in Content Browser 8

Post update functions for Content Browser.

File

content_browser.post_update.php
View source
<?php

/**
 * @file
 * Post update functions for Content Browser.
 */

/**
 * @addtogroup updates-8.x-1.x
 * @{
 */

/**
 * Update default config with default uuid.
 */
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();
  }
}

/**
 * @} End of "addtogroup updates-8.x-1.x".
 */

Functions

Namesort descending Description
content_browser_post_update_default_uuid Update default config with default uuid.