Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[console] Make optional loading alias, mappings, chain and config commands. #189

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,35 @@ public function trans($key)
/**
* {@inheritdoc}
*/
public function doRun(InputInterface $input, OutputInterface $output) {
public function doRun(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$messages = [];
if ($commandName = $this->getCommandName($input)) {
$this->commandName = $commandName;
}
$this->registerEvents();
$this->registerExtendCommands();
$this->registerCommandsFromAutoWireConfiguration();
$this->registerChainCommands();

/**
* @var ConfigurationManager $configurationManager
*/
$configurationManager = $this->container
->get('console.configuration_manager');

$config = $configurationManager->getConfiguration()
->get('application.extras.config')?:'true';
if ($config === 'true') {
$this->registerCommandsFromAutoWireConfiguration();
}

$chains = $configurationManager->getConfiguration()
->get('application.extras.chains')?:'true';
if ($chains === 'true') {
$this->registerChainCommands();
}


if ($commandName && !$this->has($commandName)) {
$config = $configurationManager->getConfiguration();
$mappings = $config
Expand All @@ -117,8 +129,7 @@ public function doRun(InputInterface $input, OutputInterface $output) {
$this->add(
$this->find($commandNameMap)->setAliases([$commandName])
);
}
else {
} else {
$io->error(
sprintf(
$this->trans('application.errors.invalid-command'),
Expand All @@ -136,7 +147,7 @@ public function doRun(InputInterface $input, OutputInterface $output) {
);

if ($this->commandName != 'init' && $configurationManager->getMissingConfigurationFiles(
)
)
) {
$io->warning(
$this->trans('application.site.errors.missing-config-file')
Expand All @@ -150,8 +161,8 @@ public function doRun(InputInterface $input, OutputInterface $output) {
}

if ($this->getCommandName(
$input
) == 'list' && $this->container->hasParameter('console.warning')
$input
) == 'list' && $this->container->hasParameter('console.warning')
) {
$io->warning(
$this->trans($this->container->getParameter('console.warning'))
Expand Down
17 changes: 12 additions & 5 deletions src/Utils/ConfigurationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,14 @@ public function loadConfiguration($applicationDirectory)

$builder = new YamlFileConfigurationBuilder($configurationFiles);
$this->configuration = $builder->build();
$this->appendCommandAliases();
$this->appendCommandMappings();
$aliases = $this->configuration->get('application.extras.alias')?:'true';
if ($aliases === 'true') {
$this->appendCommandAliases();
}
$mappings = $this->configuration->get('application.extras.mappings')?:'true';
if ($mappings === 'true') {
$this->appendCommandMappings();
}

if ($configurationFiles) {
$this->missingConfigurationFiles = [];
Expand Down Expand Up @@ -248,7 +254,7 @@ public function getConfigurationDirectories()
/**
* @return void
*/
public function appendCommandMappings()
private function appendCommandMappings()
{
$mappings = [];
$mappingsFile = $this->applicationDirectory.DRUPAL_CONSOLE_CORE.'config/mappings.yml';
Expand All @@ -268,7 +274,7 @@ public function appendCommandMappings()
/**
* @return void
*/
public function appendCommandAliases()
private function appendCommandAliases()
{
$aliases = [];
foreach ($this->configurationDirectories as $directory) {
Expand Down Expand Up @@ -344,7 +350,8 @@ public function getSites()
return $this->sites;
}

public function getHomeDirectory() {
public function getHomeDirectory()
{
return Path::getHomeDirectory();
}
}
8 changes: 6 additions & 2 deletions templates/core/init/config.yml.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ application:
language: '{{language}}'
editor: 'vim'
temp: '{{temp}}'
cache:
directory: 'console/cache/'
develop: 'false'
command: 'about'
checked: 'false'
clear: 'false'
extras:
alias: 'true'
extend: 'true'
config: 'true'
chains: 'true'
mappings: 'true'
remote:
user: 'drupal'
# password: 'drupal'
Expand Down