writeln() публичный Метод

public writeln ( $messages, $type = self::OUTPUT_NORMAL )
 /**
  * {@inheritdoc}
  *
  * @throws \LogicException
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $name = $input->getArgument('name');
     if (empty($name)) {
         $io->comment('Provide the name of a bundle as the first argument of this command to dump its default configuration.');
         $io->newLine();
         $this->listBundles($output);
         return;
     }
     $extension = $this->findExtension($name);
     $configuration = $extension->getConfiguration(array(), $this->getContainerBuilder());
     $this->validateConfiguration($extension, $configuration);
     if ($name === $extension->getAlias()) {
         $message = sprintf('Default configuration for extension with alias: "%s"', $name);
     } else {
         $message = sprintf('Default configuration for "%s"', $name);
     }
     switch ($input->getOption('format')) {
         case 'yaml':
             $io->writeln(sprintf('# %s', $message));
             $dumper = new YamlReferenceDumper();
             break;
         case 'xml':
             $io->writeln(sprintf('<!-- %s -->', $message));
             $dumper = new XmlReferenceDumper();
             break;
         default:
             $io->writeln($message);
             throw new \InvalidArgumentException('Only the yaml and xml formats are supported.');
     }
     $io->writeln($dumper->dump($configuration, $extension->getNamespace()));
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $this->destinationPath = $input->getArgument('destination');
     $this->version = $input->getArgument('version');
     if (file_exists($this->destinationPath)) {
         throw new \InvalidArgumentException(sprintf('The directory %s already exists', $this->destinationPath));
     }
     $this->filesystem = new Filesystem();
     $io->writeln(PHP_EOL . ' Downloading Majora Standard Edition...' . PHP_EOL);
     $this->download($output);
     $io->writeln(PHP_EOL . PHP_EOL . ' Preparing project...' . PHP_EOL);
     $io->note('Extracting...');
     $this->extract();
     $io->note('Installing dependencies (this operation may take a while)...');
     $outputCallback = null;
     if ($output->getVerbosity() === OutputInterface::VERBOSITY_VERY_VERBOSE) {
         $outputCallback = function ($type, $buffer) use($output) {
             $output->write($buffer);
         };
     }
     $this->installComposerDependencies($outputCallback);
     $io->note('Cleaning...');
     $this->clean();
     $io->success([sprintf('Majora Standard Edition %s was successfully installed', $this->version)]);
 }
Пример #3
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int|null|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->io->title($this->getDescription());
     foreach ($this->apiViews as $apiView) {
         $bufferOutput = new BufferedOutput();
         $this->application->run(new StringInput(sprintf('api:doc:dump --view=%s', $apiView)), $bufferOutput);
         $viewDump = $bufferOutput->fetch();
         $viewDumpFile = __DIR__ . '/../Resources/doc/' . $apiView . '-api-doc.md';
         file_put_contents($viewDumpFile, $viewDump);
         $this->io->writeln(sprintf("%s -> view dumped to %s", $apiView, $viewDumpFile));
     }
 }
Пример #4
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output = new SymfonyStyle($input, $output);
     $this->partInput = new ConsoleInput($output);
     $creator = $this->makeCreator($input);
     $package = $creator->create();
     $this->config->addPackage($package);
     $path = $package->getPath();
     $output->writeln("<info>Package directory {$path} created.</info>");
     $output->writeln("<comment>Running composer install for new package...</comment>");
     Shell::run('composer install --prefer-dist', $package->getPath());
     $output->writeln("<info>Package successfully created.</info>");
     $this->refreshAutoloads($output, $package);
 }
Пример #5
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int|null|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->io->title($this->getDescription());
     $roles = explode(',', $input->getArgument('roles'));
     if (!is_array($roles) || count($roles) < 1) {
         throw new \LogicException('Specify min. 1 role');
     }
     $users = $this->em->getRepository('OjsUserBundle:User')->findUsersByJournalRole($roles);
     $this->io->writeln('"user_id", "username", "first_name", "last_name", "email"');
     /** @var User $user */
     foreach ($users as $user) {
         $this->io->writeln(sprintf('%s, "%s", "%s", "%s", "%s"', $user->getId(), $user->getUsername(), $user->getFirstName(), $user->getLastName(), $user->getEmail()));
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->title('Exporting databases');
     $io->section('Exporting all databases');
     $strategies = $this->collectorDbStrategy->collectDatabasesStrategies();
     $totalStrategies = count($strategies);
     $io->writeln($totalStrategies . ' strategie(s) found.');
     $progressBar = new ProgressBar($output, $totalStrategies);
     $progressBar->setFormat(self::PROGRESS_BAR_FORMAT);
     $progressBar->setMessage('Beginning backuping');
     $this->eventDispatcher->dispatch(Events::BACKUP_BEGINS, new BackupBeginsEvent($output));
     $progressBar->start();
     $reportContent = new \ArrayObject();
     foreach ($strategies as $strategy) {
         $strategyIdentifier = $strategy->getIdentifier();
         $setProgressBarMessage = function ($message) use($progressBar, $strategyIdentifier) {
             $message = "[{$strategyIdentifier}] {$message}";
             $progressBar->setMessage($message);
             $progressBar->display();
         };
         $exportedFiles = $this->processorDatabaseDumper->dump($strategy, $setProgressBarMessage);
         $reportContent->append("Backuping of the database: {$strategyIdentifier}");
         foreach ($exportedFiles as $file) {
             $filename = $file->getPath();
             $reportContent->append("\t→ {$filename}");
         }
         $progressBar->advance();
     }
     $progressBar->finish();
     $io->newLine(2);
     $io->section('Report');
     $io->text($reportContent->getArrayCopy());
     $this->eventDispatcher->dispatch(Events::BACKUP_ENDS, new BackupEndsEvent($output));
 }
