Skip to content

Commit

Permalink
[core: getData] Added new parameters, Improve custom chain for gitboo…
Browse files Browse the repository at this point in the history
…k update (#341)
  • Loading branch information
enzolutions committed Apr 20, 2018
1 parent bf1fb4a commit e93efb2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
10 changes: 7 additions & 3 deletions dist/chain/update-gitbook.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# How to use
# update:gitbook --directory="/path/to/drupal-project/"
# update:gitbook --directory="/path/to/drupal-console/gitbook-repository/"
command:
name: update:gitbook
description: 'Update gitbook'
Expand All @@ -16,17 +16,21 @@ commands:
- node
- views
- features
{% set languages = ['en', 'es', 'hi', 'hu', 'pt_br', 'ro', 'vn', 'zh_hans'] %}
- command: 'develop:translation:sync'
{% set languages = ['en', 'ca', 'es', 'hi', 'hu', 'ja', 'mr', 'pt-br', 'ro', 'ru', 'vn' , 'zh-hans'] %}
{% for language in languages %}
- command: settings:set
arguments:
name: language
value: {{ language }}
- command: exec
arguments:
bin: 'rm -Rf {{ directory }}/{{ language }}/commands'
- command: develop:doc:gitbook
options:
path: '{{ directory }}/{{ language }}'
{% endfor %}
- command: settings:set
arguments:
name: language
value: en
value: en
19 changes: 18 additions & 1 deletion src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ private function registerExtendCommands()
->loadExtendConfiguration();
}

public function getData()
public function getData($filterNamespaces = null, $excludeNamespaces = [], $excludeChainCommands = false)
{
$singleCommands = [
'about',
Expand Down Expand Up @@ -693,9 +693,16 @@ public function getData()
return (strpos($item, ':')<=0);
}
);

sort($namespaces);
array_unshift($namespaces, 'misc');

// Exclude specific namespaces
$namespaces = array_diff($namespaces, $excludeNamespaces);

// filter namespaces if available
if($filterNamespaces) $namespaces = array_intersect($namespaces, $filterNamespaces);

foreach ($namespaces as $namespace) {
$commands = $this->all($namespace);
usort(
Expand All @@ -705,6 +712,11 @@ public function getData()
);

foreach ($commands as $command) {
// Exclude command if is a chain command and was requested to exclude chain commands
if($excludeChainCommands && $command instanceof ChainCustomCommand) {
continue;
}

if (method_exists($command, 'getModule')) {
if ($command->getModule() == 'Console') {
$data['commands'][$namespace][] = $this->commandData(
Expand All @@ -719,6 +731,11 @@ public function getData()
}
}

// Remove namepsaces without commands
$namespaces = array_filter($namespaces, function($namespace) use( $data) {
return count($data['commands'][$namespace]) > 0;
});

$input = $this->getDefinition();
$options = [];
foreach ($input->getOptions() as $option) {
Expand Down

0 comments on commit e93efb2

Please sign in to comment.