Skip to content

Commit

Permalink
Merge ceb888c into c7382da
Browse files Browse the repository at this point in the history
  • Loading branch information
mabar committed Mar 2, 2018
2 parents c7382da + ceb888c commit 276a10c
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/DI/ConsoleExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class ConsoleExtension extends CompilerExtension
ContainerHelper::class,
],
'lazy' => FALSE,
'cliOnly' => TRUE,
];

/**
Expand All @@ -46,11 +47,14 @@ class ConsoleExtension extends CompilerExtension
*/
public function loadConfiguration()
{
$config = $this->validateConfig($this->defaults);

// Skip if it's not CLI mode
if (PHP_SAPI !== 'cli') return;
if (PHP_SAPI !== 'cli' && $config['cliOnly'] === TRUE) {
return;
}

$builder = $this->getContainerBuilder();
$config = $this->validateConfig($this->defaults);

Validators::assertField($config, 'helpers', 'array|null');

Expand Down Expand Up @@ -110,18 +114,23 @@ public function loadConfiguration()
*/
public function beforeCompile()
{
$config = $this->validateConfig($this->defaults);

// Skip if it's not CLI mode
if (PHP_SAPI !== 'cli') return;
if (PHP_SAPI !== 'cli' && $config['cliOnly'] === TRUE) {
return;
}

$builder = $this->getContainerBuilder();
$config = $this->validateConfig($this->defaults);
$application = $builder->getDefinition($this->prefix('application'));

// Setup URL in CLI
if ($builder->hasDefinition('http.request') && $config['url'] !== NULL) {
$builder->getDefinition('http.request')
->setClass(Request::class, [new Statement(UrlScript::class, [$config['url']])]);
}
if(PHP_SAPI === 'cli') {
if ($builder->hasDefinition('http.request') && $config['url'] !== NULL) {
$builder->getDefinition('http.request')
->setClass(Request::class, [new Statement(UrlScript::class, [$config['url']])]);
}
}

// Register all commands (if they are not lazy-loaded)
// otherwise build a command map for command loader
Expand Down

0 comments on commit 276a10c

Please sign in to comment.