You are here

function lightning_media_requirements in Lightning Media 8.3

Same name and namespace in other branches
  1. 8.4 lightning_media.install \lightning_media_requirements()

Alerts users of Libraries API dependencies.

A future version of Lightning Media will remove Libraries API, so users must add that dependency to composer.json manually.

@todo Remove this function when Libraries API is no longer shipped with Lightning Media.

File

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

Code

function lightning_media_requirements() {
  $requirements = [];
  $libraries_dependencies = [];
  $enabled_modules = \Drupal::service('extension.list.module')
    ->getAllInstalledInfo();
  foreach ($enabled_modules as $module => $info) {
    if (isset($info['dependencies']) && array_intersect($info['dependencies'], [
      'libraries:libraries',
      'libraries',
    ])) {
      $libraries_dependencies[$module] = $info['name'];
    }
  }
  if ($libraries_dependencies) {
    $requirements['lightning_libraries'] = [
      'title' => t('Libraries API dependencies'),
      'value' => t('These modules require Libraries API: %module_list. Lightning Media 4.0 will <strong>not</strong> include Libraries API as a dependency, so you must add that dependency to your composer.json manually. For example: <code>composer require drupal/libraries</code>.', [
        '%module_list' => Element::oxford($libraries_dependencies),
      ]),
      'severity' => REQUIREMENT_WARNING,
    ];
  }
  return $requirements;
}