Security update for Core, with self-updated composer
[yaffs-website] / vendor / drupal / console / src / Command / Debug / LibrariesCommand.php
similarity index 56%
rename from vendor/drupal/console/src/Command/Libraries/DebugCommand.php
rename to vendor/drupal/console/src/Command/Debug/LibrariesCommand.php
index bfa501f63aa2a6d5649a38ec0623d5e4f89f0e6d..6153784250baad6092ee36a78c873cf81585b124 100644 (file)
@@ -2,26 +2,22 @@
 
 /**
  * @file
- * Contains \Drupal\Console\Command\Libraries\DebugCommand.
+ * Contains \Drupal\Console\Command\Debug\LibrariesCommand.
  */
 
-namespace Drupal\Console\Command\Libraries;
+namespace Drupal\Console\Command\Debug;
 
 use Symfony\Component\Console\Input\InputArgument;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\Console\Command\Command;
+use Drupal\Console\Core\Command\Command;
 use Drupal\Core\Extension\ModuleHandlerInterface;
 use Drupal\Core\Extension\ThemeHandlerInterface;
 use Drupal\Core\Asset\LibraryDiscoveryInterface;
 use Drupal\Component\Serialization\Yaml;
-use Drupal\Console\Core\Command\Shared\CommandTrait;
-use Drupal\Console\Core\Style\DrupalStyle;
 
-class DebugCommand extends Command
+class LibrariesCommand extends Command
 {
-    use CommandTrait;
-
     /**
  * @var  ModuleHandlerInterface
 */
@@ -69,13 +65,13 @@ class DebugCommand extends Command
     protected function configure()
     {
         $this
-            ->setName('libraries:debug')
-            ->setDescription($this->trans('commands.libraries.debug.description'))
+            ->setName('debug:libraries')
+            ->setDescription($this->trans('commands.debug.libraries.description'))
             ->addArgument(
                 'group',
                 InputArgument::OPTIONAL,
-                $this->trans('commands.libraries.debug.options.name')
-            );
+                $this->trans('commands.debug.libraries.options.name')
+            )->setAliases(['dl']);
     }
 
     /**
@@ -83,24 +79,59 @@ class DebugCommand extends Command
      */
     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.libraries.debug.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"
+                    ];
+                }
+            }
+
+            $this->getIo()->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);
-                $io->writeln(Yaml::encode($libraries));
+                if ($libraryName && $libraryName != $key) {
+                    continue;
+                }
+
+                $this->getIo()->writeln('<info>'.$extension.'/'.$key.'</info>');
+                $this->getIo()->writeln(Yaml::encode($libraries));
             }
         }
     }