N98\Magento\Command\Config\GetCommand::execute PHP Method

execute() protected method

protected execute ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output ) : integer | void
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
return integer | void
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->detectMagento($output, true);
        if (!$this->initMagento()) {
            return;
        }
        /* @var $collection \Mage_Core_Model_Resource_Db_Collection_Abstract */
        $collection = $this->_getConfigDataModel()->getCollection();
        $searchPath = $input->getArgument('path');
        if (substr($input->getArgument('path'), -1, 1) === '/') {
            $searchPath .= '*';
        }
        $collection->addFieldToFilter('path', array('like' => str_replace('*', '%', $searchPath)));
        if ($scope = $input->getOption('scope')) {
            $collection->addFieldToFilter('scope', array('eq' => $scope));
        }
        if ($scopeId = $input->getOption('scope-id')) {
            $collection->addFieldToFilter('scope_id', array('eq' => $scopeId));
        }
        $collection->addOrder('path', 'ASC');
        // sort according to the config overwrite order
        // trick to force order default -> (f)website -> store , because f comes after d and before s
        $collection->addOrder('REPLACE(scope, "website", "fwebsite")', 'ASC');
        $collection->addOrder('scope_id', 'ASC');
        if ($collection->count() == 0) {
            $output->writeln(sprintf("Couldn't find a config value for \"%s\"", $input->getArgument('path')));
            return;
        }
        foreach ($collection as $item) {
            $table[] = array('path' => $item->getPath(), 'scope' => $item->getScope(), 'scope_id' => $item->getScopeId(), 'value' => $this->_formatValue($item->getValue(), $input->getOption('decrypt') ? 'decrypt' : false));
        }
        ksort($table);
        if ($input->getOption('update-script')) {
            $this->renderAsUpdateScript($output, $table);
        } elseif ($input->getOption('magerun-script')) {
            $this->renderAsMagerunScript($output, $table);
        } else {
            $this->renderAsTable($output, $table, $input->getOption('format'));
        }
    }