DrupalKernel.php 22.8 KB
Newer Older
1 2 3 4 5 6 7 8 9
<?php

/**
 * @file
 * Definition of Drupal\Core\DrupalKernel.
 */

namespace Drupal\Core;

10
use Drupal\Core\PhpStorage\PhpStorageFactory;
11
use Drupal\Core\Config\BootstrapConfigStorageFactory;
12
use Drupal\Core\Config\NullStorage;
13
use Drupal\Core\CoreServiceProvider;
14
use Drupal\Core\DependencyInjection\ContainerBuilder;
15
use Drupal\Core\DependencyInjection\ServiceProviderInterface;
16
use Drupal\Core\DependencyInjection\YamlFileLoader;
17
use Drupal\Core\Extension\ExtensionDiscovery;
18
use Drupal\Core\Language\Language;
19
use Symfony\Component\Config\Loader\LoaderInterface;
20
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
21
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
22 23
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
24
use Symfony\Component\HttpKernel\HttpKernelInterface;
25
use Symfony\Component\HttpKernel\TerminableInterface;
26
use Composer\Autoload\ClassLoader;
27 28 29

/**
 * The DrupalKernel class is the core of Drupal itself.
30 31
 *
 * This class is responsible for building the Dependency Injection Container and
32 33 34 35 36 37 38 39
 * also deals with the registration of service providers. It allows registered
 * service providers to add their services to the container. Core provides the
 * CoreServiceProvider, which, in addition to registering any core services that
 * cannot be registered in the core.services.yaml file, adds any compiler passes
 * needed by core, e.g. for processing tagged services. Each module can add its
 * own service provider, i.e. a class implementing
 * Drupal\Core\DependencyInjection\ServiceProvider, to register services to the
 * container, or modify existing services.
40
 */
41 42
class DrupalKernel implements DrupalKernelInterface, TerminableInterface {

43
  const CONTAINER_BASE_CLASS = '\Drupal\Core\DependencyInjection\Container';
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63

  /**
   * Holds the container instance.
   *
   * @var \Symfony\Component\DependencyInjection\ContainerInterface
   */
  protected $container;

  /**
   * The environment, e.g. 'testing', 'install'.
   *
   * @var string
   */
  protected $environment;

  /**
   * Whether the kernel has been booted.
   *
   * @var bool
   */
64
  protected $booted;
65

66 67 68 69
  /**
   * Holds the list of enabled modules.
   *
   * @var array
70 71
   *   An associative array whose keys are module names and whose values are
   *   ignored.
72 73 74
   */
  protected $moduleList;

75
  /**
76
   * List of available modules and installation profiles.
77
   *
78
   * @var \Drupal\Core\Extension\Extension[]
79
   */
80
  protected $moduleData = array();
81 82 83 84 85 86 87 88

  /**
   * PHP code storage object to use for the compiled container.
   *
   * @var \Drupal\Component\PhpStorage\PhpStorageInterface
   */
  protected $storage;

89 90 91
  /**
   * The classloader object.
   *
92
   * @var \Composer\Autoload\ClassLoader
93 94 95
   */
  protected $classLoader;

96 97 98 99 100 101 102 103 104 105 106 107 108 109
  /**
   * Config storage object used for reading enabled modules configuration.
   *
   * @var \Drupal\Core\Config\StorageInterface
   */
  protected $configStorage;

  /**
   * Whether the container can be dumped.
   *
   * @var bool
   */
  protected $allowDumping;

110 111 112 113 114 115 116
  /**
   * Whether the container can be loaded.
   *
   * @var bool
   */
  protected $allowLoading;

117 118 119 120 121 122 123
  /**
   * Whether the container needs to be dumped once booting is complete.
   *
   * @var bool
   */
  protected $containerNeedsDumping;

124
  /**
125 126 127 128 129 130
   * List of discovered services.yml pathnames.
   *
   * This is a nested array whose top-level keys are 'app' and 'site', denoting
   * the origin of a service provider. Site-specific providers have to be
   * collected separately, because they need to be processed last, so as to be
   * able to override services from application service providers.
131 132 133 134 135
   *
   * @var array
   */
  protected $serviceYamls;

136
  /**
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
   * List of discovered service provider class names.
   *
   * This is a nested array whose top-level keys are 'app' and 'site', denoting
   * the origin of a service provider. Site-specific providers have to be
   * collected separately, because they need to be processed last, so as to be
   * able to override services from application service providers.
   *
   * @var array
   */
  protected $serviceProviderClasses;

