/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); if (false !== strpos($input->getFirstArgument(), ':d')) { $output->caution('The use of "config:debug" command is deprecated since version 2.7 and will be removed in 3.0. Use the "debug:config" instead.'); } $name = $input->getArgument('name'); if (empty($name)) { $output->comment('Provide the name of a bundle as the first argument of this command to dump its configuration.'); $output->newLine(); $this->listBundles($output); return; } $extension = $this->findExtension($name); $container = $this->compileContainer(); $configs = $container->getExtensionConfig($extension->getAlias()); $configuration = $extension->getConfiguration($configs, $container); $this->validateConfiguration($extension, $configuration); $configs = $container->getParameterBag()->resolveValue($configs); $processor = new Processor(); $config = $processor->processConfiguration($configuration, $configs); if ($name === $extension->getAlias()) { $output->title(sprintf('Current configuration for extension with alias "%s"', $name)); } else { $output->title(sprintf('Current configuration for "%s"', $name)); } $output->writeln(Yaml::dump(array($extension->getAlias() => $config), 3)); }
protected function execute(InputInterface $input, OutputInterface $output) { $stdout = $output; $output = new SymfonyStyle($input, $output); if (false !== strpos($input->getFirstArgument(), ':l')) { $output->caution('The use of "twig:lint" command is deprecated since version 2.7 and will be removed in 3.0. Use the "lint:twig" instead.'); } $twig = $this->getTwigEnvironment(); if (null === $twig) { $output->error('The Twig environment needs to be set.'); return 1; } $filenames = $input->getArgument('filename'); if (0 === count($filenames)) { if (0 !== ftell(STDIN)) { throw new \RuntimeException('Please provide a filename or pipe template content to STDIN.'); } $template = ''; while (!feof(STDIN)) { $template .= fread(STDIN, 1024); } return $this->display($input, $stdout, $output, array($this->validate($twig, $template, uniqid('sf_')))); } $filesInfo = $this->getFilesInfo($twig, $filenames); return $this->display($input, $stdout, $output, $filesInfo); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); if (false !== strpos($input->getFirstArgument(), ':d')) { $io->caution('The use of "container:debug" command is deprecated since version 2.7 and will be removed in 3.0. Use the "debug:container" instead.'); } $this->validateInput($input); $object = $this->getContainerBuilder(); if ($input->getOption('parameters')) { $object = $object->getParameterBag(); $options = array(); } elseif ($parameter = $input->getOption('parameter')) { $options = array('parameter' => $parameter); } elseif ($input->getOption('tags')) { $options = array('group_by' => 'tags', 'show_private' => $input->getOption('show-private')); } elseif ($tag = $input->getOption('tag')) { $options = array('tag' => $tag, 'show_private' => $input->getOption('show-private')); } elseif ($name = $input->getArgument('name')) { $name = $this->findProperServiceName($input, $io, $object, $name); $options = array('id' => $name); } else { $options = array('show_private' => $input->getOption('show-private')); } $helper = new DescriptorHelper(); $options['format'] = $input->getOption('format'); $options['raw_text'] = $input->getOption('raw'); $options['output'] = $io; $helper->describe($output, $object, $options); if (!$input->getArgument('name') && $input->isInteractive()) { $io->comment('To search for a specific service, re-run this command with a search term. (e.g. <comment>debug:container log</comment>)'); } }
protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); if (false !== strpos($input->getFirstArgument(), ':l')) { $io->caution('The use of "yaml:lint" command is deprecated since version 2.7 and will be removed in 3.0. Use the "lint:yaml" instead.'); } $filename = $input->getArgument('filename'); if (!$filename) { if (0 !== ftell(STDIN)) { throw new \RuntimeException('Please provide a filename or pipe file content to STDIN.'); } $content = ''; while (!feof(STDIN)) { $content .= fread(STDIN, 1024); } return $this->display($input, $output, $io, array($this->validate($content))); } if (0 !== strpos($filename, '@') && !is_readable($filename)) { throw new \RuntimeException(sprintf('File or directory "%s" is not readable', $filename)); } $files = array(); if (is_file($filename)) { $files = array($filename); } elseif (is_dir($filename)) { $files = Finder::create()->files()->in($filename)->name('*.yml'); } else { $dir = $this->getApplication()->getKernel()->locateResource($filename); $files = Finder::create()->files()->in($dir)->name('*.yml'); } $filesInfo = array(); foreach ($files as $file) { $filesInfo[] = $this->validate(file_get_contents($file), $file); } return $this->display($input, $output, $io, $filesInfo); }
protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); if (false !== strpos($input->getFirstArgument(), ':d')) { $io->caution('The use of "twig:debug" command is deprecated since version 2.7 and will be removed in 3.0. Use the "debug:twig" instead.'); } parent::execute($input, $io); }
/** * Unlock the TYPO3 Backend by removing the lock file * * @param SymfonyStyle $io */ protected function unlock(SymfonyStyle $io) { $lockFile = $this->getLockFileName(); if (@is_file($lockFile)) { unlink($lockFile); if (@is_file($lockFile)) { $io->caution('Could not remove lock file "' . $lockFile . '"!'); } else { $io->success('Removed lock file "' . $lockFile . '".'); } } else { $io->note('No lock file "' . $lockFile . '" was found.' . LF . 'Hence no lock can be removed.'); } }
protected function execute(InputInterface $input, OutputInterface $output) { // throw new \Exception('boo'); $directory = realpath($input->getArgument('directory')); $directoryOutput = $input->getArgument('outputdirectory'); /* @var $logger Psr\Log\LoggerInterface */ $this->logger = $this->getContainer()->get('logger'); $io = new SymfonyStyle($input, $output); $io->title('DDD Model Generation'); $clean = $input->hasOption('clean'); if ($clean) { $io->section('Clean output directoty'); $fs = new \Symfony\Component\Filesystem\Filesystem(); try { $fs->remove($directoryOutput); } catch (IOExceptionInterface $e) { $io->error($e->getMessage()); } $io->text('clean of ' . $directoryOutput . ' completed'); } if (is_dir($directory)) { $finder = new Finder(); $finder->search($directory); foreach ($finder->getFindedFiles() as $file) { if (pathinfo($file, PATHINFO_FILENAME) == 'model.yml') { $io->text('Analizzo model.yml in ' . pathinfo($file, PATHINFO_DIRNAME)); $dddGenerator = new DDDGenerator(); $dddGenerator->setLogger($this->logger); $dddGenerator->analyze($file); $dddGenerator->generate($directoryOutput); } } $io->section('Php-Cs-Fixer on generated files'); $fixer = new \Symfony\CS\Console\Command\FixCommand(); $input = new ArrayInput(['path' => $directoryOutput, '--level' => 'psr2', '--fixers' => 'eof_ending,strict_param,short_array_syntax,trailing_spaces,indentation,line_after_namespace,php_closing_tag']); $output = new BufferedOutput(); $fixer->run($input, $output); $content = $output->fetch(); $io->text($content); if (count($this->errors) == 0) { $io->success('Completed generation'); } else { $io->error($this->errors); } } else { $io->caution('Directory ' . $directory . ' not valid'); } // PER I WARNING RECUPERABILI //$io->note('Generate Class'); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); $io->title('Router Apache Dumper'); $io->caution('The router:dump-apache command is deprecated since version 2.5 and will be removed in 3.0.'); $router = $this->getContainer()->get('router'); $dumpOptions = array(); if ($input->getArgument('script_name')) { $dumpOptions['script_name'] = $input->getArgument('script_name'); } if ($input->getOption('base-uri')) { $dumpOptions['base_uri'] = $input->getOption('base-uri'); } $dumper = new ApacheMatcherDumper($router->getRouteCollection()); $io->writeln($dumper->dump($dumpOptions), OutputInterface::OUTPUT_RAW); }
/** * {@inheritdoc} * * @throws \InvalidArgumentException When route does not exist */ protected function execute(InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); if (false !== strpos($input->getFirstArgument(), ':d')) { $output->caution('The use of "router:debug" command is deprecated since version 2.7 and will be removed in 3.0. Use the "debug:router" instead.'); } $name = $input->getArgument('name'); $helper = new DescriptorHelper(); if ($name) { $route = $this->getContainer()->get('router')->getRouteCollection()->get($name); if (!$route) { throw new \InvalidArgumentException(sprintf('The route "%s" does not exist.', $name)); } $this->convertController($route); $helper->describe($output, $route, array('format' => $input->getOption('format'), 'raw_text' => $input->getOption('raw'), 'name' => $name, 'output' => $output)); } else { $routes = $this->getContainer()->get('router')->getRouteCollection(); foreach ($routes as $route) { $this->convertController($route); } $helper->describe($output, $routes, array('format' => $input->getOption('format'), 'raw_text' => $input->getOption('raw'), 'show_controllers' => $input->getOption('show-controllers'), 'output' => $output)); } }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); if (false !== strpos($input->getFirstArgument(), ':d')) { $output->caution('The use of "translation:debug" command is deprecated since version 2.7 and will be removed in 3.0. Use the "debug:translation" instead.'); } $locale = $input->getArgument('locale'); $domain = $input->getOption('domain'); $loader = $this->getContainer()->get('translation.loader'); $kernel = $this->getContainer()->get('kernel'); // Define Root Path to App folder $rootPath = $kernel->getRootDir(); // Override with provided Bundle info if (null !== $input->getArgument('bundle')) { try { $rootPath = $kernel->getBundle($input->getArgument('bundle'))->getPath(); } catch (\InvalidArgumentException $e) { // such a bundle does not exist, so treat the argument as path $rootPath = $input->getArgument('bundle'); if (!is_dir($rootPath)) { throw new \InvalidArgumentException(sprintf('"%s" is neither an enabled bundle nor a directory.', $rootPath)); } } } // get bundle directory $translationsPath = $rootPath . '/Resources/translations'; // Extract used messages $extractedCatalogue = new MessageCatalogue($locale); if (is_dir($rootPath . '/Resources/views')) { $this->getContainer()->get('translation.extractor')->extract($rootPath . '/Resources/views', $extractedCatalogue); } // Load defined messages $currentCatalogue = new MessageCatalogue($locale); if (is_dir($translationsPath)) { $loader->loadMessages($translationsPath, $currentCatalogue); } // Merge defined and extracted messages to get all message ids $mergeOperation = new MergeOperation($extractedCatalogue, $currentCatalogue); $allMessages = $mergeOperation->getResult()->all($domain); if (null !== $domain) { $allMessages = array($domain => $allMessages); } // No defined or extracted messages if (empty($allMessages) || null !== $domain && empty($allMessages[$domain])) { $outputMessage = sprintf('No defined or extracted messages for locale "%s"', $locale); if (null !== $domain) { $outputMessage .= sprintf(' and domain "%s"', $domain); } $output->warning($outputMessage); return; } // Load the fallback catalogues $fallbackCatalogues = array(); $translator = $this->getContainer()->get('translator'); if ($translator instanceof Translator) { foreach ($translator->getFallbackLocales() as $fallbackLocale) { if ($fallbackLocale === $locale) { continue; } $fallbackCatalogue = new MessageCatalogue($fallbackLocale); $loader->loadMessages($translationsPath, $fallbackCatalogue); $fallbackCatalogues[] = $fallbackCatalogue; } } // Display header line $headers = array('State', 'Domain', 'Id', sprintf('Message Preview (%s)', $locale)); foreach ($fallbackCatalogues as $fallbackCatalogue) { $headers[] = sprintf('Fallback Message Preview (%s)', $fallbackCatalogue->getLocale()); } $rows = array(); // Iterate all message ids and determine their state foreach ($allMessages as $domain => $messages) { foreach (array_keys($messages) as $messageId) { $value = $currentCatalogue->get($messageId, $domain); $states = array(); if ($extractedCatalogue->defines($messageId, $domain)) { if (!$currentCatalogue->defines($messageId, $domain)) { $states[] = self::MESSAGE_MISSING; } } elseif ($currentCatalogue->defines($messageId, $domain)) { $states[] = self::MESSAGE_UNUSED; } if (!in_array(self::MESSAGE_UNUSED, $states) && true === $input->getOption('only-unused') || !in_array(self::MESSAGE_MISSING, $states) && true === $input->getOption('only-missing')) { continue; } foreach ($fallbackCatalogues as $fallbackCatalogue) { if ($fallbackCatalogue->defines($messageId, $domain) && $value === $fallbackCatalogue->get($messageId, $domain)) { $states[] = self::MESSAGE_EQUALS_FALLBACK; break; } } $row = array($this->formatStates($states), $domain, $this->formatId($messageId), $this->sanitizeString($value)); foreach ($fallbackCatalogues as $fallbackCatalogue) { $row[] = $this->sanitizeString($fallbackCatalogue->get($messageId, $domain)); } $rows[] = $row; } } $output->table($headers, $rows); }
<?php use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; //Ensure has single blank line between blocks return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); $output->warning('Warning'); $output->caution('Caution'); $output->error('Error'); $output->success('Success'); $output->note('Note'); $output->block('Custom block', 'CUSTOM', 'fg=white;bg=green', 'X ', true); };
<?php use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; //Ensure has single blank line at start when using block element return function (InputInterface $input, OutputInterface $output) { $output = new SymfonyStyle($input, $output); $output->caution('Lorem ipsum dolor sit amet'); };
/** * Check if the core is up to date * * @param InputInterface $input Input stream, used to get the options. * @param SymfonyStyle $io IO handler, for formatted and unified IO * @param string $stability Force a given stability * @param bool $recheck Disallow the use of the cache * @return int */ protected function check_core(InputInterface $input, SymfonyStyle $io, $stability, $recheck) { $version_helper = $this->phpbb_container->get('version_helper'); $version_helper->force_stability($stability); $updates_available = $version_helper->get_suggested_updates($recheck); if ($input->getOption('verbose')) { $io->title('phpBB core'); $io->note($this->language->lang('CURRENT_VERSION') . $this->language->lang('COLON') . ' ' . $this->config['version']); } if (!empty($updates_available)) { $io->caution($this->language->lang('UPDATE_NEEDED')); if ($input->getOption('verbose')) { $this->display_versions($io, $updates_available); } return 1; } else { if ($input->getOption('verbose')) { $io->success($this->language->lang('UPDATE_NOT_NEEDED')); } return 0; } }
/** * @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); } } }
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); }