You are here

function __flysystem_check_dependencies in Flysystem 8

Same name and namespace in other branches
  1. 3.x flysystem.install \__flysystem_check_dependencies()
  2. 2.0.x flysystem.install \__flysystem_check_dependencies()
  3. 3.0.x flysystem.install \__flysystem_check_dependencies()

Checks that dependencies are installed.

1 call to __flysystem_check_dependencies()
flysystem_requirements in ./flysystem.install
Implements hook_requirements().

File

./flysystem.install, line 57
Install, update and uninstall functions for the flysystem module.

Code

function __flysystem_check_dependencies(array &$requirements) {
  $dependencies = [
    'League\\Flysystem\\Filesystem' => \Drupal::translation()
      ->translate('Flysystem'),
    'League\\Flysystem\\Replicate\\ReplicateAdapter' => \Drupal::translation()
      ->translate('replicate adapter'),
    'Twistor\\FlysystemStreamWrapper' => \Drupal::translation()
      ->translate('stream wrapper'),
  ];
  $missing = array_filter(array_map(function ($dependency) use ($dependencies) {
    return class_exists($dependency) ? FALSE : $dependencies[$dependency];
  }, array_keys($dependencies)));

  // @codeCoverageIgnoreStart
  if ($missing) {
    $requirements['flysystem_dependencies'] = [
      'title' => \Drupal::translation()
        ->translate('Flysystem'),
      'description' => \Drupal::translation()
        ->translate('Dependencies missing: @deps.', [
        '@deps' => implode(', ', $missing),
      ]),
      'severity' => REQUIREMENT_ERROR,
    ];
  }

  // @codeCoverageIgnoreEnd
}