N98\Util\Console\Helper\ParameterHelper::askWebsite PHP Method

askWebsite() public method

public askWebsite ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output, string $argumentName = 'website' ) : mixed
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
$argumentName string
return mixed
    public function askWebsite(InputInterface $input, OutputInterface $output, $argumentName = 'website')
    {
        /* @var $storeManager \Mage_Core_Model_App */
        $storeManager = \Mage::app();
        $website = null;
        $argumentValue = $input->getArgument($argumentName);
        $hasArgument = $argumentValue !== null;
        if ($hasArgument) {
            try {
                /* @var $website Mage_Core_Model_Website */
                $website = $storeManager->getWebsite($argumentValue);
                return $website;
            } catch (Exception $e) {
                // catch all exceptions
            }
        }
        list($websites, $question) = $this->websitesQuestion($storeManager);
        if (count($websites) === 1) {
            return $storeManager->getWebsite($websites[0]);
        }
        $question[] = '<question>Please select a website: </question>';
        $callback = function ($typeInput) use($websites) {
            if (!isset($websites[$typeInput - 1])) {
                throw new InvalidArgumentException('Invalid website');
            }
            return $websites[$typeInput - 1];
        };
        $websiteId = $this->askAndValidate($output, $question, $callback);
        $website = $storeManager->getWebsite($websiteId);
        return $website;
    }