Commit 22a5d3fd authored by Ivica Puljic's avatar Ivica Puljic Committed by Ivica Puljic
Browse files

Issue #3226203 by pivica, Berdir: _bs_base_drupal_scan() should also scan origin of site folder

parent d9e68487
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -5,10 +5,13 @@
 * BS Base drush integration offering various theme management function.
 */

use Drupal\Core\DrupalKernel;
use Drupal\Core\Extension\ExtensionDiscovery;
use Drush\Log\LogLevel;
use Drupal\Component\Serialization\Yaml;
use Drupal\Core\Extension\Discovery\RecursiveExtensionFilterIterator;
use Drupal\Core\Site\Settings;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Generator\UrlGenerator;

/**
@@ -493,8 +496,18 @@ function _bs_base_drupal_scan($type, $reset = FALSE) {
    return $processed_files;
  }

  $searchdirs = [
    ExtensionDiscovery::ORIGIN_SITES_ALL => 'sites/all',
    ExtensionDiscovery::ORIGIN_ROOT => ''
  ];
  if (\Drupal::hasService('kernel')) {
    $searchdirs[ExtensionDiscovery::ORIGIN_SITE] = \Drupal::service('site.path');
  }
  else {
    $searchdirs[ExtensionDiscovery::ORIGIN_SITE] = DrupalKernel::findSitePath(Request::createFromGlobals());
  }

  $files = [];
  static $searchdirs = ['core', 'sites/all', ''];
  foreach ($searchdirs as $dir) {
    $scan_res = _bs_base_drupal_scan_directory($dir);
    // Only return extensions of the requested type.
@@ -590,7 +603,8 @@ function _bs_base_drupal_scan_directory($dir) {
    $extension->type = $type;
    $extension->pathname = $pathname;
    $extension->filename = $filename;
    $extension->subpath = $fileinfo->getSubPath();
    // Add dir to subpath so we can work with multisites also.
    $extension->subpath = (!empty($dir) ? $dir . '/' : '') . $fileinfo->getSubPath();
    // Extension parent folder path.
    $extension->parentPath = substr($fileinfo->getPath(), 0, -(strlen($name) + 1));
    $extension->origin = $dir;