Пример #7
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     if (false !== strpos($input->getFirstArgument(), ':d')) {
         $io->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)) {
         $io->comment('Provide the name of a bundle as the first argument of this command to dump its configuration.');
         $io->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()) {
         $io->title(sprintf('Current configuration for extension with alias "%s"', $name));
     } else {
         $io->title(sprintf('Current configuration for "%s"', $name));
     }
     $io->writeln(Yaml::dump(array($extension->getAlias() => $config), 10));
 }
Пример #8
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $name = $input->getArgument('name');
     if (empty($name)) {
         $io->comment('Provide the name of a bundle as the first argument of this command to dump its configuration.');
         $io->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()) {
         $io->title(sprintf('Current configuration for extension with alias "%s"', $name));
     } else {
         $io->title(sprintf('Current configuration for "%s"', $name));
     }
     $io->writeln(Yaml::dump(array($extension->getAlias() => $config), 3));
 }
Пример #9
0
    /**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $io = new SymfonyStyle($input, $output);
        $commandTitle = '                     Majora Installer                    ';
        $commandHelper = <<<COMMAND_HELPER
    <info>This is installer for majora-standard-edition</info>
   
    Create project to <info>current directory</info>: 
    
        <comment>majora new <Project Name></comment>
        
    Create project <info>for path</info>: 
    
        <comment>majora new <Path></comment>
        
    Create project <info>based on a specific branch</info>: 
    
        <comment>majora new <Project Name> <BranchName> </comment>
        
        
        
COMMAND_HELPER;
        $io->title($commandTitle);
        $io->writeln($commandHelper);
    }
Пример #10
0
 private function syncEventDescription(EventDetail $eventDetail, $lang)
 {
     $findTemplates = $this->em->getRepository('OjsJournalBundle:MailTemplate')->findBy(['type' => $eventDetail->getName(), 'lang' => $lang]);
     foreach ($findTemplates as $template) {
         $this->io->writeln(sprintf('Updating description for  -> %s', $eventDetail->getName()));
         $template->setDescription($this->translator->trans($eventDetail->getName(), [], null, $lang));
         $template->setUpdatedBy('cli');
         $this->em->persist($template);
     }
 }
Пример #11
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->title('Ajouter un fichier');
     $em = $this->getcontainer()->get('doctrine.orm.default_entity_manager');
     $SCrepo = $em->getRepository('evegAppBundle:SyntaxonCore');
     $UserRepo = $em->getRepository('evegUserBundle:User');
     $s = $SCrepo->findById($input->getArgument('SCid'));
     $SCdiag = $SCrepo->findById($input->getArgument('diagnosisOf'));
     $user = $UserRepo->findByUsername($input->getArgument('userName'))[0];
     $io->writeln('Updating (id: ' . $input->getArgument('SCid') . ') ' . $s->getSyntaxon());
     $io->writeln('    adding file ' . $input->getArgument('fileName'));
     $sFile = new SyntaxonFile();
     $sFile->setHit($input->getArgument('hit'))->setDiagnosisOf($SCdiag);
     $sFile->setSyntaxonCore($s);
     $sFile->setUser($user)->setType($input->getArgument('type'))->setVisibility($input->getArgument('visibility'))->setTitle($input->getArgument('title'))->setFileName($input->getArgument('fileName'))->setOriginalName($input->getArgument('originalName'))->setOriginalSyntaxonName($input->getArgument('originalSyntaxonName'))->setLicense('CC-BY-SA')->setUpdatedAt(new \DateTime('now'))->setUploadedAt(new \DateTime('now'));
     $s->addSyntaxonFile($sFile);
     $em->flush();
     $io->success('file added');
 }
Пример #12
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->title('OpenCFP');
     $io->section('Clearing caches');
     $paths = [$this->app->cachePurifierPath(), $this->app->cacheTwigPath()];
     array_walk($paths, function ($path) use($io) {
         passthru(sprintf('rm -rf %s/*', $path));
         $io->writeln(sprintf('  * %s', $path));
     });
     $io->success('Cleared caches.');
 }
Пример #13
0
 /**
  * Summarize changes since last tag.
  */
 protected function summarizeCommits()
 {
     $last = $this->changelog->getLastRelease();
     if (!$last) {
         return;
     }
     $commits = $this->executeQuietly(['git', 'log', $last['name'] . '..HEAD', '--oneline']);
     $commits = explode(PHP_EOL, trim($commits));
     if (!$commits) {
         $this->output->writeln('Commits since <comment>' . $last['name'] . '</comment>:');
         $this->output->listing($commits);
     }
 }
