Skip to content

Commit

Permalink
[console] Output on debug option. (#3087)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmolivas committed Jan 9, 2017
1 parent 2379eea commit 9e6ba52
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 44 deletions.
10 changes: 6 additions & 4 deletions bin/drupal.php
@@ -1,5 +1,6 @@
<?php

use Symfony\Component\Console\Input\ArgvInput;
use DrupalFinder\DrupalFinder;
use Drupal\Console\Core\Utils\ArgvInputReader;
use Drupal\Console\Bootstrap\Drupal;
Expand Down Expand Up @@ -30,8 +31,10 @@
exit(1);
}

$drupalFinder = new DrupalFinder();
$argvInput = new ArgvInput();
$debug = $argvInput->hasParameterOption(['--debug']);

$drupalFinder = new DrupalFinder();
if (!$drupalFinder->locateRoot(getcwd())) {
echo ' DrupalConsole must be executed within a Drupal Site.'.PHP_EOL;

Expand All @@ -43,10 +46,10 @@
chdir($drupalRoot);

$drupal = new Drupal($autoload, $composerRoot, $drupalRoot);
$container = $drupal->boot();
$container = $drupal->boot($debug);

if (!$container) {
echo ' Something was wrong. Drupal can not be bootstrapped.';
echo ' Something was wrong. Drupal can not be bootstrap.';

exit(1);
}
Expand All @@ -61,7 +64,6 @@
$argvInputReader->setOptionsFromConfiguration($options);
}
$argvInputReader->setOptionsAsArgv();

$application = new Application($container);
$application->setDefaultCommand('about');
$application->run();
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -37,7 +37,7 @@
},
"require": {
"php": "^5.5.9 || ^7.0",
"drupal/console-core" : "1.0.0-rc14",
"drupal/console-core" : "dev-master",
"alchemy/zippy": "0.4.3",
"composer/installers": "~1.0",
"symfony/css-selector": ">=2.7 <3.2",
Expand Down
28 changes: 15 additions & 13 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 0 additions & 13 deletions src/Application.php
Expand Up @@ -39,14 +39,8 @@ public function __construct(ContainerInterface $container)
*/
public function doRun(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$this->registerGenerators();
$this->registerCommands();
// for ($lines = 0; $lines < 2; $lines++) {
// $io->write("\r\033[K\033[1A\r");
// }
// $io->clearCurrentLine();

$clear = $this->container->get('console.configuration_manager')
->getConfiguration()
->get('application.clear')?:false;
Expand All @@ -55,13 +49,6 @@ public function doRun(InputInterface $input, OutputInterface $output)
}

$exitCode = parent::doRun($input, $output);

if ($this->getCommandName($input) == 'list' && $this->container->hasParameter('console.warning')) {
$io->warning(
$this->trans($this->container->getParameter('console.warning'))
);
}

return $exitCode;
}

Expand Down
34 changes: 21 additions & 13 deletions src/Bootstrap/Drupal.php
Expand Up @@ -3,10 +3,10 @@
namespace Drupal\Console\Bootstrap;

use Doctrine\Common\Annotations\AnnotationRegistry;
use Drupal\Console\Core\Style\DrupalStyle;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\HttpFoundation\Request;
use Drupal\Console\Core\Style\DrupalStyle;
use Drupal\Console\Core\Utils\ArgvInputReader;
use Drupal\Console\Core\Bootstrap\DrupalConsoleCore;

Expand All @@ -30,7 +30,7 @@ public function __construct($autoload, $root, $appRoot)
$this->appRoot = $appRoot;
}

public function boot()
public function boot($debug)
{
$output = new ConsoleOutput();
$input = new ArrayInput([]);
Expand All @@ -51,7 +51,9 @@ public function boot()
}
$argvInputReader = new ArgvInputReader();

// $io->writeln('➤ Creating request');
if ($debug) {
$io->writeln('➤ Creating request');
}
if ($argvInputReader->get('uri')) {
$uri = $argvInputReader->get('uri');
if (substr($uri, -1) != '/') {
Expand All @@ -62,18 +64,20 @@ public function boot()
} else {
$request = Request::createFromGlobals();
}
// $io->writeln("\r\033[K\033[1A\r<info>✔</info>");

// $io->writeln('➤ Creating kernel');
if ($debug) {
$io->writeln("\r\033[K\033[1A\r<info>✔</info>");
$io->writeln('➤ Creating Drupal kernel');
}
$drupalKernel = DrupalKernel::createFromRequest(
$request,
$this->autoload,
'prod',
false
);
// $io->writeln("\r\033[K\033[1A\r<info>✔</info>");

// $io->writeln('➤ Registering commands');
if ($debug) {
$io->writeln("\r\033[K\033[1A\r<info>✔</info>");
$io->writeln('➤ Providing dynamic services');
}
$drupalKernel->addServiceModifier(
new DrupalServiceModifier(
$this->root,
Expand All @@ -82,13 +86,17 @@ public function boot()
'drupal.generator'
)
);
// $io->writeln("\r\033[K\033[1A\r<info>✔</info>");

// $io->writeln('➤ Rebuilding container');
if ($debug) {
$io->writeln("\r\033[K\033[1A\r<info>✔</info>");
$io->writeln('➤ Rebuilding container');
}
$drupalKernel->invalidateContainer();
$drupalKernel->rebuildContainer();
$drupalKernel->boot();
// $io->writeln("\r\033[K\033[1A\r<info>✔</info>");

if ($debug) {
$io->writeln("\r\033[K\033[1A\r<info>✔</info>");
}

$container = $drupalKernel->getContainer();
$container->set('console.root', $this->root);
Expand Down

0 comments on commit 9e6ba52

Please sign in to comment.