N98\Magento\Command\AbstractMagentoStoreConfigCommand::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);
        if ($this->initMagento()) {
            $runOnStoreView = false;
            if ($this->scope == self::SCOPE_STORE_VIEW || $this->scope == self::SCOPE_STORE_VIEW_GLOBAL && !$input->getOption('global')) {
                $runOnStoreView = true;
            }
            if ($runOnStoreView) {
                $store = $this->_initStore($input, $output);
            } else {
                $store = \Mage::app()->getStore(\Mage_Core_Model_App::ADMIN_STORE_ID);
            }
        }
        if ($input->getOption('on')) {
            $isFalse = true;
        } elseif ($input->getOption('off')) {
            $isFalse = false;
        } else {
            $isFalse = !\Mage::getStoreConfigFlag($this->configPath, $store->getId());
        }
        $this->_beforeSave($store, $isFalse);
        \Mage::app()->getConfig()->saveConfig($this->configPath, $isFalse ? 1 : 0, $store->getId() == \Mage_Core_Model_App::ADMIN_STORE_ID ? 'default' : 'stores', $store->getId());
        $comment = '<comment>' . $this->toggleComment . '</comment> ' . '<info>' . (!$isFalse ? $this->falseName : $this->trueName) . '</info>' . ($runOnStoreView ? ' <comment>for store</comment> <info>' . $store->getCode() . '</info>' : '');
        $output->writeln($comment);
        $this->_afterSave($store, $isFalse);
        $input = new StringInput('cache:flush');
        $this->getApplication()->run($input, new NullOutput());
    }