Пример #14
0
 /**
  * Generate the data while outputting updates.
  *
  * @param string $path
  *
  * @return void
  */
 public function generate($path)
 {
     $bar = new ProgressBar($this->output, $this->rows);
     $this->output->writeln("<info>Creating file with {$this->rows} rows at {$path}.</info>");
     $this->createFile($path);
     for ($i = 0; $i < $this->rows; $i++) {
         $this->writeRow();
         $bar->advance();
     }
     $this->writer->close();
     $bar->finish();
     $this->output->writeln(PHP_EOL . '<info>Complete.</info>');
 }
Пример #15
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $basePath = Application::basePath();
     chdir($basePath);
     $host = $input->getOption('host');
     $port = $input->getOption('port');
     $base = ProcessUtils::escapeArgument($basePath);
     $binary = ProcessUtils::escapeArgument((new PhpExecutableFinder())->find(false));
     $io = new SymfonyStyle($input, $output);
     $io->newLine();
     $io->writeln('<info>Tagmeo development server started on http://' . $host . ':' . $port . '/</info>');
     $io->newLine();
     passthru($binary . ' -S ' . $host . ':' . $port . ' ' . $base . '/server.php');
 }
Пример #16
0
 /**
  * Create a file or folder.
  *
  * @param string      $path
  * @param string|null $contents
  */
 protected function create($path, $contents = null)
 {
     // If the file already exists, quit
     $path = $this->formatPath($path);
     if ($this->filesystem->has($path)) {
         return;
     }
     // Create the file or folder
     if ($contents) {
         $this->filesystem->put($path, $contents);
     } else {
         $this->filesystem->createDir($path);
     }
     $this->output->writeln('<info>✓</info> Created <comment>' . $path . '</comment>');
 }