  /**
   * List of instantiated service provider classes.
   *
   * @see \Drupal\Core\DrupalKernel::$serviceProviderClasses
152 153 154 155 156
   *
   * @var array
   */
  protected $serviceProviders;

157 158 159 160
  /**
   * Constructs a DrupalKernel object.
   *
   * @param string $environment
161 162 163
   *   String indicating the environment, e.g. 'prod' or 'dev'. Used by
   *   Symfony\Component\HttpKernel\Kernel::__construct(). Drupal does not use
   *   this value currently. Pass 'prod'.
164
   * @param \Composer\Autoload\ClassLoader $class_loader
165
   *   (optional) The classloader is only used if $storage is not given or
166 167
   *   the load from storage fails and a container rebuild is required. In
   *   this case, the loaded modules will be registered with this loader in
168
   *   order to be able to find the module serviceProviders.
169 170 171
   * @param bool $allow_dumping
   *   (optional) FALSE to stop the container from being written to or read
   *   from disk. Defaults to TRUE.
172 173 174
   * @param bool $allow_loading
   *   (optional) FALSE to prevent the kernel attempting to read the dependency
   *   injection container from disk. Defaults to $allow_dumping.
175
   */
176
  public function __construct($environment, ClassLoader $class_loader, $allow_dumping = TRUE, $allow_loading = NULL) {
177
    $this->environment = $environment;
178
    $this->booted = FALSE;
179
    $this->classLoader = $class_loader;
180
    $this->allowDumping = $allow_dumping;
181
    $this->allowLoading = isset($allow_loading) ? $allow_loading : $allow_dumping;
182 183
  }

184
  /**
185
   * {@inheritdoc}
186 187 188
   */
  public function boot() {
    if ($this->booted) {
189
      return;
190
    }
191 192
    $this->initializeContainer();
    $this->booted = TRUE;
193 194 195
    if ($this->containerNeedsDumping && !$this->dumpDrupalContainer($this->container, static::CONTAINER_BASE_CLASS)) {
      watchdog('DrupalKernel', 'Container cannot be written to disk');
    }
196 197
  }

198
  /**
199
   * {@inheritdoc}
200
   */
201 202 203 204 205
  public function shutdown() {
    if (FALSE === $this->booted) {
      return;
    }
    $this->booted = FALSE;
206
    $this->container = NULL;
207 208 209 210 211 212 213 214 215 216 217 218 219
  }

  /**
   * {@inheritdoc}
   */
  public function getContainer() {
    return $this->container;
  }

  /**
   * {@inheritdoc}
   */
  public function discoverServiceProviders() {
220
    $this->serviceYamls = array(
221 222
      'app' => array(),
      'site' => array(),
223
    );
224 225 226 227 228 229
    $this->serviceProviderClasses = array(
      'app' => array(),
      'site' => array(),
    );
    $this->serviceYamls['app']['core'] = 'core/core.services.yml';
    $this->serviceProviderClasses['app']['core'] = 'Drupal\Core\CoreServiceProvider';
230

231
    // Retrieve enabled modules and register their namespaces.
232
    if (!isset($this->moduleList)) {
233 234
      $extensions = $this->getConfigStorage()->read('core.extension');
      $this->moduleList = isset($extensions['module']) ? $extensions['module'] : array();
235
    }
236
    $module_filenames = $this->getModuleFileNames();
237
    $this->classLoaderAddMultiplePsr4($this->getModuleNamespacesPsr4($module_filenames));
238

239
    // Load each module's serviceProvider class.
240
    foreach ($this->moduleList as $module => $weight) {
katbailey's avatar
katbailey committed
241
      $camelized = ContainerBuilder::camelize($module);
242 243
      $name = "{$camelized}ServiceProvider";
      $class = "Drupal\\{$module}\\{$name}";
244
      if (class_exists($class)) {
245
        $this->serviceProviderClasses['app'][$module] = $class;
246
      }
247
      $filename = dirname($module_filenames[$module]) . "/$module.services.yml";
248
      if (file_exists($filename)) {
249
        $this->serviceYamls['app'][$module] = $filename;
250
      }
251
    }
252

253
    // Add site-specific service providers.
254
    if (!empty($GLOBALS['conf']['container_service_providers'])) {
255 256 257 258
      foreach ($GLOBALS['conf']['container_service_providers'] as $class) {
        if (class_exists($class)) {
          $this->serviceProviderClasses['site'][] = $class;
        }
259 260
      }
    }
261
    if (!empty($GLOBALS['conf']['container_yamls'])) {
262 263
      $this->serviceYamls['site'] = $GLOBALS['conf']['container_yamls'];
    }
264
    if (file_exists($site_services_yml = conf_path() . '/services.yml')) {
265
      $this->serviceYamls['site'][] = $site_services_yml;
266
    }
267 268 269 270 271
  }

