You are here

function lightning_media_update_8006 in Lightning Media 8.2

Same name and namespace in other branches
  1. 8.4 lightning_media.install \lightning_media_update_8006()
  2. 8 lightning_media.install \lightning_media_update_8006()
  3. 8.3 lightning_media.install \lightning_media_update_8006()

Sets the icon for the media browser's embed button.

1 call to lightning_media_update_8006()
lightning_media_install in ./lightning_media.install
Implements hook_install().

File

./lightning_media.install, line 107
Contains install and update routines for Lightning Media.

Code

function lightning_media_update_8006() {
  $icon = \Drupal::moduleHandler()
    ->getModule('lightning_media')
    ->getPath() . '/images/star.png';
  $fs = \Drupal::service('file_system');
  $destination = file_unmanaged_copy($icon, 'public://' . $fs
    ->basename($icon));
  if ($destination) {
    $file = File::create([
      'uri' => $destination,
    ]);
    $file
      ->save();
    EmbedButton::load('media_browser')
      ->set('icon_uuid', $file
      ->uuid())
      ->save();
  }
}