Skip to content

Commit

Permalink
Updated dev:theme:list
Browse files Browse the repository at this point in the history
  • Loading branch information
sreichel committed Aug 10, 2024
1 parent 81ba741 commit dd5c13e
Showing 1 changed file with 30 additions and 21 deletions.
51 changes: 30 additions & 21 deletions src/N98/Magento/Command/Developer/Theme/ListCommand.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<?php

declare(strict_types=1);

namespace N98\Magento\Command\Developer\Theme;

use Mage;
use N98\Magento\Command\AbstractMagentoCommand;
use N98\Magento\Command\CommandFormatable;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

Expand All @@ -12,29 +15,39 @@
*
* @package N98\Magento\Command\Developer\Theme
*/
class ListCommand extends AbstractMagentoCommand
class ListCommand extends AbstractMagentoCommand implements CommandFormatable
{
protected function configure()
/**
* @var string
*/
public static $defaultName = 'dev:theme:list';

/**
* @var string
*/
public static $defaultDescription = 'Lists all available themes.';

/**
* {@inheritDoc}
*/
public function getSectionTitle(InputInterface $input, OutputInterface $output): string
{
$this
->setName('dev:theme:list')
->setDescription('Lists all available themes')
->addFormatOption()
;
return 'Themes';
}

/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int
* {@inheritDoc}
*/
protected function execute(InputInterface $input, OutputInterface $output): int
public function getListHeader(InputInterface $input, OutputInterface $output): array
{
$this->detectMagento($output);
if (!$this->initMagento()) {
return 0;
}
return ['label'];
}

/**
* {@inheritDoc}
*/
public function getListData(InputInterface $input, OutputInterface $output): array
{
$packages = $this->getThemes();
$table = [];
foreach ($packages as $package => $themes) {
Expand All @@ -43,17 +56,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
}

$tableHelper = $this->getTableHelper();
$tableHelper
->setHeaders(['Theme'])
->renderByFormat($output, $table, $input->getOption('format'));
return 0;
return $table;
}

/**
* @return array
*/
protected function getThemes()
protected function getThemes(): array
{
if ($this->_magentoMajorVersion == self::MAGENTO_MAJOR_VERSION_2) {
$collection = Mage::getModel('Mage_Core_Model_Theme')->getLabelsCollection();
Expand Down

0 comments on commit dd5c13e

Please sign in to comment.