  /**
   * {@inheritdoc}
   */
272 273
  public function getServiceProviders($origin) {
    return $this->serviceProviders[$origin];
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
  }

  /**
   * {@inheritdoc}
   */
  public function terminate(Request $request, Response $response) {
    if (FALSE === $this->booted) {
      return;
    }

    if ($this->getHttpKernel() instanceof TerminableInterface) {
      $this->getHttpKernel()->terminate($request, $response);
    }
  }

  /**
   * {@inheritdoc}
   */
292 293 294 295
  public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = TRUE) {
    if (FALSE === $this->booted) {
      $this->boot();
    }
296

297
    return $this->getHttpKernel()->handle($request, $type, $catch);
298 299
  }

300 301 302 303 304 305
  /**
   * Returns module data on the filesystem.
   *
   * @param $module
   *   The name of the module.
   *
306 307
   * @return \Drupal\Core\Extension\Extension|bool
   *   Returns an Extension object if the module is found, FALSE otherwise.
308 309 310
   */
  protected function moduleData($module) {
    if (!$this->moduleData) {
311
      // First, find profiles.
312 313 314 315 316
      $listing = new ExtensionDiscovery();
      $listing->setProfileDirectories(array());
      $all_profiles = $listing->scan('profile');
      $profiles = array_intersect_key($all_profiles, $this->moduleList);

317 318
      // If a module is within a profile directory but specifies another
      // profile for testing, it needs to be found in the parent profile.
319
      $settings = $this->getConfigStorage()->read('simpletest.settings');
320 321
      $parent_profile = !empty($settings['parent_profile']) ? $settings['parent_profile'] : NULL;
      if ($parent_profile && !isset($profiles[$parent_profile])) {
322 323
        // In case both profile directories contain the same extension, the
        // actual profile always has precedence.
324
        $profiles = array($parent_profile => $all_profiles[$parent_profile]) + $profiles;
325
      }
326 327 328 329 330 331

      $profile_directories = array_map(function ($profile) {
        return $profile->getPath();
      }, $profiles);
      $listing->setProfileDirectories($profile_directories);

332
      // Now find modules.
333
      $this->moduleData = $profiles + $listing->scan('module');
334 335 336 337
    }
    return isset($this->moduleData[$module]) ? $this->moduleData[$module] : FALSE;
  }

338 339
  /**
   * Implements Drupal\Core\DrupalKernelInterface::updateModules().
340 341 342
   *
   * @todo Remove obsolete $module_list parameter. Only $module_filenames is
   *   needed.
343
   */
344
  public function updateModules(array $module_list, array $module_filenames = array()) {
345
    $this->moduleList = $module_list;
346 347
    foreach ($module_filenames as $name => $extension) {
      $this->moduleData[$name] = $extension;
348
    }
349 350 351 352 353 354

    // This method is called whenever the list of modules changed. Therefore
    // disable loading of a dumped container from the disk, because it is
    // guaranteed to be out of date and needs to be rebuilt anyway.
    $this->allowLoading = FALSE;

355 356
    // If we haven't yet booted, we don't need to do anything: the new module
    // list will take effect when boot() is called. If we have already booted,
357
    // then reboot in order to refresh the serviceProvider list and container.
358 359 360 361 362
    if ($this->booted) {
      $this->booted = FALSE;
      $this->boot();
    }
  }
