Security update for Core, with self-updated composer
[yaffs-website] / vendor / drupal / console-core / src / Bootstrap / DrupalConsoleCore.php
index d35c262e7909e36b59e3a6266a62140ce8ff3eae..6bd718677d8f35490d1dc28eed275f3ec2dbd7a0 100644 (file)
@@ -7,12 +7,14 @@
 
 namespace Drupal\Console\Core\Bootstrap;
 
+use Drupal\Console\Core\Utils\DrupalFinder;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\Config\FileLocator;
 use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
 
 /**
  * Class DrupalConsoleCore
+ *
  * @package Drupal\Console\Core\Bootstrap
  */
 class DrupalConsoleCore
@@ -27,15 +29,26 @@ class DrupalConsoleCore
      */
     protected $appRoot;
 
+    /**
+     * @var DrupalFinder
+     */
+    protected $drupalFinder;
+
     /**
      * DrupalConsole constructor.
-     * @param $root
-     * @param $appRoot
+     *
+     * @param string       $root
+     * @param string       $appRoot
+     * @param DrupalFinder $drupalFinder
      */
-    public function __construct($root, $appRoot = null)
-    {
+    public function __construct(
+        $root,
+        $appRoot = null,
+        DrupalFinder $drupalFinder
+    ) {
         $this->root = $root;
         $this->appRoot = $appRoot;
+        $this->drupalFinder = $drupalFinder;
     }
 
     /**
@@ -45,15 +58,22 @@ class DrupalConsoleCore
     {
         $container = new ContainerBuilder();
         $loader = new YamlFileLoader($container, new FileLocator($this->root));
-        $loader->load($this->root.DRUPAL_CONSOLE_CORE.'/services.yml');
-        if (file_exists($this->root.'/services.yml')) {
-            $loader->load('services.yml');
+
+        if (substr($this->root, -1) === DIRECTORY_SEPARATOR) {
+            $this->root = substr($this->root, 0, -1);
         }
 
-        if (file_exists($this->root.DRUPAL_CONSOLE.'/services-drupal-install.yml')) {
-            $loader->load(
-                $this->root . DRUPAL_CONSOLE . '/services-drupal-install.yml'
-            );
+        $servicesFiles = [
+            $this->root.DRUPAL_CONSOLE_CORE.'services.yml',
+            $this->root.'/services.yml',
+            $this->root.DRUPAL_CONSOLE.'uninstall.services.yml',
+            $this->root.DRUPAL_CONSOLE.'extend.console.uninstall.services.yml'
+        ];
+
+        foreach ($servicesFiles as $servicesFile) {
+            if (file_exists($servicesFile)) {
+                $loader->load($servicesFile);
+            }
         }
 
         $container->get('console.configuration_manager')
@@ -77,12 +97,17 @@ class DrupalConsoleCore
             $consoleRoot
         );
 
+        $container->set(
+            'console.drupal_finder',
+            $this->drupalFinder
+        );
+
         $configurationManager = $container->get('console.configuration_manager');
         $directory = $configurationManager->getConsoleDirectory() . 'extend/';
         $autoloadFile = $directory . 'vendor/autoload.php';
         if (is_file($autoloadFile)) {
             include_once $autoloadFile;
-            $extendServicesFile = $directory . 'extend.console.services.yml';
+            $extendServicesFile = $directory . 'extend.console.uninstall.services.yml';
             if (is_file($extendServicesFile)) {
                 $loader->load($extendServicesFile);
             }