Пример #17
0
 /**
  * {@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);
 }
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->title("Banking information");
     $hipayID = $input->getArgument(self::HIPAY_ID);
     $vendor = new Vendor(false, false, $hipayID);
     $status = $this->vendorProcessor->getBankInfoStatus($vendor);
     $io->writeln($status);
     if (trim($status) == BankInfo::VALIDATED) {
         $bankData = $this->vendorProcessor->getBankInfo($vendor)->getData();
         $rows = array();
         foreach ($bankData as $key => $value) {
             $rows[] = array($key, $value);
         }
         $io->table(array('key', 'value'), $rows);
     }
 }
Пример #19
0
 private function updateLocalConfiguration($remoteConfiguration)
 {
     $localWebHooksConfiguration = $this->configurationStorage->get()['web_hooks'];
     $remoteWebHooksConfiguration = $remoteConfiguration['web_hooks'];
     // remove old
     $localKeysToRemove = [];
     foreach ($localWebHooksConfiguration as $localKey => $localWebHook) {
         $found = false;
         foreach ($remoteWebHooksConfiguration as $remoteWebHook) {
             if ($localWebHook['endpoint'] == $remoteWebHook['endpoint']) {
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             $localKeysToRemove[] = $localKey;
         }
     }
     $removedEndpoints = [];
     foreach ($localKeysToRemove as $localKeyToRemove) {
         $removedEndpoints[] = $localWebHooksConfiguration[$localKeyToRemove]['endpoint'];
         unset($localWebHooksConfiguration[$localKeyToRemove]);
     }
     if (count($removedEndpoints)) {
         $this->io->writeln('Endpoint(s) "' . implode(', ', $removedEndpoints) . '" removed from local configuration as it/they does not exists anymore on the server.');
     }
     // add new
     $addedEndpoints = [];
     foreach ($remoteWebHooksConfiguration as $key => $remoteWebHook) {
         if (!$this->getLocalWebHookConfigurationBy('endpoint', $remoteWebHook['endpoint'])) {
             $localWebHooksConfiguration[] = $remoteWebHook;
             $addedEndpoints[] = $remoteWebHook['endpoint'];
         }
     }
     if (count($addedEndpoints)) {
         $this->io->writeln('Endpoint(s) ' . implode(', ', $addedEndpoints) . ' added to the local configuration as it/they has been configured on the server.');
     }
     $remoteConfiguration['web_hooks'] = array_values($localWebHooksConfiguration);
     $this->configurationStorage->replaceConfiguration($remoteConfiguration)->save();
 }
 protected function execute(Input\InputInterface $input, Output\OutputInterface $output)
 {
     $this->stopwatch->start('changelog');
     $io = new SymfonyStyle($input, $output);
     $io->title('Localheinz GitHub Changelog');
     $authToken = $input->getOption('auth-token');
     if (null !== $authToken) {
         $this->client->authenticate($authToken, Client::AUTH_HTTP_TOKEN);
     }
     $owner = $input->getArgument('owner');
     $repository = $input->getArgument('repository');
     $startReference = $input->getArgument('start-reference');
     $endReference = $input->getArgument('end-reference');
     $range = $this->range($startReference, $endReference);
     $io->section(sprintf('Pull Requests for %s/%s %s', $owner, $repository, $range));
     try {
         $range = $this->pullRequestRepository->items($owner, $repository, $startReference, $endReference);
     } catch (\Exception $exception) {
         $io->error(sprintf('An error occurred: %s', $exception->getMessage()));
         return 1;
     }
     $pullRequests = $range->pullRequests();
     if (!count($pullRequests)) {
         $io->warning('Could not find any pull requests');
     } else {
         $template = $input->getOption('template');
         $pullRequests = array_reverse($pullRequests);
         array_walk($pullRequests, function (Resource\PullRequestInterface $pullRequest) use($output, $template) {
             $message = str_replace(['%title%', '%id%'], [$pullRequest->title(), $pullRequest->id()], $template);
             $output->writeln($message);
         });
         $io->newLine();
         $io->success(sprintf('Found %s pull request%s.', count($pullRequests), count($pullRequests) === 1 ? '' : 's', $range));
     }
     $event = $this->stopwatch->stop('changelog');
     $io->writeln($this->formatStopwatchEvent($event));
     return 0;
 }
Пример #21
0
 /**
  * @param bool $force
  */
 private function installWorkingLocale($force = false)
 {
     $installLocaleCommand = $this->getApplication()->find('forkcms:locale:import');
     $installBackendLocaleCommandArguments = ['-f' => PATH_WWW . '/src/Backend/Core/Installer/Data/locale.xml', '-o' => $force, '-l' => $this->workingLocale];
     $this->formatter->writeln('<info>Installing Core locale</info>');
     $installLocaleCommand->run(new ArrayInput($installBackendLocaleCommandArguments), $this->output);
     foreach ($this->installedModules as $installedModule) {
         $installModuleLocaleCommandArguments = ['-m' => $installedModule, '-o' => $force, '-l' => $this->workingLocale];
         $this->formatter->writeln('<info>Installing ' . $installedModule . ' locale</info>');
         try {
             $installLocaleCommand->run(new ArrayInput($installModuleLocaleCommandArguments), $this->output);
         } catch (Exception $exception) {
             $this->formatter->error($installedModule . ': skipped because ' . $exception->getMessage());
         }
     }
     if (!array_key_exists($this->workingLocale, $this->installedLocale)) {
         // add the working locale to the installed locale
         $this->installedLocale = array_flip($this->installedLocale);
         $this->installedLocale[] = $this->workingLocale;
         $this->settings->set('Core', 'languages', $this->installedLocale);
         $this->installedLocale = array_flip($this->installedLocale);
     }
 }