363

364
  /**
365
   * Returns the classname based on environment.
366 367 368 369 370
   *
   * @return string
   *   The class name.
   */
  protected function getClassName() {
371
    $parts = array('service_container', $this->environment);
372 373 374
    return implode('_', $parts);
  }

375 376 377 378 379 380 381 382 383 384 385 386

  /**
   * Returns the kernel parameters.
   *
   * @return array An array of kernel parameters
   */
  protected function getKernelParameters() {
    return array(
      'kernel.environment' => $this->environment,
    );
  }

387 388 389
  /**
   * Initializes the service container.
   */
390
  protected function initializeContainer() {
391
    $this->containerNeedsDumping = FALSE;
392
    $persist = $this->getServicesToPersist();
393
    // The request service requires custom persisting logic, since it is also
394
    // potentially scoped.
395 396 397 398 399 400 401 402
    $request_scope = FALSE;
    if (isset($this->container)) {
      if ($this->container->isScopeActive('request')) {
        $request_scope = TRUE;
      }
      if ($this->container->initialized('request')) {
        $request = $this->container->get('request');
      }
403
    }
404
    $this->container = NULL;
405 406 407
    $class = $this->getClassName();
    $cache_file = $class . '.php';

408
    if ($this->allowLoading) {
409 410
      // First, try to load.
      if (!class_exists($class, FALSE)) {
411
        $this->storage()->load($cache_file);
412 413 414 415 416
      }
      // If the load succeeded or the class already existed, use it.
      if (class_exists($class, FALSE)) {
        $fully_qualified_class_name = '\\' . $class;
        $this->container = new $fully_qualified_class_name;
417
        $this->persistServices($persist);
418 419
      }
    }
420
    if (isset($this->container)) {
421 422
      // All namespaces must be registered before we attempt to use any service
      // from the container.
423
      $this->classLoaderAddMultiplePsr4($this->container->getParameter('container.namespaces'));
424
    }
425
    else {
426
      $this->container = $this->buildContainer();
427
      $this->persistServices($persist);
428

429 430
      if ($this->allowDumping) {
        $this->containerNeedsDumping = TRUE;
431 432 433
      }
    }

434
    $this->container->set('kernel', $this);
435

436 437
    // Set the class loader which was registered as a synthetic service.
    $this->container->set('class_loader', $this->classLoader);
438
    // If we have a request set it back to the new container.
439
    if ($request_scope) {
440
      $this->container->enterScope('request');
441 442
    }
    if (isset($request)) {
443 444
      $this->container->set('request', $request);
    }
445
    \Drupal::setContainer($this->container);
446
  }
447

448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476
  /**
   * Returns service instances to persist from an old container to a new one.
   */
  protected function getServicesToPersist() {
    $persist = array();
    if (isset($this->container)) {
      foreach ($this->container->getParameter('persistIds') as $id) {
        // It's pointless to persist services not yet initialized.
        if ($this->container->initialized($id)) {
          $persist[$id] = $this->container->get($id);
        }
      }
    }
    return $persist;
  }

  /**
   * Moves persistent service instances into a new container.
   */
  protected function persistServices(array $persist) {
    foreach ($persist as $id => $object) {
      // Do not override services already set() on the new container, for
      // example 'service_container'.
      if (!$this->container->initialized($id)) {
        $this->container->set($id, $object);
      }
    }
  }

477 478 479 480 481
  /**
   * Builds the service container.
   *
   * @return ContainerBuilder The compiled service container
   */
