Exemple #1
0
 public function boot()
 {
     $logger = new Logger($this->root);
     if (!class_exists('Drupal\\Core\\DrupalKernel')) {
         $logger->writeln('Class Drupal\\Core\\DrupalKernel not found.');
         $drupal = new DrupalConsoleCore($this->root, $this->appRoot);
         $container = $drupal->boot();
         $container->set('console.logger', $logger);
         return $container;
     }
     try {
         $argvInputReader = new ArgvInputReader();
         if ($argvInputReader->get('uri')) {
             $uri = $argvInputReader->get('uri');
             if (substr($uri, -1) != '/') {
                 $uri .= '/';
             }
             $uri .= 'index.php';
             $request = Request::create($uri, 'GET', array(), array(), array(), array('SCRIPT_NAME' => $this->appRoot . '/index.php'));
         } else {
             $request = Request::createFromGlobals();
         }
         $drupalKernel = DrupalKernel::createFromRequest($request, $this->autoload, 'prod', false);
         $drupalKernel->addServiceModifier(new DrupalServiceModifier($this->root, 'drupal.command', 'drupal.generator'));
         $drupalKernel->invalidateContainer();
         $drupalKernel->rebuildContainer();
         $drupalKernel->boot();
         $container = $drupalKernel->getContainer();
         $container->set('console.root', $this->root);
         $container->set('console.logger', $logger);
         AnnotationRegistry::registerLoader([$this->autoload, "loadClass"]);
         $configuration = $container->get('console.configuration_manager')->loadConfiguration($this->root)->getConfiguration();
         $container->get('console.translator_manager')->loadCoreLanguage($configuration->get('application.language'), $this->root);
         $container->get('console.renderer')->setSkeletonDirs([$this->root . DRUPAL_CONSOLE . '/templates/', $this->root . DRUPAL_CONSOLE_CORE . '/templates/']);
         return $container;
     } catch (\Exception $e) {
         $logger->writeln($e->getMessage());
         $drupal = new DrupalConsoleCore($this->root, $this->appRoot);
         $container = $drupal->boot();
         $container->set('console.logger', $logger);
         return $container;
     }
 }
Exemple #2
0
 public function boot()
 {
     if (!class_exists('Drupal\\Core\\DrupalKernel')) {
         $drupal = new DrupalConsoleCore($this->root, $this->appRoot);
         return $drupal->boot();
     }
     try {
         // Add support for Acquia Dev Desktop sites on Mac OS X
         // @TODO: Check if this condition works in Windows
         $devDesktopSettingsDir = getenv('HOME') . "/.acquia/DevDesktop/DrupalSettings";
         if (file_exists($devDesktopSettingsDir)) {
             $_SERVER['DEVDESKTOP_DRUPAL_SETTINGS_DIR'] = $devDesktopSettingsDir;
         }
         $argvInputReader = new ArgvInputReader();
         if ($argvInputReader->get('uri')) {
             $uri = $argvInputReader->get('uri');
             if (substr($uri, -1) != '/') {
                 $uri .= '/';
             }
             $uri .= 'index.php';
             $request = Request::create($uri, 'GET', array(), array(), array(), array('SCRIPT_NAME' => $this->appRoot . '/index.php'));
         } else {
             $request = Request::createFromGlobals();
         }
         $drupalKernel = DrupalKernel::createFromRequest($request, $this->autoload, 'prod', false);
         $drupalKernel->addServiceModifier(new DrupalServiceModifier($this->root, 'drupal.command', 'drupal.generator'));
         $drupalKernel->invalidateContainer();
         $drupalKernel->rebuildContainer();
         $drupalKernel->boot();
         $container = $drupalKernel->getContainer();
         $container->set('console.root', $this->root);
         AnnotationRegistry::registerLoader([$this->autoload, "loadClass"]);
         $configuration = $container->get('console.configuration_manager')->loadConfiguration($this->root)->getConfiguration();
         $container->get('console.translator_manager')->loadCoreLanguage($configuration->get('application.language'), $this->root);
         $container->get('console.renderer')->setSkeletonDirs([$this->root . DRUPAL_CONSOLE . '/templates/', $this->root . DRUPAL_CONSOLE_CORE . '/templates/']);
         return $container;
     } catch (\Exception $e) {
         $drupal = new DrupalConsoleCore($this->root, $this->appRoot);
         return $drupal->boot();
     }
 }