Skip to content

Commit

Permalink
Merge pull request #535 from LukeOl/command_info_design_settings_deve…
Browse files Browse the repository at this point in the history
…lop_to_develop

Added display current design settings on particular store
  • Loading branch information
cmuench committed May 2, 2015
2 parents 2f04b3b + 0f90de3 commit 90a5a30
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 7 deletions.
1 change: 1 addition & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ commands:
- N98\Magento\Command\Developer\TemplateHintsCommand
- N98\Magento\Command\Developer\Theme\DuplicatesCommand
- N98\Magento\Command\Developer\Theme\ListCommand
- N98\Magento\Command\Developer\Theme\InfoCommand
- N98\Magento\Command\Developer\Translate\InlineAdminCommand
- N98\Magento\Command\Developer\Translate\InlineShopCommand
- N98\Magento\Command\Developer\Translate\SetCommand
Expand Down
81 changes: 74 additions & 7 deletions src/N98/Magento/Command/Developer/Theme/InfoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,99 @@
use N98\Magento\Command\AbstractMagentoCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
use N98\Magento\Command\AbstractMagentoStoreConfigCommand;

/**
* Class InfoCommand
* @codeCoverageIgnore Command is currently not implemented
* @package N98\Magento\Command\Developer\Theme
*/
class InfoCommand extends AbstractMagentoCommand
{
const THEMES_EXCEPTION = '_ua_regexp';

protected $_configNodes = array(
'Theme translations' => 'design/theme/locale',
);

protected $_configNodesWithExceptions = array(
'Design Package Name' => 'design/package/name',
'Theme template' => 'design/theme/template',
'Theme skin' => 'design/theme/skin',
'Theme layout' => 'design/theme/layout',
'Theme default' => 'design/theme/default',
);

protected function configure()
{
$this
->setName('dev:theme:info')
->addArgument('theme', InputArgument::REQUIRED, 'Your theme')
->setDescription('Infos about a theme');
->setDescription('Displays settings of current design on particular store view');
}

/**
* @param \Symfony\Component\Console\Input\\Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\\Symfony\Component\Console\Output\OutputInterface $output
* @return int|void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->detectMagento($output);
if ($this->initMagento()) {
if ( $this->initMagento() ) {
foreach ( \Mage::app()->getWebsites() as $website ) {
/* @var $website \Mage_Core_Model_Website */
foreach ( $website->getStores() as $store ) {
/* @var $store \Mage_Core_Model_Store */
$this->_displayTable($output, $store);
}
}
}
}

protected function _displayTable(OutputInterface $output, \Mage_Core_Model_Store $store)
{
$this->writeSection($output, 'Current design setting on store: '. $store->getWebsite()->getCode() . '/' . $store->getCode());
$storeInfoLines = $this->_parse($this->_configNodesWithExceptions, $store, true);
$storeInfoLines = array_merge($storeInfoLines, $this->_parse($this->_configNodes, $store));

$this->getHelper('table')
->setHeaders(array('Parameter', 'Value'))
->renderByFormat($output, $storeInfoLines);

return $this;
}

/**
* @return array
*/
protected function _parse(array $nodes, \Mage_Core_Model_Store $store, $withExceptions = false)
{
$result = array();
foreach ( $nodes as $nodeLabel => $node ) {
$result[] = array(
$nodeLabel, (string)\Mage::getConfig()->getNode($node, AbstractMagentoStoreConfigCommand::SCOPE_STORE_VIEW, $store->getCode())
);
if ( $withExceptions ) {
$result[] = array(
$nodeLabel . ' exceptions', $this->_parseException($node, $store)
);
}
}
return $result;
}

/**
* @return string
*/
protected function _parseException($node, \Mage_Core_Model_Store $store)
{
$exception = (string)\Mage::getConfig()->getNode($node . self::THEMES_EXCEPTION, AbstractMagentoStoreConfigCommand::SCOPE_STORE_VIEW, $store->getCode());
if ( empty($exception) ) {
return '';
}
$exceptions = unserialize($exception);
$result = array();
foreach ( $exceptions as $expression ) {
$result[] = 'Matched Expression: ' . $expression['regexp'];
$result[] = 'Value: ' . $expression['value'];
}
return implode("\n", $result);
}
}

0 comments on commit 90a5a30

Please sign in to comment.