482
  protected function buildContainer() {
483
    $this->initializeServiceProviders();
484
    $container = $this->getContainerBuilder();
485
    $container->set('kernel', $this);
486
    $container->setParameter('container.modules', $this->getModulesParameter());
487 488

    // Get a list of namespaces and put it onto the container.
489
    $namespaces = $this->getModuleNamespacesPsr4($this->getModuleFileNames());
490 491 492 493
    // Add all components in \Drupal\Core and \Drupal\Component that have a
    // Plugin directory.
    foreach (array('Core', 'Component') as $parent_directory) {
      $path = DRUPAL_ROOT . '/core/lib/Drupal/' . $parent_directory;
494
      $parent_namespace = 'Drupal\\' . $parent_directory;
495
      foreach (new \DirectoryIterator($path) as $component) {
496
        if (!$component->isDot() && $component->isDir() && is_dir($component->getPathname() . '/Plugin')) {
497
          $namespaces[$parent_namespace . '\\' . $component->getFilename()] = $path . '/' . $component->getFilename();
498 499 500
        }
      }
    }
501 502
    $container->setParameter('container.namespaces', $namespaces);

503 504 505 506 507 508
    // Store the default language values on the container. This is so that the
    // default language can be configured using the configuration factory. This
    // avoids the circular dependencies that would created by
    // \Drupal\language\LanguageServiceProvider::alter() and allows the default
    // language to not be English in the installer.
    $default_language_values = Language::$defaultValues;
509 510 511 512
    if ($system = $this->getConfigStorage()->read('system.site')) {
      if ($default_language_values['id'] != $system['langcode']) {
        $default_language_values = array('id' => $system['langcode'], 'default' => TRUE);
      }
513 514 515
    }
    $container->setParameter('language.default_values', $default_language_values);

516
    // Register synthetic services.
517
    $container->register('class_loader')->setSynthetic(TRUE);
518 519
    $container->register('kernel', 'Symfony\Component\HttpKernel\KernelInterface')->setSynthetic(TRUE);
    $container->register('service_container', 'Symfony\Component\DependencyInjection\ContainerInterface')->setSynthetic(TRUE);
520 521

    // Register application services.
522
    $yaml_loader = new YamlFileLoader($container);
523 524 525 526 527 528 529 530 531 532
    foreach ($this->serviceYamls['app'] as $filename) {
      $yaml_loader->load($filename);
    }
    foreach ($this->serviceProviders['app'] as $provider) {
      if ($provider instanceof ServiceProviderInterface) {
        $provider->register($container);
      }
    }
    // Register site-specific service overrides.
    foreach ($this->serviceYamls['site'] as $filename) {
533 534
      $yaml_loader->load($filename);
    }
535
    foreach ($this->serviceProviders['site'] as $provider) {
536 537 538
      if ($provider instanceof ServiceProviderInterface) {
        $provider->register($container);
      }
539
    }
540 541 542 543 544 545 546 547 548 549 550 551 552

    // Identify all services whose instances should be persisted when rebuilding
    // the container during the lifetime of the kernel (e.g., during a kernel
    // reboot). Include synthetic services, because by definition, they cannot
    // be automatically reinstantiated. Also include services tagged to persist.
    $persist_ids = array();
    foreach ($container->getDefinitions() as $id => $definition) {
      if ($definition->isSynthetic() || $definition->getTag('persist')) {
        $persist_ids[] = $id;
      }
    }
    $container->setParameter('persistIds', $persist_ids);

553
    $container->compile();
554 555
    return $container;
  }
556

557 558 559 560 561 562
  /**
   * Registers all service providers to the kernel.
   *
   * @throws \LogicException
   */
  protected function initializeServiceProviders() {
563 564 565 566 567 568 569 570
    $this->discoverServiceProviders();
    $this->serviceProviders = array(
      'app' => array(),
      'site' => array(),
    );
    foreach ($this->serviceProviderClasses as $origin => $classes) {
      foreach ($classes as $name => $class) {
        $this->serviceProviders[$origin][$name] = new $class;
571 572 573 574
      }
    }
  }

575 576 577 578 579
  /**
   * Gets a new ContainerBuilder instance used to build the service container.
   *
   * @return ContainerBuilder
   */
580
  protected function getContainerBuilder() {
581 582 583
    return new ContainerBuilder(new ParameterBag($this->getKernelParameters()));
  }

