Platformsh\Cli\Command\Local\LocalBuildCommand::execute PHP Метод

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

protected execute ( 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 execute(InputInterface $input, OutputInterface $output)
    {
        $projectRoot = $this->getProjectRoot();
        /** @var \Platformsh\Cli\Helper\QuestionHelper $questionHelper */
        $questionHelper = $this->getHelper('question');
        $sourceDirOption = $input->getOption('source');
        // If no project root is found, ask the user for a source directory.
        if (!$projectRoot && !$sourceDirOption && $input->isInteractive()) {
            $default = file_exists(self::$config->get('service.app_config_file')) || is_dir('.git') ? '.' : null;
            $sourceDirOption = $questionHelper->askInput('Source directory', $default);
        }
        if ($sourceDirOption) {
            $sourceDir = realpath($sourceDirOption);
            if (!is_dir($sourceDir)) {
                throw new \InvalidArgumentException('Source directory not found: ' . $sourceDirOption);
            } elseif (file_exists($sourceDir . self::$config->get('local.project_config'))) {
                $projectRoot = $sourceDir;
                $sourceDir = $projectRoot;
            }
        } elseif (!$projectRoot) {
            throw new RootNotFoundException('Project root not found. Specify --source or go to a project directory.');
        } else {
            $sourceDir = $projectRoot;
        }
        $destination = $input->getOption('destination');
        // If no project root is found, ask the user for a destination path.
        if (!$projectRoot && !$destination && $input->isInteractive()) {
            $default = is_dir($sourceDir . '/.git') && $sourceDir === getcwd() ? self::$config->get('local.web_root') : null;
            $destination = $questionHelper->askInput('Build destination', $default);
        }
        if ($destination) {
            /** @var \Platformsh\Cli\Helper\FilesystemHelper $fsHelper */
            $fsHelper = $this->getHelper('fs');
            $destination = $fsHelper->makePathAbsolute($destination);
        } elseif (!$projectRoot) {
            throw new RootNotFoundException('Project root not found. Specify --destination or go to a project directory.');
        } else {
            $destination = $projectRoot . '/' . self::$config->get('local.web_root');
        }
        // Ensure no conflicts between source and destination.
        if (strpos($sourceDir, $destination) === 0) {
            throw new \InvalidArgumentException("The destination '{$destination}' conflicts with the source '{$sourceDir}'");
        }
        // Ask the user about overwriting the destination, if a project root was
        // not found.
        if (!$projectRoot && file_exists($destination)) {
            if (!is_writable($destination)) {
                $this->stdErr->writeln("The destination exists and is not writable: <error>{$destination}</error>");
                return 1;
            }
            $default = is_link($destination);
            if (!$questionHelper->confirm("The destination exists: <comment>{$destination}</comment>. Overwrite?", $default)) {
                return 1;
            }
        }
        // Map input options to build settings.
        $settings = [];
        foreach ($input->getOptions() as $name => $value) {
            $settings[$name] = $value;
        }
        $apps = $input->getArgument('app');
        $builder = new LocalBuild($settings, self::$config, $this->stdErr);
        $success = $builder->build($sourceDir, $destination, $apps);
        return $success ? 0 : 1;
    }
LocalBuildCommand