mirror of
https://github.com/silverstripe/silverstripe-behat-extension
synced 2024-10-22 17:05:32 +02:00
FIX Don't bootstrap when running behat -h
or behat --help
(#262)
This commit is contained in:
parent
1c4463f878
commit
f16cb65d26
@ -16,6 +16,7 @@ use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
|
|||||||
use Behat\Testwork\ServiceContainer\ExtensionManager;
|
use Behat\Testwork\ServiceContainer\ExtensionManager;
|
||||||
use Behat\Testwork\ServiceContainer\Extension as ExtensionInterface;
|
use Behat\Testwork\ServiceContainer\Extension as ExtensionInterface;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
use Symfony\Component\Console\Input\ArgvInput;
|
||||||
use Symfony\Component\DependencyInjection\Definition;
|
use Symfony\Component\DependencyInjection\Definition;
|
||||||
use Symfony\Component\DependencyInjection\Reference;
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
|
|
||||||
@ -42,7 +43,6 @@ class Extension implements ExtensionInterface
|
|||||||
*/
|
*/
|
||||||
const SILVERSTRIPE_ID = 'silverstripe_extension';
|
const SILVERSTRIPE_ID = 'silverstripe_extension';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@ -78,8 +78,10 @@ class Extension implements ExtensionInterface
|
|||||||
public function load(ContainerBuilder $container, array $config)
|
public function load(ContainerBuilder $container, array $config)
|
||||||
{
|
{
|
||||||
// Load yml config
|
// Load yml config
|
||||||
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../config'));
|
if ($this->getShouldBootstrap($container)) {
|
||||||
$loader->load('silverstripe.yml');
|
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../config'));
|
||||||
|
$loader->load('silverstripe.yml');
|
||||||
|
}
|
||||||
|
|
||||||
// Add CLI substitutions
|
// Add CLI substitutions
|
||||||
$this->loadSuiteLocator($container);
|
$this->loadSuiteLocator($container);
|
||||||
@ -105,8 +107,10 @@ class Extension implements ExtensionInterface
|
|||||||
*/
|
*/
|
||||||
public function process(ContainerBuilder $container)
|
public function process(ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
$corePass = new Compiler\CoreInitializationPass();
|
if ($this->getShouldBootstrap($container)) {
|
||||||
$corePass->process($container);
|
$corePass = new Compiler\CoreInitializationPass();
|
||||||
|
$corePass->process($container);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configure(ArrayNodeDefinition $builder)
|
public function configure(ArrayNodeDefinition $builder)
|
||||||
@ -203,4 +207,20 @@ class Extension implements ExtensionInterface
|
|||||||
$definition->addTag(CallExtension::CALL_HANDLER_TAG, ['priority' => 50]);
|
$definition->addTag(CallExtension::CALL_HANDLER_TAG, ['priority' => 50]);
|
||||||
$container->setDefinition(CallExtension::CALL_HANDLER_TAG . '.runtime', $definition);
|
$container->setDefinition(CallExtension::CALL_HANDLER_TAG . '.runtime', $definition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the extension should bootstrap or not.
|
||||||
|
* The extension should always bootstrap unless the `-h` or `--help` option is passed.
|
||||||
|
*/
|
||||||
|
private function getShouldBootstrap(ContainerBuilder $container): bool
|
||||||
|
{
|
||||||
|
if (!$container->has('cli.input')) {
|
||||||
|
// If the input isn't there for some bizarre reason, just assume we should bootstrap.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var ArgvInput $input */
|
||||||
|
$input = $container->get('cli.input');
|
||||||
|
return !$input->hasParameterOption(['--help', '-h']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user