/** * @{inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $question = '<info>Please enter the full name of the project:</info>'; $name = Application::ask($question, $input, $output, function ($answer) { if ($answer == null) { throw new \RuntimeException('The name of the project can\'t be empty.'); } return $answer; }); $question = '<info>Please enter the short name (acronym) of the project:</info>'; $acronym = Application::ask($question, $input, $output, function ($answer) { if ($answer == null) { throw new \RuntimeException('The acronym of the project can\'t be empty.'); } return $answer; }); $question = '<info>Please enter the git repository url:</info>'; $repositoryUrl = Application::ask($question, $input, $output, function ($answer) { if ($answer == null) { throw new \RuntimeException('The git repository url can\'t be empty.'); } return $answer; }); $question = '<info>Please enter the url to be able to open the website in your browser:</info>'; $webserverUrl = Application::ask($question, $input, $output, function ($answer) { if ($answer == null) { throw new \RuntimeException('The webserver url can\'t be empty.'); } return $answer; }); // Create a new Project $project = ProjectModel::buildEntity([Project::FIELD_NAME => $name, Project::FIELD_SHORT_NAME => $acronym, Project::FIELD_REPOSITORY_URL => $repositoryUrl, Project::FIELD_VHOST_NAME => $webserverUrl]); $model = new ProjectModel($project); $project = $model->persist(); if ($project) { $output->writeln(sprintf('Project <info>%s</info> (Acronym: <info>%s</info>) successful registered.', $project->getFullName(), $project->getShortName())); } else { $output->writeln(sprintf('Failed to register project <error>%s</error> (Acronym: <error>%s</error>).', $project->getFullName(), $project->getShortName())); } }