N98\Magento\Command\AbstractMagentoCommand::chooseInstallationFolder PHP Метод

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

protected chooseInstallationFolder ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
    protected function chooseInstallationFolder(InputInterface $input, OutputInterface $output)
    {
        /**
         * @param string $folderName
         *
         * @return string
         */
        $validateInstallationFolder = function ($folderName) use($input) {
            $folderName = rtrim(trim($folderName, ' '), '/');
            // resolve folder-name to current working directory if relative
            if (substr($folderName, 0, 1) == '.') {
                $cwd = OperatingSystem::getCwd();
                $folderName = $cwd . substr($folderName, 1);
            }
            if (empty($folderName)) {
                throw new InvalidArgumentException('Installation folder cannot be empty');
            }
            if (!is_dir($folderName)) {
                if (!@mkdir($folderName, 0777, true)) {
                    throw new InvalidArgumentException('Cannot create folder.');
                }
                return $folderName;
            }
            if ($input->hasOption('noDownload') && $input->getOption('noDownload')) {
                /** @var MagentoHelper $magentoHelper */
                $magentoHelper = new MagentoHelper();
                $magentoHelper->detect($folderName);
                if ($magentoHelper->getRootFolder() !== $folderName) {
                    throw new InvalidArgumentException(sprintf('Folder %s is not a Magento working copy.', $folderName));
                }
                $localXml = $folderName . '/app/etc/local.xml';
                if (file_exists($localXml)) {
                    throw new InvalidArgumentException(sprintf('Magento working copy in %s seems already installed. Please remove %s and retry.', $folderName, $localXml));
                }
            }
            return $folderName;
        };
        if (($installationFolder = $input->getOption('installationFolder')) == null) {
            $defaultFolder = './magento';
            $question[] = "<question>Enter installation folder:</question> [<comment>" . $defaultFolder . "</comment>]";
            $installationFolder = $this->getHelper('dialog')->askAndValidate($output, $question, $validateInstallationFolder, false, $defaultFolder);
        } else {
            // @Todo improve validation and bring it to 1 single function
            $installationFolder = $validateInstallationFolder($installationFolder);
        }
        $this->config['installationFolder'] = realpath($installationFolder);
        \chdir($this->config['installationFolder']);
    }