JMOlivas\Phpqa\Command\InitCommand::execute PHP Method

execute() protected method

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)
    {
        $application = $this->getApplication();
        $config = $application->getConfig();
        $global = false;
        if ($input->hasOption('global')) {
            $global = $input->getOption('global');
        }
        $project = $input->getOption('project');
        if ($global && $project) {
            throw new \Exception('Options `project` and `global` can not used in combination.');
        }
        if (!$global && (!$project || !in_array($project, $this->projects))) {
            throw new \Exception(sprintf('You must provide a valid project value (%s)', implode(',', $this->projects)));
        }
        $override = false;
        if ($input->hasOption('override')) {
            $override = $input->getOption('override');
        }
        if ($global) {
            $this->copyHomeDirectory($output, $config, $override);
        }
        if (!$global) {
            $this->copyCurrentDirectory($output, $config, $override, $project);
        }
    }