Skip to content
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
30 changes: 30 additions & 0 deletions config/mappings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
commands:
mappings:
breakpoints:debug: debug:breakpoints
cache:context:debug: debug:cache:context
chain:debug: debug:chain
config:debug: debug:config
config:settings:debug: debug:config:settings
config:validate:debug: debug:config:validate
container:debug: debug:container
cron:debug: debug:cron
database:log:debug: debug:database:log
database:table:debug: debug:database:table
entity:debug: debug:entity
event:debug: debug:event
image:styles:debug: debug:image:styles
libraries:debug: debug:libraries
module:debug: debug:module
multisite:debug: debug:multisite
permission:debug: debug:permission
plugin:debug: debug:plugin
queue:debug: debug:queue
router:debug: debug:router
settings:debug: debug:settings
site:debug: debug:site
state:debug: debug:state
theme:debug: debug:theme
update:debug: debug:update
user:debug: debug:user
views:debug: debug:views
views:plugins:debug: debug:views:plugins
56 changes: 43 additions & 13 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ 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;
}
Expand All @@ -103,35 +103,65 @@ public function doRun(InputInterface $input, OutputInterface $output)
->get('console.configuration_manager');

if ($commandName && !$this->has($commandName)) {
$io->error(
sprintf(
$this->trans('application.errors.invalid-command'),
$this->commandName
)
);
$config = $configurationManager->getConfiguration();
$mappings = $config
->get('application.commands.mappings');

if (array_key_exists($commandName, $mappings)) {
$commandNameMap = $mappings[$commandName];
$messages['warning'][] = sprintf(
$this->trans('application.errors.renamed-command'),
$commandName,
$commandNameMap
);
$this->add(
$this->find($commandNameMap)->setAliases([$commandName])
);
}
else {
$io->error(
sprintf(
$this->trans('application.errors.invalid-command'),
$this->commandName
)
);

return 1;
return 1;
}
}

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

if ($this->commandName != 'init' && $configurationManager->getMissingConfigurationFiles()) {
$io->warning($this->trans('application.site.errors.missing-config-file'));
if ($this->commandName != 'init' && $configurationManager->getMissingConfigurationFiles(
)
) {
$io->warning(
$this->trans('application.site.errors.missing-config-file')
);
$io->listing($configurationManager->getMissingConfigurationFiles());
$io->commentBlock(
$this->trans('application.site.errors.missing-config-file-command')
$this->trans(
'application.site.errors.missing-config-file-command'
)
);
}

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

foreach ($messages as $type => $message) {
$io->$type($message);
}

return $code;
}

Expand Down
23 changes: 22 additions & 1 deletion src/Utils/ConfigurationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public function loadConfiguration($applicationDirectory)
$builder = new YamlFileConfigurationBuilder($configurationFiles);
$this->configuration = $builder->build();
$this->appendCommandAliases();
$this->appendCommandMappings();

if ($configurationFiles) {
$this->missingConfigurationFiles = [];
Expand Down Expand Up @@ -245,7 +246,27 @@ public function getConfigurationDirectories()
}

/**
* @return string
* @return void
*/
public function appendCommandMappings()
{
$mappings = [];
$mappingsFile = $this->applicationDirectory.DRUPAL_CONSOLE_CORE.'config/mappings.yml';

if (file_exists($mappingsFile)) {
$mappings = Yaml::parse(file_get_contents($mappingsFile));
}

if (array_key_exists('commands', $mappings) && array_key_exists('mappings', $mappings['commands'])) {
$this->configuration->set(
'application.commands.mappings',
$mappings['commands']['mappings']
);
}
}

/**
* @return void
*/
public function appendCommandAliases()
{
Expand Down