X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrupal%2Fconsole%2Fsrc%2FBootstrap%2FDrupal.php;h=48ba2fe58cacda1de95a59a6dd46841eda884ff3;hp=b1776756255a45e16d7b9395b805a50b61c11840;hb=eba34333e3c89f208d2f72fa91351ad019a71583;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae diff --git a/vendor/drupal/console/src/Bootstrap/Drupal.php b/vendor/drupal/console/src/Bootstrap/Drupal.php index b17767562..48ba2fe58 100644 --- a/vendor/drupal/console/src/Bootstrap/Drupal.php +++ b/vendor/drupal/console/src/Bootstrap/Drupal.php @@ -10,37 +10,52 @@ use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Core\Utils\ArgvInputReader; use Drupal\Console\Core\Bootstrap\DrupalConsoleCore; use Drupal\Console\Utils\ExtendExtensionManager; +use Drupal\Console\Core\Utils\DrupalFinder; class Drupal { protected $autoload; - protected $root; - protected $appRoot; + + /** + * @var DrupalFinder + */ + protected $drupalFinder; /** * Drupal constructor. * * @param $autoload - * @param $root - * @param $appRoot + * @param $drupalFinder */ - public function __construct($autoload, $root, $appRoot) + public function __construct($autoload, DrupalFinder $drupalFinder) { $this->autoload = $autoload; - $this->root = $root; - $this->appRoot = $appRoot; + $this->drupalFinder = $drupalFinder; } - public function boot($debug) + public function boot() { $output = new ConsoleOutput(); $input = new ArrayInput([]); $io = new DrupalStyle($input, $output); $argvInputReader = new ArgvInputReader(); + $command = $argvInputReader->get('command'); + $uri = $argvInputReader->get('uri'); + $debug = $argvInputReader->get('debug', false); + + if ($debug) { + $binaryPath = $this->drupalFinder->getVendorDir() . + '/drupal/console/bin/drupal'; + $io->writeln("Per-Site path: $binaryPath"); + $io->newLine(); + } if (!class_exists('Drupal\Core\DrupalKernel')) { - $io->error('Class Drupal\Core\DrupalKernel do not exists.'); - $drupal = new DrupalConsoleCore($this->root, $this->appRoot); + $io->error('Class Drupal\Core\DrupalKernel does not exist.'); + $drupal = new DrupalConsoleCore( + $this->drupalFinder->getComposerRoot(), + $this->drupalFinder->getDrupalRoot() + ); return $drupal->boot(); } @@ -57,8 +72,7 @@ class Drupal $_SERVER['DEVDESKTOP_DRUPAL_SETTINGS_DIR'] = $devDesktopSettingsDir; } } - $argvInputReader = new ArgvInputReader(); - $command = $argvInputReader->get('command'); + $rebuildServicesFile = false; if ($command=='cache:rebuild' || $command=='cr') { $rebuildServicesFile = true; @@ -67,27 +81,30 @@ class Drupal if ($debug) { $io->writeln('➤ Creating request'); } - $uri = $argvInputReader->get('uri'); - if ($uri && $uri != 'http://default') { - if (substr($uri, -1) != '/') { - $uri .= '/'; - } - $uri .= 'index.php'; - $request = Request::create($uri, 'GET', [], [], [], ['SCRIPT_NAME' => $this->appRoot . '/index.php']); - } else { - $request = Request::createFromGlobals(); - } + + $_SERVER['HTTP_HOST'] = parse_url($uri, PHP_URL_HOST); + $_SERVER['SERVER_PORT'] = null; + $_SERVER['REQUEST_URI'] = '/'; + $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; + $_SERVER['REQUEST_METHOD'] = 'GET'; + $_SERVER['SERVER_SOFTWARE'] = null; + $_SERVER['HTTP_USER_AGENT'] = null; + $_SERVER['PHP_SELF'] = $_SERVER['REQUEST_URI'] . 'index.php'; + $_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF']; + $_SERVER['SCRIPT_FILENAME'] = $this->drupalFinder->getDrupalRoot() . '/index.php'; + $request = Request::createFromGlobals(); if ($debug) { $io->writeln("\r\033[K\033[1A\r✔"); $io->writeln('➤ Creating Drupal kernel'); } + $drupalKernel = DrupalKernel::createFromRequest( $request, $this->autoload, 'prod', false, - $this->appRoot + $this->drupalFinder->getDrupalRoot() ); if ($debug) { $io->writeln("\r\033[K\033[1A\r✔"); @@ -96,13 +113,14 @@ class Drupal $drupalKernel->addServiceModifier( new DrupalServiceModifier( - $this->root, - $this->appRoot, + $this->drupalFinder->getComposerRoot(), + $this->drupalFinder->getDrupalRoot(), 'drupal.command', 'drupal.generator', $rebuildServicesFile ) ); + if ($debug) { $io->writeln("\r\033[K\033[1A\r✔"); $io->writeln('➤ Rebuilding container'); @@ -116,7 +134,10 @@ class Drupal } $container = $drupalKernel->getContainer(); - $container->set('console.root', $this->root); + $container->set( + 'console.root', + $this->drupalFinder->getComposerRoot() + ); AnnotationRegistry::registerLoader([$this->autoload, "loadClass"]); @@ -126,10 +147,10 @@ class Drupal $container->get('console.translator_manager') ->loadCoreLanguage( $configuration->get('application.language'), - $this->root + $this->drupalFinder->getComposerRoot() ); - $consoleExtendConfigFile = $this->root . DRUPAL_CONSOLE .'/extend.console.config.yml'; + $consoleExtendConfigFile = $this->drupalFinder->getComposerRoot() . DRUPAL_CONSOLE .'/extend.console.config.yml'; if (file_exists($consoleExtendConfigFile)) { $container->get('console.configuration_manager') ->importConfigurationFile($consoleExtendConfigFile); @@ -138,19 +159,23 @@ class Drupal $container->get('console.renderer') ->setSkeletonDirs( [ - $this->root.DRUPAL_CONSOLE.'/templates/', - $this->root.DRUPAL_CONSOLE_CORE.'/templates/' + $this->drupalFinder->getComposerRoot().DRUPAL_CONSOLE.'/templates/', + $this->drupalFinder->getComposerRoot().DRUPAL_CONSOLE_CORE.'/templates/' ] ); return $container; } catch (\Exception $e) { - if ($argvInputReader->get('command') == 'list') { + if ($command == 'list') { $io->error($e->getMessage()); } - $drupal = new DrupalConsoleCore($this->root, $this->appRoot); + $drupal = new DrupalConsoleCore( + $this->drupalFinder->getComposerRoot(), + $this->drupalFinder->getDrupalRoot() + ); $container = $drupal->boot(); $container->set('class_loader', $this->autoload); + return $container; } }