Skip to content

Commit

Permalink
[debug:libraries] Show libraries when debugging extensions. (#3537)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmolivas committed Oct 28, 2017
1 parent 30821a7 commit 051c2d8
Showing 1 changed file with 42 additions and 6 deletions.
48 changes: 42 additions & 6 deletions src/Command/Debug/LibrariesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,58 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$group = $input->getArgument('group');
$extension = $input->getArgument('group');

if (!$group) {
if (!$extension) {
$groups = $this->getAllLibraries();

$tableRow = [];

$tableHeader = [
$this->trans('commands.debug.libraries.messages.name'),
$this->trans('commands.debug.libraries.messages.extension'),
$this->trans('commands.debug.libraries.messages.library'),
];

$io->table($tableHeader, $groups, 'compact');
foreach ($groups as $extension) {
$library = $this->libraryDiscovery
->getLibrariesByExtension($extension);

if (!$library) {
continue;
}

if ($libraryKeys = array_keys($library)) {
$libraryKeys = array_map(
function ($value) use ($extension) {
return $extension . '/' . $value;
},
$libraryKeys
);

$tableRow[] = [
$extension,
$libraryKeys = implode("\n", $libraryKeys) . "\n"
];
}
}

$io->table($tableHeader, $tableRow, 'default');
} else {
$libraryName = null;
if ($library = explode('/', $extension)) {
$extension = $library[0];
$libraryName = $library[1];
}

$librariesData = $this->libraryDiscovery
->getLibrariesByExtension($group);
->getLibrariesByExtension($extension);

foreach ($librariesData as $key => $libraries) {
$io->comment($key);
if ($libraryName && $libraryName != $key) {
continue;
}

$io->writeln('<info>'.$extension.'/'.$key.'</info>');
$io->writeln(Yaml::encode($libraries));
}
}
Expand Down

0 comments on commit 051c2d8

Please sign in to comment.