/** * @return Changelog */ protected function getChangelog() { $changelogPath = $this->environment->getChangelogPath(); if (!$this->environment->hasChangelog() && $this->output->confirm('No CHANGELOG.md exists, create it?')) { $stub = file_get_contents(__DIR__ . '/../../stubs/CHANGELOG.md'); file_put_contents($changelogPath, $stub); } return new Changelog($changelogPath); }
protected function execute(InputInterface $input, OutputInterface $output) { $this->io = new SymfonyStyle($input, $output); $this->sort = $input->getOption('sort'); $this->sleepTime = $input->getOption('sleepTime'); if (!$input->hasOption('sleepTime') && $output->getVerbosity() >= OutputInterface::VERBOSITY_NORMAL) { $this->sleepTime = 25; } // Transform milliseconds in microseconds for usleep() $this->sleepTime = $this->sleepTime * 1000; $this->numberOfCodesToGenerate = $input->getOption('amount'); // The length of each outputted code $this->codeLength = $input->getOption('length'); // All possible chars. By default, 'A' to 'Z' and '0' to '9' $this->possibleChars = str_split($input->getOption('characters')); $baseNumberOfChars = count($this->possibleChars); $this->possibleChars = array_unique($this->possibleChars); // If there's an error here, we'll say it later $maxPossibleNumberOfCombinations = pow(count($this->possibleChars), $this->codeLength); if ($maxPossibleNumberOfCombinations < $this->numberOfCodesToGenerate) { $this->io->error(sprintf('Cannot generate %s combinations because there are only %s combinations possible', number_format($this->numberOfCodesToGenerate, 0, '', ' '), number_format($maxPossibleNumberOfCombinations, 0, '', ' '))); return 1; } else { $this->io->block(sprintf('Generating %s combinations.', number_format($this->numberOfCodesToGenerate, 0, '', ' ')), null, 'info'); if ($maxPossibleNumberOfCombinations > $this->numberOfCodesToGenerate) { $this->io->block(sprintf('Note: If you need you can generate %s more combinations (with a maximum of %s).', number_format($maxPossibleNumberOfCombinations - $this->numberOfCodesToGenerate, 0, '', ' '), number_format($maxPossibleNumberOfCombinations, 0, '', ' ')), null, 'comment'); } } $this->io->block('Available characters:'); $this->io->block(implode('', $this->possibleChars), null, 'info'); $codesList = $this->doGenerate(); $outputFile = $input->getOption('output'); if ($outputFile) { $save = true; if (file_exists($outputFile)) { $save = $this->io->confirm(sprintf('File %s exists. Erase it?', $outputFile), false); } if ($save) { $this->io->block(sprintf('Output results to %s', $outputFile), null, 'info'); if (!file_put_contents($outputFile, implode("\n", $codesList))) { throw new \Exception(sprintf('Could not write to %s...', $outputFile)); } } } else { $this->io->text($codesList); } if ($baseNumberOfChars !== count($this->possibleChars)) { $this->io->warning(sprintf('We detected that there were duplicate characters in "%s", so we removed them.', $input->getOption('characters'))); } return 0; }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); $io->title('Pre-commit delete'); $git = new GitVersionControl(); $projectBase = $git->getProjectBase(); $hookDir = $projectBase . '/.git/hooks'; if (!$io->confirm('Are you sure to remove Pre-commit hooks on this project?', true)) { exit(0); } $output->writeln(''); if (!is_dir($hookDir)) { $io->error(sprintf('The git hook directory does not exist (%s)', $hookDir)); exit(1); } $target = $hookDir . '/pre-commit'; $fs = new Filesystem(); if (is_file($target)) { $fs->remove($target); $io->success('pre-commit was deleted'); exit(0); } $io->error(sprintf('pre-commit file does\'nt exist (%s)', $target)); exit(1); }
/** * @return bool */ private function askToInstall() { if (array_key_exists($this->workingLocale, $this->installedLocale)) { $reinstallLocale = $this->formatter->confirm('The locale is already installed, would you like to reinstall and overwrite the current translations?', false); if (!$reinstallLocale) { return true; } $this->installWorkingLocale(true); return true; } $install = $this->formatter->confirm('Would you like to install this locale?'); if (!$install) { return false; } $this->formatter->writeln('<info>Before you can enable a new locale you need to authenticate to be able to create the pages</info>'); while (!Authentication::loginUser($this->formatter->ask('Login'), $this->formatter->askHidden('Password'))) { $this->formatter->error('Failed to login, please try again'); } if (!Authentication::isAllowedAction('Copy', 'Pages')) { $this->formatter->error('Your profile doesn\'t have the permission to execute the action Copy of the Pages module'); return false; } $this->installWorkingLocale(); $this->formatter->writeln('<info>Copying pages from the default locale to the current locale</info>'); BackendPagesModel::copy($this->defaultEnabledLocale, $this->workingLocale); return true; }
/** * Push the tags to Git. */ protected function pushTags() { if (!$this->output->confirm('Tag and push to remote?')) { return false; } $commands = [['git', 'add', '--all'], ['git', 'commit', '-vam', 'Create version ' . $this->version], ['git', 'tag', $this->version], ['git', 'push'], ['git', 'push', '--tags']]; foreach ($commands as $command) { $this->execute($command); } }
/** * Thows an exception if the specified path is not valid. * * @param string $path * * @return void * * @throws \SheetFaker\PathException */ protected function throwIfInvalidPath($path) { if (is_writable(dirname($path))) { if ($file_exists = file_exists($path)) { if ($this->output->confirm('The file exists, do you want to remove it? [y|N]', false)) { unlink($path); return; } throw new PathException("{$path} the specified file already exists."); } return; } throw new PathException("{$path} is not writable."); }
protected function execute(InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); $queue = $this->queueFactory->createQueue($input->getArgument('queue')); if ($input->isInteractive()) { if (!$output->confirm(sprintf(static::CONFIRM_MSG, $queue->getName()), false)) { return; } } $count = $this->queueRegistry->deregister($queue); $output->success('Deleted queue "' . $queue->getName() . '"'); if ($count) { $output->note('Removed ' . $count . ' jobs.'); } }
/** * @param InputInterface $input * @param OutputInterface|Output $output * @return void */ protected function execute(InputInterface $input, OutputInterface $output) { $this->getLogger()->debug('Start', ['command_name' => $this->getName(), 'args' => $input->getArguments(), 'opts' => $input->getOptions()]); $optionDryRun = $input->getOption('dry-run'); $repositories = $this->getRepositoryModelList(); $projectModel = $repositories->getProjectModel(); $xmlFilename = implode(DIRECTORY_SEPARATOR, [$projectModel->getAbsolutePath(), '.idea', 'vcs.xml']); $fileSystem = new Filesystem(); if (!$fileSystem->exists($xmlFilename)) { $this->getSymfonyStyle()->error(sprintf('Config file "%s" not found', $xmlFilename)); } $existsMap = []; $simpleXml = simplexml_load_file($xmlFilename); foreach ($simpleXml->component->children() as $child) { /** @var \SimpleXMLElement $child */ $existsMap[] = (string) $child->attributes()['directory']; } $vendors = []; foreach ($this->getRepositoryModelList()->getAll() as $model) { $tmp = '$PROJECT_DIR$'; if ($model->getPath()) { $tmp .= DIRECTORY_SEPARATOR . $model->getPath(); } $vendors[] = $tmp; } $symfonyStyle = new SymfonyStyle($input, $output); $newDirs = array_diff($vendors, $existsMap); if (count($newDirs)) { $question = sprintf('Script will add %d new dirs, would you like to continue?', count($newDirs)); if ($symfonyStyle->confirm($question, true)) { foreach ($newDirs as $dir) { $mapping = $simpleXml->component->addChild('mapping', ''); $mapping->addAttribute('directory', $dir); $mapping->addAttribute('vcs', 'Git'); } $dom = dom_import_simplexml($simpleXml)->ownerDocument; $dom->preserveWhiteSpace = false; $dom->formatOutput = true; if (!$optionDryRun) { $fileSystem->dumpFile($xmlFilename, $dom->saveXML()); } $symfonyStyle->success(sprintf('File "%s" updated', $xmlFilename)); } } else { $symfonyStyle->note('Changes not found'); } $this->getLogger()->debug('Finish', ['command_name' => $this->getName()]); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); $job = new Job($input->getArgument('target')); // @todo remove new Job. @todo arguments if ($input->isInteractive()) { if (!$output->confirm(sprintf('you sure?', $job->getJobClass()), false)) { return; } } if (true === ($result = $this->jobPerformer->perform($job))) { $output->success('Job "' . $job->getJobClass() . '" with arguments (?) successfully performed'); } else { throw $result; } }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); $io->title('Pre-commit install'); $git = new GitVersionControl(); $projectBase = $git->getProjectBase(); $phpunit = $io->confirm('Enable PhpUnit ?', true); $source = realpath($projectBase); $hookDir = $source . '/.git/hooks'; $defaultPhpUnitConfFile = $source . '/' . self::PHPUNIT_DEFAULT_CONF_FILENAME; $precommitCommand = sprintf('precommit check%s', $phpunit ? ' --phpunit true' : ''); if ($phpunit) { $phpunitPath = $io->ask('Specify Phpunit bin path [example: vendor/bin/phpunit] ? : ', 'phpunit'); $phpunitConfFile = $io->ask('Specify Phpunit config file path ? : ', $defaultPhpUnitConfFile); if ($phpunitPath != '') { if (strpos($phpunitPath, '/') !== false) { $phpunitPath = $source . '/' . $phpunitPath; if (!is_file($phpunitPath)) { $io->error(sprintf('No phpunit bin found "%s"', $phpunitPath)); exit(1); } } } if (!is_file($phpunitConfFile)) { $io->error(sprintf('No phpunit conf file found "%s"', $phpunitConfFile)); exit(1); } $precommitCommand .= $phpunitPath != 'phpunit' ? ' --phpunit-bin-path ' . $phpunitPath : ''; $precommitCommand .= $phpunitConfFile != $defaultPhpUnitConfFile ? ' --phpunit-conf ' . $phpunitConfFile : ''; } if (!is_dir($hookDir)) { $io->error(sprintf('The git hook directory does not exist (%s)', $hookDir)); exit(1); } $target = $hookDir . '/pre-commit'; $fs = new Filesystem(); if (!is_file($target)) { $fileContent = sprintf("#!/bin/sh\n%s", $precommitCommand); $fs->dumpFile($target, $fileContent); chmod($target, 0755); $io->success('pre-commit file correctly updated'); } else { $io->note(sprintf('A pre-commit file is already exist. Please add "%s" at the end !', $precommitCommand)); } exit(0); }
/** * Password Replace action * * @param SymfonyStyle $helper * * @return null */ private function actionPasswordReplace(SymfonyStyle $helper) { if (false === $helper->confirm('Are you sure? Only use this for development purposes!', false)) { return null; } $userClass = $this->getUserEntityClass(); if (null === $userClass) { throw new \RuntimeException('User entity not found'); } $password = $helper->ask('New password', 'login123'); $userManager = $this->getContainer()->get('fos_user.user_manager'); /** @var User $user */ foreach ($this->getDoctrine()->getRepository($userClass)->findAll() as $user) { $user->setPlainPassword($password); $userManager->updateUser($user); } return null; }
private function updateSchema(SymfonyStyle $io, $queries) { $io->caution("Your database schema needs to be updated. The following queries will be run:"); $io->listing($queries); if ($this->updateDb === false && $io->confirm("Should we run this queries now?", false) === false) { return; } $cmdOutput = new BufferedOutput(); $command = $this->getApplication()->find('doctrine:schema:update'); $force = new ArrayInput(array('--env' => 'dev', '--dump-sql' => true, '--force' => true)); $command->run($force, $cmdOutput); $result = $cmdOutput->fetch(); if (strstr($result, 'Database schema updated successfully!') === false) { $io->error("Couldn't update the schema. Run 'doctrine:schema:update' separately to find out why"); } $io->success("Database schema updated successfully!"); $this->clearMetadata($io); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); $input->isInteractive() ? $io->title('Symfony Password Encoder Utility') : $io->newLine(); $password = $input->getArgument('password'); $userClass = $input->getArgument('user-class'); $emptySalt = $input->getOption('empty-salt'); $encoder = $this->getContainer()->get('security.encoder_factory')->getEncoder($userClass); $bcryptWithoutEmptySalt = !$emptySalt && $encoder instanceof BCryptPasswordEncoder; if ($bcryptWithoutEmptySalt) { $emptySalt = true; } if (!$password) { if (!$input->isInteractive()) { $io->error('The password must not be empty.'); return 1; } $passwordQuestion = $this->createPasswordQuestion(); $password = $io->askQuestion($passwordQuestion); } $salt = null; if ($input->isInteractive() && !$emptySalt) { $emptySalt = true; $io->note('The command will take care of generating a salt for you. Be aware that some encoders advise to let them generate their own salt. If you\'re using one of those encoders, please answer \'no\' to the question below. ' . PHP_EOL . 'Provide the \'empty-salt\' option in order to let the encoder handle the generation itself.'); if ($io->confirm('Confirm salt generation ?')) { $salt = $this->generateSalt(); $emptySalt = false; } } elseif (!$emptySalt) { $salt = $this->generateSalt(); } $encodedPassword = $encoder->encodePassword($password, $salt); $rows = array(array('Encoder used', get_class($encoder)), array('Encoded password', $encodedPassword)); if (!$emptySalt) { $rows[] = array('Generated salt', $salt); } $io->table(array('Key', 'Value'), $rows); if (!$emptySalt) { $io->note(sprintf('Make sure that your salt storage field fits the salt length: %s chars', strlen($salt))); } elseif ($bcryptWithoutEmptySalt) { $io->note('Bcrypt encoder used: the encoder generated its own built-in salt.'); } $io->success('Password encoding succeeded'); }
/** * Function to update the reference index * - if the option --update-refindex is set, do it * - otherwise, if in interactive mode (not having -n set), ask the user * - otherwise assume everything is fine * * @param InputInterface $input holds information about entered parameters * @param SymfonyStyle $io necessary for outputting information * @return void */ protected function updateReferenceIndex(InputInterface $input, SymfonyStyle $io) { // Check for reference index to update $io->note('Finding missing files referenced by TYPO3 requires a clean reference index (sys_refindex)'); if ($input->hasOption('update-refindex') && $input->getOption('update-refindex')) { $updateReferenceIndex = true; } elseif ($input->isInteractive()) { $updateReferenceIndex = $io->confirm('Should the reference index be updated right now?', false); } else { $updateReferenceIndex = false; } // Update the reference index if ($updateReferenceIndex) { $referenceIndex = GeneralUtility::makeInstance(ReferenceIndex::class); $referenceIndex->updateIndex(false, !$io->isQuiet()); } else { $io->writeln('Reference index is assumed to be up to date, continuing.'); } }
protected function execute(InputInterface $input, OutputInterface $output) { $since = $input->getArgument('since'); $dateTimeRequested = null; $io = new SymfonyStyle($input, $output); $io->title('Envoi un mail avec les derniers fichiers à ' . $input->getArgument('for')); if ($since == 'day') { $dateTimeRequested = (new \Datetime())->modify('-1 day'); } elseif ($since == 'week') { $dateTimeRequested = (new \Datetime())->modify('-1 week'); } elseif ($since == 'month') { $dateTimeRequested = (new \Datetime())->modify('-1 month'); } else { throw new HttpException(500, "Excpected variable 'since' with values 'day', 'week', 'month'"); } switch ($since) { case 'day': $sinceFr = 'un jour'; break; case 'week': $sinceFr = 'une semaine'; break; case 'month': $sinceFr = "un mois"; break; } $mailer = $this->getContainer()->get('mailer'); $templating = $this->getContainer()->get('templating'); $users = $this->getContainer()->get('eveg.user.newsletter'); $emails = $users->getUsersEmailsAction(); $emailsList = array(); foreach ($emails as $key => $email) { foreach ($email as $key => $value) { array_push($emailsList, $value); } } $wu = $this->getContainer()->get('eveg_app.whatsup'); $news = $wu->tellMeWhatsNew($limitItems = null, $since = $dateTimeRequested); $io->writeln(count($news) . ' nouveaux documents ajoutés à eVeg depuis ' . $sinceFr . '.'); if ($input->getArgument('for') == 'users') { $io->writeln(count($emailsList) . ' mails à envoyer.'); } if ($input->getArgument('for') == 'admin') { $io->writeln('Envoyer le mail à Admin.'); } $message = \Swift_Message::newInstance()->setSubject('eVeg | Derniers ajouts')->setFrom($this->getContainer()->getParameter('eveg')['feedback']['mail_website_admin'])->setBody($templating->render('evegAppBundle:Emails:newsletterLastUploads.html.twig', array('news' => $news, 'since' => $input->getArgument('since'))), 'text/html'); if ($input->getArgument('for') == 'users') { $message->setBcc($emailsList); } elseif ($input->getArgument('for') == 'admin') { $message->setTo($this->getContainer()->getParameter('eveg')['feedback']['mail_website_admin']); } else { throw new HttpException(500, "Excpected variable 'for' with values 'admin', 'users'"); } if (count($news) > 1) { if ($input->getOption('force') || $io->confirm("Valider l'envoi à " . $input->getArgument('for') . "?", false)) { $mailer->send($message); $io->success('La newsletter a été envoyée.'); } } else { $output->writeln('Aucun mail envoyé'); } }
/** * @param InputInterface $input * @param OutputInterface $output * @return null */ protected function execute(InputInterface $input, OutputInterface $output) { // Get inputs $from = $input->getArgument('from'); $pjtname = $input->getArgument('pjtname'); // Important vars $container = $this->getContainer(); $router = $container->get('router'); $selfBaseUrl = $container->getParameter('spirit_dev_d_box_portal.app.self_base_url'); $em = $container->get('doctrine')->getManager(); $io = new SymfonyStyle($input, $output); // // API's $apiPM = $container->get('spirit_dev_dbox_portal_bundle.api.redmine'); $apiVCS = $container->get('spirit_dev_dbox_portal_bundle.api.gitlab'); $io->title(sprintf('Import project -- %s -- from -- %s --', $pjtname, $from)); $pmProject = null; $vcsProject = null; $dbProject = null; // Import values from PM if requested if ($from == 'pm' || $from == 'both') { $io->section('PM Check'); $pmProjectId = $apiPM->getProjectIdByName($pjtname); if (intval($pmProjectId)) { $tmpPjt = new Project(); $tmpPjt->setRedmineProjectId($pmProjectId); $pmProject = $apiPM->showProject($tmpPjt); $io->success('Project -- ' . $pjtname . ' -- found in PM'); $io->table(array('Name', 'Id', 'Identifier', 'description'), array(array($pmProject['project']['name'], $pmProject['project']['id'], $pmProject['project']['identifier'], empty($pmProject['project']['description']) ? "none" : $pmProject['project']['description']))); } else { $io->error('This project does not exists in PM, check value case'); if ($from != "both") { exit(0); } } } // Import values from VCS if requested if ($from == 'vcs' || $from == 'both') { $io->section('VCS Check'); $vcsProjectId = $apiVCS->getProjectIdByName($pjtname); if (intval($vcsProjectId)) { $vcsProject = $apiVCS->getProject($vcsProjectId); $io->success('Project -- ' . $pjtname . ' -- found in VCS'); $io->table(array('Name', 'Id', 'description', 'SSH Url', 'HTTP Url', 'WEB Url', 'Namespace', 'Issues', 'Wiki', 'Snippets'), array(array($vcsProject['name'], $vcsProject['id'], $vcsProject['description'], $vcsProject['ssh_url_to_repo'], $vcsProject['http_url_to_repo'], $vcsProject['web_url'], $vcsProject['path_with_namespace'], $vcsProject['issues_enabled'], $vcsProject['wiki_enabled'], $vcsProject['snippets_enabled']))); } else { $io->error('This project does not exists in VCS, check value case'); exit(0); } } // Check if project exists in db $io->section('DB Check'); $dbProject = $em->getRepository('SpiritDevDBoxPortalBundle:Project')->findOneBy(array('canonicalName' => strtolower($pjtname))); if ($dbProject) { $io->note('Project -- ' . $pjtname . ' -- already exists in database!'); $io->caution('Local DB Project will be update'); } else { $io->note('Project -- ' . $pjtname . ' -- does not exists in database!'); $io->note('A local DB Project will be created'); } // Starting import $io->section('Starting Importation'); if ($dbProject) { // Updating entity if ($input->getOption('force-update') && $io->confirm('Do you want to continue ?', true)) { // Import PM Values if ($from == "pm" || $from == "both") { $io->writeln('Importing from PM'); $dbProject->setRedmineProjectId($pmProject['project']['id']); $dbProject->setRedmineProjectIdentifier($pmProject['project']['identifier']); $dbProject->setRedmineWebUrl($apiPM->getProjectWebUrl($dbProject)); $io->writeln('Updating PM remote project'); $dbProject->setName($pjtname); $update = $apiPM->updateProject($dbProject); } // Import VCS Values if ($from == "vcs" || $from == "both") { $io->writeln('Importing from VCS'); $dbProject->setGitLabIssueEnabled($vcsProject['issues_enabled']); $dbProject->setGitLabWikiEnabled($vcsProject['wiki_enabled']); $dbProject->setGitLabSnippetsEnabled($vcsProject['snippets_enabled']); $dbProject->setGitLabProjectId($vcsProject['id']); $dbProject->setGitLabSshUrlToRepo($vcsProject['ssh_url_to_repo']); $dbProject->setGitLabHttpUrlToRepo($vcsProject['http_url_to_repo']); $dbProject->setGitLabWebUrl($vcsProject['web_url']); $dbProject->setGitLabNamespace($vcsProject['path_with_namespace']); $io->writeln('Updating VCS remote project'); // Create hooks $nbCommitHookUrl = $selfBaseUrl != 'none' ? $selfBaseUrl . "web_hook/update/nb_commit/" . $dbProject->getId() : $router->generate('spirit_dev_dbox_portal_bundle_webhook_pjt_update_nbcommits', array('pjt_id' => $dbProject->getId()), true); // var_dump($nbCommitHookUrl); $apiVCS->setProjectWebHook($dbProject, $nbCommitHookUrl); // Push hook to ci server $processor = $container->get('spirit_dev_dbox_admin_bundle.admin.processor'); $jenkinsUrl = $processor->defineJenkinsProjectUrl($dbProject); $apiVCS->setProjectWebHook($dbProject, $jenkinsUrl); } $io->writeln('Updating entity'); $dbProject->setName($pjtname); $dbProject->setActive(true); $em->flush(); $io->success('Done'); } else { $io->error('You may reload the command with the --force-update option'); $io->note('php app/console dbox:portal:pmvcs:import ' . $from . ' ' . $pjtname . ' --force-update'); exit(0); } } else { // Creating entity if ($input->getOption('force') && $io->confirm('Do you want to continue ?', true)) { $project = new Project(); // Import PM Values if ($from == "pm" || $from == "both") { $io->writeln('Importing from PM'); $project->setRedmineProjectId($pmProject['project']['id']); $project->setRedmineProjectIdentifier($pmProject['project']['identifier']); $project->setRedmineWebUrl($apiPM->getProjectWebUrl($project)); $io->writeln('Updating PM remote project'); $project->setName($pjtname); $update = $apiPM->updateProject($project); // dump($update); } // Import VCS Values if ($from == "vcs" || $from == "both") { $io->writeln('Importing from VCS'); $project->setGitLabIssueEnabled($vcsProject['issues_enabled']); $project->setGitLabWikiEnabled($vcsProject['wiki_enabled']); $project->setGitLabSnippetsEnabled($vcsProject['snippets_enabled']); $project->setGitLabProjectId($vcsProject['id']); $project->setGitLabSshUrlToRepo($vcsProject['ssh_url_to_repo']); $project->setGitLabHttpUrlToRepo($vcsProject['http_url_to_repo']); $project->setGitLabWebUrl($vcsProject['web_url']); $project->setGitLabNamespace($vcsProject['path_with_namespace']); $io->writeln('Updating VCS remote project'); // Create hooks $nbCommitHookUrl = $selfBaseUrl != 'none' ? $selfBaseUrl . "web_hook/update/nb_commit/" . $project->getId() : $router->generate('spirit_dev_dbox_portal_bundle_webhook_pjt_update_nbcommits', array('pjt_id' => $project->getId()), true); $apiVCS->setProjectWebHook($project, $nbCommitHookUrl); // Push hook to ci server $processor = $container->get('spirit_dev_dbox_admin_bundle.admin.processor'); $jenkinsUrl = $processor->defineJenkinsProjectUrl($project); $apiVCS->setProjectWebHook($project, $jenkinsUrl); } $io->writeln('Creating entity'); $project->setName($pjtname); $project->setActive(true); $em->persist($project); $em->flush(); $io->success('Done'); } else { $io->error('You may reload the command with the --force option'); $io->note('php app/console dbox:portal:pmvcs:import ' . $from . ' ' . $pjtname . ' --force'); exit(0); } } }
<?php use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; //Ensure questions do not output anything when input is non-interactive return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); $output->title('Title'); $output->askHidden('Hidden question'); $output->choice('Choice question with default', array('choice1', 'choice2'), 'choice1'); $output->confirm('Confirmation with yes default', true); $output->text('Duis aute irure dolor in reprehenderit in voluptate velit esse'); };
/** * @param InputInterface $input * @param OutputInterface $output * * @return void */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); if (!($searchPaths = $input->getArgument('fixtures'))) { $searchPaths = $this->getSearchPaths(); } if (count($searchPaths) === 0) { $io->error('No search paths could be determinened.'); return; } $io->section('Determening ORM paths'); $io->listing($searchPaths); $io->section('Registering fixtures'); $registry = new FixtureRegistry($this->getContainer()); foreach ($searchPaths as $path) { $registry->loadFromPath($path); } $fixtures = $registry->getFixtures(); if (!$fixtures) { $io->error('Unable to find any fixtures within the following search paths.'); $io->listing($searchPaths); return; } if ($input->isInteractive() && !$io->confirm('Do you want to begin fixture loading', false)) { return; } $purger = new ORMPurger($this->em); $purger->setPurgeMode(ORMPurger::PURGE_MODE_TRUNCATE); $executor = new ORMExecutor($this->em, $purger); $executor->setLogger(function ($message) use($output) { $output->writeln(sprintf(' <comment>></comment> <info>%s</info>', $message)); }); $io->section('Importing fixtures'); $executor->execute($fixtures, true); $io->success('Complete!'); /* if ($input->isInteractive() && !$input->getOption('append')) { if (!$this->askConfirmation($input, $output, '<question>Careful, database will be purged. Do you want to continue y/N ?</question>', false)) { return; } } */ }
/** * Confirm a question with the user. * * @param string $question * @param bool $default * @return bool */ public function confirm($question, $default = false) { return $this->output->confirm($question, $default); }
/** * @codeCoverageIgnore */ public function confirm($question, $default = true) { return $this->interactive->confirm($question, $default); }