You are here

public function FlysystemFactory::ensure in Flysystem 3.x

Same name and namespace in other branches
  1. 8 src/FlysystemFactory.php \Drupal\flysystem\FlysystemFactory::ensure()
  2. 7 src/FlysystemFactory.php \Drupal\flysystem\FlysystemFactory::ensure()
  3. 2.0.x src/FlysystemFactory.php \Drupal\flysystem\FlysystemFactory::ensure()
  4. 3.0.x src/FlysystemFactory.php \Drupal\flysystem\FlysystemFactory::ensure()

Calls FlysystemPluginInterface::ensure() on each plugin.

Parameters

bool $force: (optional) Wheter to force the insurance. Defaults to false.

Return value

array Errors keyed by scheme.

File

src/FlysystemFactory.php, line 178

Class

FlysystemFactory
A factory for Flysystem filesystems.

Namespace

Drupal\flysystem

Code

public function ensure($force = FALSE) {
  $errors = [];
  foreach ($this
    ->getSchemes() as $scheme) {
    foreach ($this
      ->getPlugin($scheme)
      ->ensure($force) as $error) {
      $event = new EnsureEvent($scheme, $error['severity'], $error['message'], $error['context']);
      $this->eventDispatcher
        ->dispatch(FlysystemEvents::ENSURE, $event);
      $errors[$scheme][] = $error;
    }
  }
  return $errors;
}