You are here

function bynder_lightning_install in Bynder 8

Same name and namespace in other branches
  1. 8.3 modules/lightning/bynder_lightning.install \bynder_lightning_install()
  2. 8.2 modules/lightning/bynder_lightning.install \bynder_lightning_install()
  3. 4.0.x modules/lightning/bynder_lightning.install \bynder_lightning_install()

Implements hook_install().

File

modules/lightning/bynder_lightning.install, line 31
Install, uninstall and update hooks for Bynder Lighting module.

Code

function bynder_lightning_install() {

  /** @var \Drupal\entity_browser\Entity\EntityBrowser $browser */
  $browser = \Drupal::entityTypeManager()
    ->getStorage('entity_browser')
    ->load('media_browser');
  $widget_manager = \Drupal::getContainer()
    ->get('plugin.manager.entity_browser.widget');
  $bynder_upload = $widget_manager
    ->getDefinition('bynder_upload');
  $bynder_search = $widget_manager
    ->getDefinition('bynder_search');
  $browser
    ->addWidget([
    'id' => $bynder_upload['id'],
    'label' => $bynder_upload['label'],
    'weight' => -10,
    'settings' => [
      'media_bundle' => 'bynder',
    ],
  ]);
  $browser
    ->addWidget([
    'id' => $bynder_search['id'],
    'label' => $bynder_search['label'],
    'weight' => -20,
    'settings' => [
      'media_bundle' => 'bynder',
    ],
  ]);
  $browser
    ->save();
}