/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $environment = $input->getArgument('environment'); $template = $input->getArgument('template'); $scalingProfile = $input->getOption('scaling-profile'); $name = $input->getOption('name'); $stack = $this->configStackMapper->create($template, $environment, $scalingProfile, $name); $output->writeLn('<info>Template</info>'); $output->write($stack->getTemplate()->getBodyJSON()); $output->writeLn(''); $output->writeLn('<info>Parameters</info>'); $table = new Table($output); $table->setHeaders(['Key', 'Value']); foreach ($stack->getParameters() as $key => $value) { $table->addRow([$key, $value]); } $table->render(); $output->writeLn(''); $output->writeLn('<info>Tags</info>'); $table = new Table($output); $table->setHeaders(['Key', 'Value']); foreach ($stack->getTags() as $key => $value) { $table->addRow([$key, $value]); } $table->render(); }
/** * Runs when silly routes the command to us. * ie: ```ppm install``` * * @param IOutput $output * @return void */ public function __invoke(IOutput $output) { // Save the output interface so we can use it later $this->output = $output; // Tell the world we have started installing stuff $this->output->writeLn("Starting Installer"); // Attach to Observables $this->downloader->attach($this); $this->cleaner->attach($this); // Read in the root composer.json file $composer = $this->reader->getComposerObject(); // Loop through all "require" packages, downloading them, recursively. if (isset($composer['require'])) { $this->downloadPackages($composer['require']); } // Loop through all "require-dev" packages, downloading them. // This is done recursively just like the normal require packages but // only these first level packages are downloaded, as to say we do not // download any "require-dev" packages of a "require-dev" package. if (isset($composer['require-dev'])) { $this->downloadPackages($composer['require-dev']); } // Remove anything that shouldn't exist $this->cleaner->clean($this->downloader->getDownloaded()); // Discover any namespace conflicts $conflicts = $this->conflicts->discover($this->downloader->getDownloaded()); // Re-Name conflicting types. $replacements = $this->renamer->renameConflicts($conflicts); // Generate auto loader. $this->autoload->generate($this->downloader->getDownloaded(), $replacements); $autoloader = (require $this->vendorDir . '/autoload.php'); // Create proxies for renamed types. //$this->proxy->generate($replacements, $autoloader); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $dryRun = $input->getOption('dry-run'); $content = $this->processConfig($this->crontab); $enviroment = isset($content['env']) ? $content['env'] : array(); $commands = isset($content['commands']) ? $content['commands'] : array(); foreach ($commands as $entry) { preg_match('/\\[(.*)\\](.*)/', $entry, $match); $tab = $match[1]; $command = $match[2]; $cron = CronExpression::factory($tab); $output->writeLn('<info>- Checking schedule entry: ' . $tab . '</info>'); // If the cron is not due for execution, just skip if (!$cron->isDue()) { continue; } // Construct the fork command $fork = $command . " > " . $this->log . " 2>&1 & echo \$!"; $output->writeLn('<info>- Command:</info> ' . $fork); // Start a new process if (!$dryRun) { exec($fork, $pid); $pid = current($pid); $output->writeLn('<info>- Process created:</info> ' . $pid); } else { $output->writeLn('<info>- Skipping execution (--dry-run)</info>'); } } }
/** * @see Command */ protected function execute(InputInterface $input, OutputInterface $output) { $repo = $this->getContainer()->get('lichess.repository.game'); $dm = $this->getContainer()->get('doctrine.odm.mongodb.document_manager'); $query = array('isAi' => array('$exists' => false)); $select = array('players.isAi' => true); $collection = $dm->getDocumentCollection($repo->getDocumentName())->getMongoCollection(); $total = $collection->count($query); $batchSize = 10000; $it = 0; $output->writeLn(sprintf('Found %d games to process', $total)); for ($it = 0, $itMax = ceil($total / $batchSize); $it < $itMax; $it++) { $cursor = $collection->find($query, $select)->limit($batchSize)->skip($it * $batchSize); $games = iterator_to_array($cursor); $nbIsAi = 0; foreach ($games as $id => $game) { if (!empty($game['players'][0]['isAi']) || !empty($game['players'][1]['isAi'])) { $collection->update(array('_id' => $id), array('$set' => array('isAi' => true)), array('safe' => true)); $nbIsAi++; } } $output->writeLn(sprintf('%d%% %d/%d %d/%d', ($it + 1) * $batchSize * 100 / $total, ($it + 1) * $batchSize, $total, $nbIsAi, $batchSize)); sleep(5); } $output->writeLn('Done'); }
/** * @see Command */ protected function execute(InputInterface $input, OutputInterface $output) { $fs = new Filesystem(); $repoUrl = 'git://github.com/ornicar/lichess.wiki.git'; //$repoUrl = '/home/thib/lichess.wiki/'; $repoName = 'lichess_wiki'; $repoDir = '/tmp'; $repo = $repoDir . '/' . $repoName; $fs->remove($repo); $command = sprintf('cd %s && git clone %s %s', $repoDir, $repoUrl, $repoName); system($command); $finder = new Finder(); $mdFiles = $finder->files()->depth(0)->name('*.md')->in($repo); $pages = array(); foreach ($mdFiles as $mdFile) { $name = preg_replace('/^(.+)\\.md$/', '$1', $mdFile->getFileName()); if ($name == "Home") { continue; } $output->writeLn('* ' . $name); $command = sprintf('sundown %s/%s', $repo, $mdFile->getFileName()); exec($command, $out); $body = implode($out, "\n"); unset($out); $pages[] = new WikiPage($name, $body); } if (empty($pages)) { throw new \Exception('No pages to save'); } $this->getContainer()->get('lichess.repository.wiki_page')->replaceWith($pages); $this->getContainer()->get('doctrine.odm.mongodb.document_manager')->flush(); $output->writeLn('Flushed'); }
/** * {@inheritDoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $newrelic = $this->newrelic; $appNames = $newrelic->getDeploymentNames(); if (!$appNames) { $output->writeLn("<error>No deployment application configured.</error>"); return self::EXIT_NO_APP_NAMES; } $exitCode = 0; foreach ($appNames as $appName) { $response = $this->performRequest($newrelic->getApiKey(), $this->createPayload($appName, $input)); switch ($response['status']) { case 200: case 201: $output->writeLn(sprintf("Recorded deployment to '%s' (%s)", $appName, $input->getOption('description') ? $input->getOption('description') : date('r'))); break; case 403: $output->writeLn(sprintf("<error>Deployment not recorded to '%s': API key invalid</error>", $appName)); $exitCode = self::EXIT_UNAUTHORIZED; break; case null: $output->writeLn(sprintf("<error>Deployment not recorded to '%s': Did not understand response</error>", $appName)); $exitCode = self::EXIT_HTTP_ERROR; break; default: $output->writeLn(sprintf("<error>Deployment not recorded to '%s': Received HTTP status %d</error>", $appName, $response['status'])); $exitCode = self::EXIT_HTTP_ERROR; break; } } return $exitCode; }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $filename = 'app/config/parameters.yml'; if (!file_exists($filename)) { throw new RuntimeException("No such file: " . $filename); } $data = file_get_contents($filename); $config = Yaml::parse($data); if (isset($config['pdo'])) { $pdo = $config['pdo']; } else { if (!isset($config['parameters']['pdo'])) { throw new RuntimeException("Can't find pdo configuration"); } $pdo = $config['parameters']['pdo']; } $partten = '/^(\\w+)\\:\\/\\/(\\w+)\\:(.+)\\@([a-zA-Z0-9\\.]+)\\/(\\w+)/'; preg_match($partten, $pdo, $matches); if ($matches) { if ('mysql' == $matches[1] || 'mysqli' == $matches[1]) { $cmd = 'mysql -u ' . $matches[2] . ' --password='******' -h ' . $matches[4] . ' ' . $matches[5]; } else { $output->writeLn('<error>PDO is not mysql type</error>'); } } else { $output->writeLn('<error>Cannot parse DSN</error>'); } $output->write($cmd); }
private function runCommandProcess($cmd, OutputInterface $output) { $process = new Process($cmd); $output->writeLn('<comment>' . $process->getCommandLine() . '</comment>'); $process->run(); $output->writeLn($process->getOutput()); }
protected function execute(InputInterface $input, OutputInterface $output) { $configLoader = new ConfigurationLoader(new FileLocator()); $config = $configLoader->load('config.yml'); // Print the list of available groups if ($input->getOption('list')) { foreach (array_keys($config->getGroups()) as $item) { $output->writeln(sprintf('<comment>%s</comment>', $item)); } return; } // Compile all assets declred in config if ($input->getOption('compile-all')) { // Do the Compile $compiler = new CssCompiler(new Filesystem()); foreach ($config->getGroups() as $name => $group) { $compiler->compile($group['files'], $group['destination']); $output->writeLn(sprintf('Group <info>%s</info> [OK]', $name)); } return; } // Compile the specified group, if one is specified $groupName = $input->getOption('group'); $group = $config->getGroup($groupName); if (is_null($group)) { throw new \Exception('The group you have specified does not exist in your config file'); } // Do the Compile $compiler = new CssCompiler(new Filesystem()); $compiler->compile($group['files'], $group['destination']); $output->writeLn(sprintf('Group <info>%s</info> [OK]', $groupName)); }
/** * {@inheritDoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $output->writeLn("Received argument <info>entity</info> as <comment>" . $input->getArgument('entity') . "</comment>"); $output->writeLn("Received option <info>fields</info> as <comment>" . $input->getOption('fields') . "</comment>"); $output->writeLn("Received option <info>opt</info> as <comment>" . $input->getOption('opt') . "</comment>"); $output->writeLn("<comment>Successfully finished purified</comment>"); }
/** * Execute the filter command * * @param InputInterface $input Input object * @param OutputInterface $output Output object * @return null */ protected function execute(InputInterface $input, OutputInterface $output) { $col = new \Expose\FilterCollection(); $col->load(); $filters = $col->getFilterData(); $id = $input->getOption('id'); if ($id !== false) { $idList = explode(',', $id); foreach ($idList as $id) { if (array_key_exists($id, $filters)) { $detail = "[" . $id . "] " . $filters[$id]->getDescription() . "\n"; $detail .= "\tRule: " . $filters[$id]->getRule() . "\n"; $detail .= "\tTags: " . implode(', ', $filters[$id]->getTags()) . "\n"; $detail .= "\tImpact: " . $filters[$id]->getImpact() . "\n"; $output->writeLn($detail); } else { $output->writeLn('Filter ID ' . $id . ' not found!'); } } return; } foreach ($filters as $filter) { echo $filter->getId() . ': ' . $filter->getDescription() . "\n"; } return; }
/** * @see Command */ protected function execute(InputInterface $input, OutputInterface $output) { $repo = $this->getContainer()->get('lichess.repository.game'); $batchSize = 1000; $sleep = 15; $ids = $repo->findCandidatesToCleanup(999999); $nb = count($ids); $output->writeLn(sprintf('Found %d games of %d to remove', $nb, $repo->createQueryBuilder()->getQuery()->count())); if (!$input->getOption('execute')) { return; } do { try { $ids = $repo->findCandidatesToCleanup($batchSize); $nb = count($ids); $output->writeLn(sprintf('Found %d games of %d to remove', $nb, $repo->createQueryBuilder()->getQuery()->count())); if ($nb == 0) { return; } $output->writeLn(sprintf('Removing %d games...', $nb)); $repo->removeByIds($ids); if ($nb == $batchSize) { $output->writeLn('Sleep ' . $sleep . ' seconds'); sleep($sleep); } } catch (\MongoCursorTimeoutException $e) { $output->writeLn('<error>Time out, sleeping 60 seconds</error>'); sleep(60); } } while ($nb > 0); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $this->factory = $this->getContainer()->get('mautic.factory'); $queueMode = $this->factory->getParameter('queue_mode'); // check to make sure we are in queue mode if ($queueMode != 'command_process') { $output->writeLn('Webhook Bundle is in immediate process mode. To use the command function change to command mode.'); return 0; } $id = $input->getOption('webhook-id'); /** @var \Mautic\WebhookBundle\Model\WebhookModel $model */ $model = $this->factory->getModel('webhook'); if ($id) { $webhook = $model->getEntity($id); $webhooks = $webhook !== null && $webhook->isPublished() ? array($id => $webhook) : array(); } else { // make sure we only get published webhook entities $webhooks = $model->getEntities(array('filter' => array('force' => array(array('column' => 'e.isPublished', 'expr' => 'eq', 'value' => 1))))); } if (!count($webhooks)) { $output->writeln('<error>No published webhooks found. Try again later.</error>'); return; } $output->writeLn('<info>Processing Webhooks</info>'); try { $model->processWebhooks($webhooks); } catch (\Exception $e) { $output->writeLn('<error>' . $e->getMessage() . '</error>'); } $output->writeLn('<info>Webhook Processing Complete</info>'); }
protected function execute(InputInterface $input, OutputInterface $output) { /** @var ImportAddressService $importAddressService */ $importAddressService = $this->getHelper('container')->getByType('StreetApi\\Services\\ImportAddressService'); $cityId = $input->getArgument('cityId'); $xmlFile = simplexml_load_file($importAddressService->getRootDir() . '/../adresy.xml'); if (!$xmlFile) { $output->writeln(PHP_EOL . '<error>Missing source file!</error>'); return 1; } try { $output->writeLn('<info>Start importing addresses</info>'); $totalCount = $xmlFile->count(); $output->writeln(PHP_EOL . PHP_EOL . PHP_EOL . PHP_EOL); $progressBar = new ProgressBar($output, $totalCount); $progressBar->setFormat('%message%' . PHP_EOL . '%bar% %percent:3s% %' . PHP_EOL . 'count: %current%/%max%' . PHP_EOL . 'time: %elapsed:6s%/%estimated:-6s%' . PHP_EOL); $progressBar->setBarCharacter('<info>■</info>'); $progressBar->setEmptyBarCharacter(' '); $progressBar->setProgressCharacter(''); $progressBar->setRedrawFrequency(ceil($totalCount / 100)); $progressBar->start(); $importAddressService->import($xmlFile, $progressBar, $cityId); $output->writeLn(PHP_EOL . '<info>Importing addresses finished</info>'); return 0; } catch (\Exception $e) { $output->writeLn('<error>' . $e->getMessage() . '</error>'); return 1; } }
/** * @see Command */ protected function execute(InputInterface $input, OutputInterface $output) { $date = new \DateTime('-2 hours'); $dm = $this->getContainer()->get('doctrine.odm.mongodb.document_manager'); $postRemover = $this->getContainer()->get('herzult_forum.remover.post'); $topicRemover = $this->getContainer()->get('herzult_forum.remover.topic'); $posts = $this->getContainer()->get('herzult_forum.repository.post')->createQueryBuilder()->field('createdAt')->gt($date)->getQuery()->execute()->toArray(); $posts = array_filter($posts, function ($post) { return !$post->hasAuthor(); }); $output->writeLn(sprintf('Will remove %d posts', count($posts))); foreach ($posts as $post) { $output->writeLn(substr($post->getMessage(), 0, 80)); try { if ($post->getNumber() == 1) { $topicRemover->remove($post->getTopic()); } else { $postRemover->remove($post); } } catch (\Exception $e) { $output->writeLn($e->getMessage()); } $dm->flush(); } $output->writeLn('Done'); }
protected function execute(InputInterface $input, OutputInterface $output) { $user = $input->getArgument('user'); $project_dir = realpath($this->getContainer()->getParameter('kernel.root_dir') . '/..'); $root_dir = realpath($this->getContainer()->getParameter('kernel.root_dir')); $env = $this->getContainer()->getParameter('kernel.environment'); $namespace = $this->getContainer()->getParameter('supertag_gearman.namespace'); $debug = $input->getOption('no-debug') ? ' --no-debug' : ''; $numWorkers = $input->hasOption('num-workers') ? intval($input->getOption('num-workers')) : 1; if ($numWorkers <= 0) { $numWorkers = 1; } $workers = ''; $replace = compact('project_dir', 'root_dir', 'user', 'env', 'namespace', 'debug'); for ($i = 0; $i < $numWorkers; $i++) { $replace['num_worker'] = $i + 1; $workers .= ($i === 0 ? '' : "\n\n") . str_replace(array_map(function ($key) { return '%' . $key . '%'; }, array_keys($replace)), array_values($replace), self::TEMPLATE_WORKER); } $replace['workers'] = $workers; $content = str_replace(array_map(function ($key) { return '%' . $key . '%'; }, array_keys($replace)), array_values($replace), self::TEMPLATE_MAIN); $outputFile = $project_dir . '/worker-supervisor.conf'; if (file_put_contents($outputFile, $content) === false) { throw new \RuntimeException("Failed to write into {$outputFile}"); } $output->writeLn("Generated <info>{$outputFile}</info>, use it like:"); $output->writeLn(" <comment>supervisord -n -c {$outputFile}</comment> - for debug mode, will do output when started"); $output->writeLn(" <comment>supervisord -c {$outputFile}</comment> - for production mode, to run in background"); }
protected function execute(InputInterface $input, OutputInterface $output) { $overwrite = $input->getOption('overwrite') ? EntityBuilder::OVERWRITE : NULL; $module = $this->getDoctrineModule(); $builder = new EntityBuilder($input->getArgument('name'), $module); $entity = $input->getOption('with-entity') != 'false'; $builder->setWithRepository($repo = $input->getOption('with-repository') != 'false'); if ($input->getOption('version1')) { $builder->buildDefault(); } else { $builder->buildDefaultV2(); } if ($entity) { if ($table = $input->getArgument('tableName')) { $builder->setTableName($table); } $file = $builder->write(NULL, $overwrite); $output->writeLn('Entity in Datei: "' . $file . '" geschrieben'); } if ($repo) { $repoFile = $builder->writeRepository(NULL, $overwrite); $output->writeLn('EntityRepository in Datei: "' . $repoFile . '" geschrieben'); } return 0; }
protected function execute(InputInterface $input, OutputInterface $output) { $type = $input->getArgument('type'); if (!in_array($type, $this->type)) { $output->writeln("Invalid type."); return; } // Get the indexer $token = $this->getContainer()->getParameter('swiftype_api_key'); $engine = $this->getContainer()->getParameter('swiftype_engine_slug'); $indexer = new SwiftypeIndexer($token, $engine); $docBuilder = DocumentBuilderFactory::getDocumentBuilder($this->getContainer(), $type); $allDocs = $docBuilder->getDocuments(); $numDocs = count($allDocs); $totalIndexed = 0; $batch_size = 100; while ($totalIndexed < $numDocs) { $docs = array_slice($allDocs, $totalIndexed, $batch_size); $result = $indexer->bulkCreateOrUpdate($docs, $type); $totalIndexed += $batch_size; if (count(array_unique($result)) == 1) { $output->writeLn(count($result) . " documents indexed successfully"); } else { $output->writeLn("Some documents may have failed indexing. Total attempted " . count($result)); } } }
/** * Executes the current command. * * @param InputInterface $input An InputInterface instance * @param OutputInterface $output An OutputInterface instance */ protected function execute(InputInterface $input, OutputInterface $output) { $oxContent = oxNew('oxcontent'); $oxContent->loadByIdent($input->getArgument('ident')); if (!$oxContent) { $output->writeLn("<error>Content with ident {$input->getArgument('ident')} not found.</error>"); return; } if ($input->getOption('language') !== false) { $language = $input->getOption('language'); } else { $language = \oxRegistry::getLang()->getBaseLanguage(); } $oxContent->setLanguage($language); if ($input->getOption('title')) { $oxContent->oxcontents__oxtitle = new \oxField($input->getOption('title')); } if ($input->getOption('content')) { if (is_file(getcwd() . '/' . $input->getOption('content'))) { $content = file_get_contents(getcwd() . '/' . $input->getOption('content')); } else { $content = $input->getOption('content'); } $oxContent->oxcontents__oxcontent = new \oxField($content); } if ($input->getOption('active')) { $oxContent->oxcontents__oxactive = new \oxField($input->getOption('active')); } if ($oxContent->save()) { $output->writeLn("<info>Content with ident {$input->getArgument('ident')} updated.</info>"); } }
/** * @see Command */ protected function execute(InputInterface $input, OutputInterface $output) { $dialog = $this->getHelperSet()->get('dialog'); $output->writeln(array('', $this->getHelperSet()->get('formatter')->formatBlock(sprintf('This will delete all invoices and contacts from %s.moneybird.nl', $this->getContainer()->getParameter('ruudk_moneybird.subdomain')), 'bg=red;fg=white', true), '')); $moneybird = $this->getContainer()->get('moneybird.api'); $contactService = $moneybird->getService('Contact'); $contacts = $contactService->getAll(); $invoiceService = $moneybird->getService('Invoice'); $invoices = $invoiceService->getAll(); $output->writeLn(sprintf('<info>Found %s and %s</info> ', count($contacts) == 1 ? "1 contact" : count($contacts) . " contacts", count($invoices) == 1 ? "1 invoice" : count($invoices) . " invoices")); if (count($contacts) == 0 && count($invoices) == 0) { $output->writeln(array('', $this->getHelperSet()->get('formatter')->formatBlock('Nothing to do', 'bg=blue;fg=white', true), '')); return; } $output->writeLn(''); if (!$dialog->askConfirmation($output, '<question>Are you sure you want to do this?</question> ', false)) { return; } foreach ($invoices as $invoice) { $invoice->delete($invoiceService); } foreach ($contacts as $contact) { $contact->delete($contactService); } $output->writeln(array('', $this->getHelperSet()->get('formatter')->formatBlock('Done!', 'bg=blue;fg=white', true), '')); }
protected function execute(InputInterface $input, OutputInterface $output) { $env = $this->getContainer()->getParameter('kernel.environment'); $output->writeLn("Clearing app cache for environment <comment>{$env}</comment>..."); $cache = $this->getContainer()->get('cache.default'); $cache->flushAll(); $output->writeLn("Cache was cleared."); }
/** * Log * * @param string $message */ public function log($message) { if ($this->progress) { $this->progress->setMessage($message); $this->logs[] = $message; } else { $this->output->writeLn($message); } }
/** * Execute the command. * * @param \Symfony\Component\Console\Input\InputInterface $input * @param \Symfony\Component\Console\Output\OutputInterface $output */ public function execute(InputInterface $input, OutputInterface $output) { if (file_exists($this->configFile)) { $output->writeLn('Static Sites already installed.'); exit; } copy($this->configStubFile, $this->configFile); $output->writeLn('Static Sites installed.'); }
protected function execute(InputInterface $input, OutputInterface $output) { $vat = new Vat(); $vat->setValue(21); $line = new InvoiceLine(); $line->setVat($vat)->setQuantity(3)->setUnitPrice(200); $output->writeLn('Unit total: ' . $line->getUnitPriceTotal()); $output->writeLn('Total: ' . $line->getTotalPrice()); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $queue = $this->getContainer()->get('jobqueue'); if ($queue->flush()) { $output->writeLn('<info>Cleaned exceptions</info>'); } else { $output->writeLn('<info>Flush failed</info>'); } }
/** * Will work only on linux or unix */ protected function doKill(OutputInterface $output) { $projectDir = dirname($this->getContainer()->getParameter('kernel.root_dir')); if (file_exists($pidFile = $projectDir . '/supervisord.pid')) { $pid = trim(file_get_contents($pidFile)); $output->writeLn("Found supervisor pid file, killing process: <comment>{$pid}</comment>"); exec("kill {$pid}"); } else { $output->writeLn("Could not find supervisor pid file, probably a worker is not running."); } }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $name = $input->getArgument('name'); $scalingProfile = $input->getOption('scaling-profile'); $stackA = $this->apiStackMapper->create($name); $stackB = $this->configStackMapper->create($stackA->getTemplate()->getName(), $stackA->getEnvironment(), $scalingProfile, $name); $output->writeLn('<info>Changes to the CloudFormation parameters:</info>'); $output->write($this->coloriseUnifiedDiff($this->stackComparisonService->compareParameters($stackA->getParameters(), $stackB->getParameters()))); $output->writeLn('<info>Changes to the CloudFormation template:</info>'); $output->write($this->coloriseUnifiedDiff($this->stackComparisonService->compareTemplate($stackA->getTemplate(), $stackB->getTemplate()))); }
/** * @see Command */ protected function execute(InputInterface $input, OutputInterface $output) { $repo = $this->getContainer()->get('lichess.repository.game'); $game = $repo->findOneById($input->getArgument('id')); if (!$game) { throw new \InvalidArgumentException('No game found.'); } $output->writeLn(sprintf('Game %s', $this->generateUrl($game->getId()))); $output->writeLn(sprintf('White %s', $this->generateUrl($game->getPlayer('white')->getFullId()))); $output->writeLn(sprintf('Black %s', $this->generateUrl($game->getPlayer('black')->getFullId()))); }
/** * @see Command */ protected function execute(InputInterface $input, OutputInterface $output) { $repo = $this->getContainer()->get('lichess.repository.game'); $dm = $this->getContainer()->get('doctrine.odm.mongodb.document_manager'); $collection = $dm->getDocumentCollection($repo->getDocumentName())->getMongoCollection(); $games = $collection->find(array('clock.moveBonus' => array('$exists' => true)), array('clock.moveBonus' => true)); $output->writeLn(sprintf('Found %d games to process', $games->count())); foreach ($games as $game) { $collection->update(array('_id' => $game['_id']), array('$set' => array('clock.increment' => $game['clock']['moveBonus']), '$unset' => array('clock.moveBonus' => true))); } $output->writeLn('Done'); }
/** * @see Command */ protected function execute(InputInterface $input, OutputInterface $output) { $repo = $this->getContainer()->get('fos_user.repository.user'); $dm = $this->getContainer()->get('doctrine.odm.mongodb.document_manager'); $collection = $dm->getDocumentCollection($repo->getDocumentName())->getMongoCollection(); $users = $collection->find(); foreach ($users as $user) { $output->writeLn(sprintf('Update %s', $user['username'])); $this->migrate($user); $collection->update(array('_id' => $user['_id']), $user, array('safe' => true)); } $output->writeLn('Done'); }