Unverified Commit ce769fae authored by Mark Halliwell's avatar Mark Halliwell
Browse files

Issue #3146488 by markcarver, MaddieC: Error: Call to undefined method...


Issue #3146488 by markcarver, MaddieC: Error: Call to undefined method Drupal\Core\File\FileSystem::scanDirectory()

Signed-off-by: default avatarMark Carver <mark.carver@me.com>
parent ca5a2b3a
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -633,17 +633,25 @@ class Bootstrap {
  /**
   * Retrieves the File System service, if it exists.
   *
   * @param string $method
   *   Optional. A specific method on the file system service to check for
   *   its existance.
   *
   * @return \Drupal\Core\File\FileSystemInterface
   *   The File System service, if it exists.
   *   The File System service, if it exists and if $method exists if it was
   *   passed.
   *
   * @deprecated in bootstrap:8.x-3.22 and is removed from bootstrap:5.0.0.
   *   Use the "file_system" service instead.
   * @see https://www.drupal.org/project/bootstrap/issues/3096963
   */
  public static function fileSystem() {
  public static function fileSystem($method = NULL) {
    if (!isset(static::$fileSystem)) {
      static::$fileSystem = \Drupal::hasService('file_system') ? \Drupal::service('file_system') : FALSE;
    }
    if ($method) {
      return static::$fileSystem && method_exists(static::$fileSystem, $method) ? static::$fileSystem : FALSE;
    }
    return static::$fileSystem;
  }

+1 −2
Original line number Diff line number Diff line
@@ -640,7 +640,6 @@ class ProviderBase extends PluginBase implements ProviderInterface {
    // Due to code recursion and the need to keep this code in place for BC
    // reasons, this deprecated message should only be logged and not shown.
    Bootstrap::deprecated(FALSE);
    $fileSystem = Bootstrap::fileSystem();

    // Process API data.
    if ($api = $this->getApi()) {
@@ -648,7 +647,7 @@ class ProviderBase extends PluginBase implements ProviderInterface {

      // FILE_CREATE_DIRECTORY = 1 | FILE_MODIFY_PERMISSIONS = 2.
      $options = 1 | 2;
      if ($fileSystem) {
      if ($fileSystem = Bootstrap::fileSystem('prepareDirectory')) {
        $fileSystem->prepareDirectory($provider_path, $options);
      }
      else {
+3 −4
Original line number Diff line number Diff line
@@ -216,13 +216,12 @@ class CdnProvider extends CdnProviderBase {
   * @todo Import functionality is deprecated, remove in a future release.
   */
  protected function importProviderData(Element $group, FormStateInterface $form_state) {
    $fileSystem = Bootstrap::fileSystem();
    if ($form_state->getValue('clicked_button') === t('Save provider data')->render()) {
      $provider_path = ProviderManager::FILE_PATH;

      // FILE_CREATE_DIRECTORY = 1 | FILE_MODIFY_PERMISSIONS = 2.
      $options = 1 | 2;
      if ($fileSystem) {
      if ($fileSystem = Bootstrap::fileSystem('prepareDirectory')) {
        $fileSystem->prepareDirectory($provider_path, $options);
      }
      else {
@@ -235,7 +234,7 @@ class CdnProvider extends CdnProviderBase {
      if ($import_data = $form_state->getValue('cdn_provider_import_data', FALSE)) {
        // FILE_EXISTS_REPLACE = 1.
        $replace = 1;
        if ($fileSystem) {
        if ($fileSystem = Bootstrap::fileSystem('saveData')) {
          $fileSystem->saveData($import_data, $file, $replace);
        }
        else {
@@ -243,7 +242,7 @@ class CdnProvider extends CdnProviderBase {
        }
      }
      elseif ($file && file_exists($file)) {
        if ($fileSystem) {
        if ($fileSystem = Bootstrap::fileSystem('delete')) {
          $fileSystem->delete($file);
        }
        else {
+1 −1
Original line number Diff line number Diff line
@@ -351,7 +351,7 @@ class Theme {
    $hash = Crypt::generateBase64HashIdentifier($options, [$mask, $path]);

    if (!$cache->has($hash)) {
      if ($fileSystem = Bootstrap::fileSystem()) {
      if ($fileSystem = Bootstrap::fileSystem('scanDirectory')) {
        $files = $fileSystem->scanDirectory($path, $mask, $options);
      }
      else {