Пример #22
0
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
declare (strict_types=1);
namespace Nelmio\Alice;

use Nelmio\Alice\Loader\NativeLoader;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Style\SymfonyStyle;
require_once __DIR__ . '/../../vendor-bin/profiling/vendor/autoload.php';
$blackfire = new \Blackfire\Client();
$config = new \Blackfire\Profile\Configuration();
$config->setTitle('Scenario 1.1: immutable object');
$config->setSamples(10);
$config->setReference(1);
$probe = $blackfire->createProbe($config, false);
$output = new SymfonyStyle(new ArrayInput([]), new ConsoleOutput());
$progressBar = new ProgressBar($output, $config->getSamples());
$output->writeln(sprintf('Start profiling of <info>%s</info> with <info>%d samples.</info>', $config->getTitle(), $config->getSamples()));
$loader = new NativeLoader();
for ($i = 1; $i <= $config->getSamples(); $i++) {
    $probe->enable();
    $loader->loadFile(__DIR__ . '/immutable_user.yml');
    $probe->close();
    $progressBar->advance();
}
$blackfire->endProbe($probe);
$output->success('Finished!');
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output = new SymfonyStyle($input, $output);
     $kernel = $this->getContainer()->get('kernel');
     // check presence of force or dump-message
     if ($input->getOption('force') !== true && $input->getOption('dump-messages') !== true) {
         $output->error('You must choose one of --force or --dump-messages');
         return 1;
     }
     // check format
     $writer = $this->getContainer()->get('translation.writer');
     $supportedFormats = $writer->getFormats();
     if (!in_array($input->getOption('output-format'), $supportedFormats)) {
         $output->error(array('Wrong output format', 'Supported formats are ' . implode(', ', $supportedFormats) . '.'));
         return 1;
     }
     $kernel = $this->getContainer()->get('kernel');
     // Define Root Path to App folder
     $transPaths = array($kernel->getRootDir() . '/Resources/');
     $currentName = 'app folder';
     // Override with provided Bundle info
     if (null !== $input->getArgument('bundle')) {
         try {
             $foundBundle = $kernel->getBundle($input->getArgument('bundle'));
             $transPaths = array($foundBundle->getPath() . '/Resources/', sprintf('%s/Resources/%s/', $kernel->getRootDir(), $foundBundle->getName()));
             $currentName = $foundBundle->getName();
         } catch (\InvalidArgumentException $e) {
             // such a bundle does not exist, so treat the argument as path
             $transPaths = array($input->getArgument('bundle') . '/Resources/');
             $currentName = $transPaths[0];
             if (!is_dir($transPaths[0])) {
                 throw new \InvalidArgumentException(sprintf('<error>"%s" is neither an enabled bundle nor a directory.</error>', $transPaths[0]));
             }
         }
     }
     $output->title('Symfony translation update command');
     $output->text(sprintf('Generating "<info>%s</info>" translation files for "<info>%s</info>"', $input->getArgument('locale'), $currentName));
     // load any messages from templates
     $extractedCatalogue = new MessageCatalogue($input->getArgument('locale'));
     $output->text('Parsing templates');
     $extractor = $this->getContainer()->get('translation.extractor');
     $extractor->setPrefix($input->getOption('prefix'));
     foreach ($transPaths as $path) {
         $path .= 'views';
         if (is_dir($path)) {
             $extractor->extract($path, $extractedCatalogue);
         }
     }
     // load any existing messages from the translation files
     $currentCatalogue = new MessageCatalogue($input->getArgument('locale'));
     $output->text('Loading translation files');
     $loader = $this->getContainer()->get('translation.loader');
     foreach ($transPaths as $path) {
         $path .= 'translations';
         if (is_dir($path)) {
             $loader->loadMessages($path, $currentCatalogue);
         }
     }
     // process catalogues
     $operation = $input->getOption('clean') ? new DiffOperation($currentCatalogue, $extractedCatalogue) : new MergeOperation($currentCatalogue, $extractedCatalogue);
     // Exit if no messages found.
     if (!count($operation->getDomains())) {
         $output->warning('No translation found.');
         return;
     }
     // show compiled list of messages
     if ($input->getOption('dump-messages') === true) {
         $output->newLine();
         foreach ($operation->getDomains() as $domain) {
             $output->section(sprintf('Displaying messages for domain <info>%s</info>:', $domain));
             $newKeys = array_keys($operation->getNewMessages($domain));
             $allKeys = array_keys($operation->getMessages($domain));
             $output->listing(array_merge(array_diff($allKeys, $newKeys), array_map(function ($id) {
                 return sprintf('<fg=green>%s</>', $id);
             }, $newKeys), array_map(function ($id) {
                 return sprintf('<fg=red>%s</>', $id);
             }, array_keys($operation->getObsoleteMessages($domain)))));
         }
         if ($input->getOption('output-format') == 'xlf') {
             $output->writeln('Xliff output version is <info>1.2</info>');
         }
     }
     if ($input->getOption('no-backup') === true) {
         $writer->disableBackup();
     }
     // save the files
     if ($input->getOption('force') === true) {
         $output->text('Writing files');
         $bundleTransPath = false;
         foreach ($transPaths as $path) {
             $path .= 'translations';
             if (is_dir($path)) {
                 $bundleTransPath = $path;
             }
         }
         if ($bundleTransPath) {
             $writer->writeTranslations($operation->getResult(), $input->getOption('output-format'), array('path' => $bundleTransPath, 'default_locale' => $this->getContainer()->getParameter('kernel.default_locale')));
         }
     }
     $output->newLine();
     $output->success('Success');
 }
