diff --git a/src/Command/ListStorageProviderCommand.php b/src/Command/ListStorageProviderCommand.php index 4a4953a..ce263d6 100644 --- a/src/Command/ListStorageProviderCommand.php +++ b/src/Command/ListStorageProviderCommand.php @@ -15,8 +15,10 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use WBW\Bundle\CommonBundle\Command\AbstractProviderListCommand; use WBW\Bundle\EDMBundle\Manager\StorageManagerTrait; use WBW\Bundle\EDMBundle\Provider\StorageProviderInterface; +use WBW\Bundle\EDMBundle\WBWEDMBundle; /** * List storage provider command. @@ -24,25 +26,12 @@ * @author webeweb * @package WBW\Bundle\EDMBundle\Command */ -class ListStorageProviderCommand extends AbstractCommand { +class ListStorageProviderCommand extends AbstractProviderListCommand { use StorageManagerTrait { setStorageManager as public; } - /** - * Command help. - * - * @var string - */ - const COMMAND_HELP = <<< EOT -The %command.name% command list the storage providers. - - php %command.full_name% - - -EOT; - /** * Command name. * @@ -63,14 +52,14 @@ class ListStorageProviderCommand extends AbstractCommand { protected function configure(): void { $this ->setDescription("List the storage providers") - ->setHelp(self::COMMAND_HELP) + ->setHelp(static::formatHelp("list the storage providers")) ->setName(self::COMMAND_NAME); } /** * {@inheritDoc} */ - protected function execute(InputInterface $input, OutputInterface $output): ?int { + protected function execute(InputInterface $input, OutputInterface $output): int { $io = $this->newStyle($input, $output); $this->displayTitle($io, $this->getDescription()); @@ -85,6 +74,7 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int $this->sortRows($rows); $io->table($this->getHeaders(), $rows); + $this->displayFooter($io, count($rows), "command.footer.provider_list.success", "command.footer.provider_list.warning", WBWEDMBundle::getTranslationDomain(), "en"); return 0; } @@ -97,7 +87,7 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int protected function getHeaders(): array { return [ - $this->translate("label.class", [], null, "en"), + $this->translate("command.header.class", [], WBWEDMBundle::getTranslationDomain(), "en"), ]; } @@ -113,17 +103,4 @@ protected function renderRow(StorageProviderInterface $provider): array { get_class($provider), ]; } - - /** - * Sort the rows. - * - * @param string[][] $rows The rows. - * @return void - */ - protected function sortRows(array &$rows): void { - - usort($rows, function(array $a, array $b) { - return strcmp($a[0], $b[0]); - }); - } } diff --git a/tests/Command/ListStorageProviderCommandTest.php b/tests/Command/ListStorageProviderCommandTest.php index 978c803..15e1a8e 100644 --- a/tests/Command/ListStorageProviderCommandTest.php +++ b/tests/Command/ListStorageProviderCommandTest.php @@ -67,7 +67,7 @@ public function test__construct(): void { $obj = new ListStorageProviderCommand(); $this->assertEquals("List the storage providers", $obj->getDescription()); - $this->assertEquals(ListStorageProviderCommand::COMMAND_HELP, $obj->getHelp()); + $this->assertNotNull($obj->getHelp()); $this->assertEquals(ListStorageProviderCommand::COMMAND_NAME, $obj->getName()); } }