Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sreichel committed Aug 11, 2024
1 parent bbf411d commit 10fe55c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
14 changes: 12 additions & 2 deletions src/N98/Magento/Command/AbstractMagentoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,27 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if ($this instanceof CommandFormatable) {
$this->detectMagento($output, static::$detectMagentoSilent);

if ($input->getOption(static::COMMAND_OPTION_FORMAT) === null) {
$formatOption = $input->getOption(static::COMMAND_OPTION_FORMAT);

if ($formatOption === null) {
$this->writeSection($output, $this->getSectionTitle($input, $output));
}

if (!$this->initMagento()) {
return Command::FAILURE;
}

$data = $this->getListData($input, $output);
if ($formatOption === null && $data === []) {
$output->writeln(sprintf(
'<info>No entry found for "%s" </info>',
$this->getSectionTitle($input, $output))
);
}

$this->getTableHelper()
->setHeaders($this->getListHeader($input, $output))
->renderByFormat($output, $this->getListData($input, $output), $input->getOption(self::COMMAND_OPTION_FORMAT));
->renderByFormat($output, $data, $input->getOption(self::COMMAND_OPTION_FORMAT));

return Command::SUCCESS;
}
Expand Down
2 changes: 1 addition & 1 deletion src/N98/Magento/Command/Admin/User/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public function getListHeader(InputInterface $input, OutputInterface $output): a
*/
public function getListData(InputInterface $input, OutputInterface $output): array
{
/** @var Mage_Admin_Model_User $userModel */
$userModel = $this->getUserModel();
$userList = $userModel->getCollection();
$table = [];
/** @var Mage_Admin_Model_User $user */
foreach ($userList as $user) {
$table[] = [
$user->getId(),
Expand Down
8 changes: 7 additions & 1 deletion src/N98/Magento/Command/System/Store/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

use function ksort;

/**
* List stores command
*
Expand Down Expand Up @@ -50,7 +52,11 @@ public function getListData(InputInterface $input, OutputInterface $output): arr
{
$table = [];
foreach (Mage::app()->getStores() as $store) {
$table[$store->getId()] = [$store->getId(), $store->getCode()];
$storeId = $store->getId();
$table[$storeId] = [
$storeId,
$store->getCode()
];
}

ksort($table);
Expand Down
11 changes: 7 additions & 4 deletions src/N98/Magento/Command/System/Website/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

use function ksort;

/**
* List websites command
*
Expand Down Expand Up @@ -49,10 +51,11 @@ public function getListHeader(InputInterface $input, OutputInterface $output): a
public function getListData(InputInterface $input, OutputInterface $output): array
{
$table = [];
foreach (Mage::app()->getWebsites() as $store) {
$table[$store->getId()] = [
$store->getId(),
$store->getCode()
foreach (Mage::app()->getWebsites() as $website) {
$websiteId = $website->getId();
$table[$websiteId] = [
$websiteId,
$website->getCode()
];
}

Expand Down

0 comments on commit 10fe55c

Please sign in to comment.