N98\Magento\Command\System\Url\ListCommand::execute PHP Метод

execute() защищенный Метод

Execute command
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
Результат integer | void
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->detectMagento($output, true);
        if (!$this->initMagento()) {
            return;
        }
        if ($input->getOption('add-all')) {
            $input->setOption('add-categories', true);
            $input->setOption('add-products', true);
            $input->setOption('add-cmspages', true);
        }
        $stores = explode(',', $input->getArgument('stores'));
        $urls = array();
        foreach ($stores as $storeId) {
            $currentStore = \Mage::app()->getStore($storeId);
            /* @var $currentStore \Mage_Core_Model_Store */
            // base url
            $urls[] = $currentStore->getBaseUrl(\Mage_Core_Model_Store::URL_TYPE_WEB);
            $linkBaseUrl = $currentStore->getBaseUrl(\Mage_Core_Model_Store::URL_TYPE_LINK);
            if ($input->getOption('add-categories')) {
                $urls = $this->getUrls('sitemap/catalog_category', $linkBaseUrl, $storeId, $urls);
            }
            if ($input->getOption('add-products')) {
                $urls = $this->getUrls('sitemap/catalog_product', $linkBaseUrl, $storeId, $urls);
            }
            if ($input->getOption('add-cmspages')) {
                $urls = $this->getUrls('sitemap/cms_page', $linkBaseUrl, $storeId, $urls);
            }
        }
        if (count($urls) === 0) {
            return;
        }
        foreach ($urls as $url) {
            // pre-process
            $line = $input->getArgument('linetemplate');
            $line = str_replace('{url}', $url, $line);
            $parts = parse_url($url);
            foreach ($parts as $key => $value) {
                $line = str_replace('{' . $key . '}', $value, $line);
            }
            // ... and output
            $output->writeln($line);
        }
    }