Пример #24
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $twig = $this->getTwigEnvironment();
     if (null === $twig) {
         $io->error('The Twig environment needs to be set.');
         return 1;
     }
     $types = array('functions', 'filters', 'tests', 'globals');
     if ($input->getOption('format') === 'json') {
         $data = array();
         foreach ($types as $type) {
             foreach ($twig->{'get' . ucfirst($type)}() as $name => $entity) {
                 $data[$type][$name] = $this->getMetadata($type, $entity);
             }
         }
         $data['tests'] = array_keys($data['tests']);
         $io->writeln(json_encode($data));
         return 0;
     }
     $filter = $input->getArgument('filter');
     foreach ($types as $index => $type) {
         $items = array();
         foreach ($twig->{'get' . ucfirst($type)}() as $name => $entity) {
             if (!$filter || false !== strpos($name, $filter)) {
                 $items[$name] = $name . $this->getPrettyMetadata($type, $entity);
             }
         }
         if (!$items) {
             continue;
         }
         $io->section(ucfirst($type));
         ksort($items);
         $io->listing($items);
     }
     return 0;
 }
 public function __call($name, $arguments)
 {
     $this->outputStyle->writeln(current($arguments));
 }
Пример #26
0
<?php

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
// Ensure has proper line ending before outputing a text block like with SymfonyStyle::listing() or SymfonyStyle::text()
return function (InputInterface $input, OutputInterface $output) {
    $output = new SymfonyStyle($input, $output);
    $output->writeln('Lorem ipsum dolor sit amet');
    $output->listing(array('Lorem ipsum dolor sit amet', 'consectetur adipiscing elit'));
    // Even using write:
    $output->write('Lorem ipsum dolor sit amet');
    $output->listing(array('Lorem ipsum dolor sit amet', 'consectetur adipiscing elit'));
    $output->write('Lorem ipsum dolor sit amet');
    $output->text(array('Lorem ipsum dolor sit amet', 'consectetur adipiscing elit'));
};
Пример #27
0
 /**
  * Write a string as error output.
  *
  * @param  string $string
  * @return void
  */
 public function error($string)
 {
     $this->output->writeln("<error>{$string}</error>");
 }