584 585 586 587 588 589 590 591 592 593 594 595 596 597 598
  /**
   * Dumps the service container to PHP code in the config directory.
   *
   * This method is based on the dumpContainer method in the parent class, but
   * that method is reliant on the Config component which we do not use here.
   *
   * @param ContainerBuilder $container
   *   The service container.
   * @param string $baseClass
   *   The name of the container's base class
   *
   * @return bool
   *   TRUE if the container was successfully dumped to disk.
   */
  protected function dumpDrupalContainer(ContainerBuilder $container, $baseClass) {
599
    if (!$this->storage()->writeable()) {
600 601 602 603
      return FALSE;
    }
    // Cache the container.
    $dumper = new PhpDumper($container);
604 605
    $class = $this->getClassName();
    $content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass));
606
    return $this->storage()->save($class . '.php', $content);
607 608
  }

609 610 611 612

  /**
   * Gets a http kernel from the container
   *
613
   * @return HttpKernel
614 615 616 617 618
   */
  protected function getHttpKernel() {
    return $this->container->get('http_kernel');
  }

619 620 621 622 623 624 625 626 627 628 629 630
  /**
   * Gets the PHP code storage object to use for the compiled container.
   *
   * @return \Drupal\Component\PhpStorage\PhpStorageInterface
   */
  protected function storage() {
    if (!isset($this->storage)) {
      $this->storage = PhpStorageFactory::get('service_container');
    }
    return $this->storage;
  }

631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649
  /**
   * Returns the active configuration storage to use during building the container.
   *
   * @return \Drupal\Core\Config\StorageInterface
   */
  protected function getConfigStorage() {
    if (!isset($this->configStorage)) {
      // The active configuration storage may not exist yet; e.g., in the early
      // installer. Catch the exception thrown by config_get_config_directory().
      try {
        $this->configStorage = BootstrapConfigStorageFactory::get();
      }
      catch (\Exception $e) {
        $this->configStorage = new NullStorage();
      }
    }
    return $this->configStorage;
  }

650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668
  /**
   * Returns an array of Extension class parameters for all enabled modules.
   *
   * @return array
   */
  protected function getModulesParameter() {
    $extensions = array();
    foreach ($this->moduleList as $name => $weight) {
      if ($data = $this->moduleData($name)) {
        $extensions[$name] = array(
          'type' => $data->getType(),
          'pathname' => $data->getPathname(),
          'filename' => $data->getExtensionFilename(),
        );
      }
    }
    return $extensions;
  }

669
  /**
670 671 672 673 674
   * Gets the file name for each enabled module.
   *
   * @return array
   *   Array where each key is a module name, and each value is a path to the
   *   respective *.module or *.profile file.
675 676 677 678 679
   */
  protected function getModuleFileNames() {
    $filenames = array();
    foreach ($this->moduleList as $module => $weight) {
      if ($data = $this->moduleData($module)) {
680
        $filenames[$module] = $data->getPathname();
681 682 683 684 685
      }
    }
    return $filenames;
  }

686 687 688
  /**
   * Gets the PSR-4 base directories for module namespaces.
   *
689
   * @param string[] $module_file_names
690 691 692
   *   Array where each key is a module name, and each value is a path to the
   *   respective *.module or *.profile file.
   *
693
   * @return string[]
694
   *   Array where each key is a module namespace like 'Drupal\system', and each
695
   *   value is the PSR-4 base directory associated with the module namespace.
696 697 698 699
   */
  protected function getModuleNamespacesPsr4($module_file_names) {
    $namespaces = array();
    foreach ($module_file_names as $module => $filename) {
700
      $namespaces["Drupal\\$module"] = DRUPAL_ROOT . '/' . dirname($filename) . '/src';
701 702 703 704
    }
    return $namespaces;
  }

705 706 707 708 709 710 711 712
  /**
   * Registers a list of namespaces with PSR-4 directories for class loading.
   *
   * @param array $namespaces
   *   Array where each key is a namespace like 'Drupal\system', and each value
   *   is either a PSR-4 base directory, or an array of PSR-4 base directories
   *   associated with this namespace.
   */
713
  protected function classLoaderAddMultiplePsr4(array $namespaces = array()) {
714 715 716 717 718
    foreach ($namespaces as $prefix => $paths) {
      $this->classLoader->addPsr4($prefix . '\\', $paths);
    }
  }

719
}