Пример #28
0
<?php

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
//Ensure has single blank line after any text and a title
return function (InputInterface $input, OutputInterface $output) {
    $output = new SymfonyStyle($input, $output);
    $output->write('Lorem ipsum dolor sit amet');
    $output->title('First title');
    $output->writeln('Lorem ipsum dolor sit amet');
    $output->title('Second title');
    $output->write('Lorem ipsum dolor sit amet');
    $output->write('');
    $output->title('Third title');
    //Ensure edge case by appending empty strings to history:
    $output->write('Lorem ipsum dolor sit amet');
    $output->write(array('', '', ''));
    $output->title('Fourth title');
    //Ensure have manual control over number of blank lines:
    $output->writeln('Lorem ipsum dolor sit amet');
    $output->writeln(array('', ''));
    //Should append an extra blank line
    $output->title('Fifth title');
    $output->writeln('Lorem ipsum dolor sit amet');
    $output->newLine(2);
    //Should append an extra blank line
    $output->title('Fifth title');
};
Пример #29
0
 /**
  * @param string $msg
  */
 protected function text($msg)
 {
     if ($this->io) {
         $this->io->writeln(date('[Y-m-d H:i:s]') . $msg);
     }
 }
Пример #30
0
 /**
  * Shows an information about aspect pointcuts and advisors
  *
  * @param SymfonyStyle $io Input-output style
  * @param Aspect $aspect Instance of aspect to query information
  */
 private function showAspectPointcutsAndAdvisors(SymfonyStyle $io, Aspect $aspect)
 {
     /** @var AspectLoader $aspectLoader */
     $container = $this->aspectKernel->getContainer();
     $aspectLoader = $container->get('aspect.loader');
     $io->writeln('<comment>Pointcuts and advices</comment>');
     $aspectItems = $aspectLoader->load($aspect);
     $aspectItemsInfo = [];
     foreach ($aspectItems as $itemId => $item) {
         $itemType = 'Unknown';
         if ($item instanceof Pointcut) {
             $itemType = 'Pointcut';
         }
         if ($item instanceof Advisor) {
             $itemType = 'Advisor';
         }
         $aspectItemsInfo[] = [$itemType, $itemId];
     }
     $io->table(['Type', 'Identifier'], $aspectItemsInfo);
 }