protected function execute(InputInterface $input, OutputInterface $output) { $url = $input->getOption('url'); $email = $input->getOption('email'); $disable = $input->getOption('disable'); $events = $input->getOption('event'); if (!$url && !$email) { $output->writeln('<error>Must specify either a url or an email address</error>'); return; } if ($url && $email) { $output->writeln('<error>Must specify only a url or an email address</error>'); return; } if (!($resource = $this->getResource('webhook', $output))) { return; } if ($url) { $resource->setUrl($url); } else { $resource->setEmail($email); } $resource->setEventTypes($events ? $events : Webhook::$events); $this->getApi()->create($resource); $resource = $this->getApi()->getLastResponse(); $resource = $resource['body']['data']; $table = $this->getHelperSet()->get('table'); $this->formatTableRow($resource, $table, false); $output->writeln('<info>Webhook created</info>'); $table->render($output); }
/** * @see Command */ protected function execute(InputInterface $input, OutputInterface $output) { $doctrine = $this->getContainer()->get('doctrine'); $em = $doctrine->getManager(); $name = $input->getArgument('name'); $system = $input->getArgument('system'); /* @var RepositoryInterface $roleRepository */ $repository = $this->getContainer()->get('sulu.repository.role'); $role = $repository->findOneByName($name); if ($role) { $output->writeln(sprintf('<error>Role "%s" already exists.</error>', $name)); return 1; } /** @var RoleInterface $role */ $role = $repository->createNew(); $role->setName($name); $role->setSystem($system); $pool = $this->getContainer()->get('sulu_admin.admin_pool'); $securityContexts = $pool->getSecurityContexts(); // flatten contexts $securityContextsFlat = []; array_walk_recursive($securityContexts['Sulu'], function ($value) use(&$securityContextsFlat) { $securityContextsFlat[] = $value; }); foreach ($securityContextsFlat as $securityContext) { $permission = new Permission(); $permission->setRole($role); $permission->setContext($securityContext); $permission->setPermissions(127); $role->addPermission($permission); } $em->persist($role); $em->flush(); $output->writeln(sprintf('Created role "<comment>%s</comment>" in system "<comment>%s</comment>".', $role->getName(), $role->getSystem())); }
protected function execute(InputInterface $input, OutputInterface $output) { $path = $input->getArgument('path'); if (!file_exists($path)) { $output->writeln("{$path} is not a file or a path"); } $filePaths = []; if (is_file($path)) { $filePaths = [realpath($path)]; } elseif (is_dir($path)) { $filePaths = array_diff(scandir($path), array('..', '.')); } else { $output->writeln("{$path} is not known."); } $generator = new StopwordGenerator($filePaths); if ($input->getArgument('type') === 'json') { echo json_encode($this->toArray($generator->getStopwords()), JSON_NUMERIC_CHECK | JSON_UNESCAPED_UNICODE); echo json_last_error_msg(); die; $output->write(json_encode($this->toArray($generator->getStopwords()))); } else { $stopwords = $generator->getStopwords(); $stdout = fopen('php://stdout', 'w'); echo 'token,freq' . PHP_EOL; foreach ($stopwords as $token => $freq) { fputcsv($stdout, [utf8_encode($token), $freq]) . PHP_EOL; } fclose($stdout); } }
protected function execute(InputInterface $input, OutputInterface $output) { $elasticaClient = new \Elastica\Client(); $elasticaIndex = $elasticaClient->getIndex('evrika'); $elasticaIndex->create(array('number_of_shards' => 2, 'number_of_replicas' => 0, 'analysis' => array('analyzer' => array('indexAnalyzer' => array('type' => 'custom', 'tokenizer' => 'standard', 'filter' => array('lowercase', 'mySnowball')), 'searchAnalyzer' => array('type' => 'custom', 'tokenizer' => 'standard', 'filter' => array('standard', 'lowercase', 'mySnowball'))), 'filter' => array('mySnowball' => array('type' => 'snowball', 'language' => 'Russian')))), true); $output->writeln('+++ evrika:elastic_index created!'); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $realCacheDir = $this->getContainer()->getParameter('kernel.cache_dir'); $oldCacheDir = $realCacheDir . '_old'; $filesystem = $this->getContainer()->get('filesystem'); if (!is_writable($realCacheDir)) { throw new \RuntimeException(sprintf('Unable to write in the "%s" directory', $realCacheDir)); } if ($filesystem->exists($oldCacheDir)) { $filesystem->remove($oldCacheDir); } $kernel = $this->getContainer()->get('kernel'); $output->writeln(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true))); $this->getContainer()->get('cache_clearer')->clear($realCacheDir); if ($input->getOption('no-warmup')) { $filesystem->rename($realCacheDir, $oldCacheDir); } else { // the warmup cache dir name must have the same length than the real one // to avoid the many problems in serialized resources files $warmupDir = substr($realCacheDir, 0, -1) . '_'; if ($filesystem->exists($warmupDir)) { $filesystem->remove($warmupDir); } $this->warmup($warmupDir, $realCacheDir, !$input->getOption('no-optional-warmers')); $filesystem->rename($realCacheDir, $oldCacheDir); if (defined('PHP_WINDOWS_VERSION_BUILD')) { sleep(1); // workaround for windows php rename bug } $filesystem->rename($warmupDir, $realCacheDir); } $filesystem->remove($oldCacheDir); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $remoteFilename = 'http://get.insight.sensiolabs.com/insight.phar'; $localFilename = $_SERVER['argv'][0]; $tempFilename = basename($localFilename, '.phar') . '-temp.phar'; try { copy($remoteFilename, $tempFilename); if (md5_file($localFilename) == md5_file($tempFilename)) { $output->writeln('<info>insight is already up to date.</info>'); unlink($tempFilename); return; } chmod($tempFilename, 0777 & ~umask()); // test the phar validity $phar = new \Phar($tempFilename); // free the variable to unlock the file unset($phar); rename($tempFilename, $localFilename); $output->writeln('<info>insight updated.</info>'); } catch (\Exception $e) { if (!$e instanceof \UnexpectedValueException && !$e instanceof \PharException) { throw $e; } unlink($tempFilename); $output->writeln('<error>The download is corrupt (' . $e->getMessage() . ').</error>'); $output->writeln('<error>Please re-run the self-update command to try again.</error>'); } }
protected function execute(InputInterface $input, OutputInterface $stdout) { // capture error output $stderr = $stdout instanceof ConsoleOutputInterface ? $stdout->getErrorOutput() : $stdout; if ($input->getOption('watch')) { $stderr->writeln('<error>The --watch option is deprecated. Please use the ' . 'assetic:watch command instead.</error>'); // build assetic:watch arguments $arguments = array('command' => 'assetic:watch', 'write_to' => $this->basePath, '--period' => $input->getOption('period'), '--env' => $input->getOption('env')); if ($input->getOption('no-debug')) { $arguments['--no-debug'] = true; } if ($input->getOption('force')) { $arguments['--force'] = true; } $command = $this->getApplication()->find('assetic:watch'); return $command->run(new ArrayInput($arguments), $stdout); } // print the header $stdout->writeln(sprintf('Dumping all <comment>%s</comment> assets.', $input->getOption('env'))); $stdout->writeln(sprintf('Debug mode is <comment>%s</comment>.', $this->am->isDebug() ? 'on' : 'off')); $stdout->writeln(''); if ($this->spork) { $batch = $this->spork->createBatchJob($this->am->getNames(), new ChunkStrategy($input->getOption('forks'))); $self = $this; $batch->execute(function ($name) use($self, $stdout) { $self->dumpAsset($name, $stdout); }); } else { foreach ($this->am->getNames() as $name) { $this->dumpAsset($name, $stdout); } } }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $class_name = ltrim($input->getArgument('class_name'), '\\'); $namespace_root = $input->getArgument('namespace_root_path'); $match = []; preg_match('/([a-zA-Z0-9_]+\\\\[a-zA-Z0-9_]+)\\\\(.+)/', $class_name, $match); if ($match) { $root_namespace = $match[1]; $rest_fqcn = $match[2]; $proxy_filename = $namespace_root . '/ProxyClass/' . str_replace('\\', '/', $rest_fqcn) . '.php'; $proxy_class_name = $root_namespace . '\\ProxyClass\\' . $rest_fqcn; $proxy_class_string = $this->proxyBuilder->build($class_name); $file_string = <<<EOF <?php // @codingStandardsIgnoreFile /** * This file was generated via php core/scripts/generate-proxy-class.php '{$class_name}' "{$namespace_root}". */ {{ proxy_class_string }} EOF; $file_string = str_replace(['{{ proxy_class_name }}', '{{ proxy_class_string }}'], [$proxy_class_name, $proxy_class_string], $file_string); mkdir(dirname($proxy_filename), 0775, TRUE); file_put_contents($proxy_filename, $file_string); $output->writeln(sprintf('Proxy of class %s written to %s', $class_name, $proxy_filename)); } }
protected function execute(InputInterface $input, OutputInterface $output) { $newStatus = $input->getArgument('status'); $em = $this->getContainer()->get('Doctrine')->getManager(); $entity = $em->getRepository('ParkBundle:Computer')->findAll(); if ($newStatus == "actif") { foreach ($entity as $computer) { $computer->setEnabled(true); } $em->flush(); $text = "Tous les ordinateurs ont ete actives"; } elseif ($newStatus == "inactif") { foreach ($entity as $computer) { $computer->setEnabled(false); } $em->flush(); $text = "Tous les ordinateurs ont ete desactives"; } elseif ($newStatus == "toggle") { foreach ($entity as $computer) { $computer->setEnabled(!$computer->getEnabled()); } $em->flush(); $text = "Tous les ordinateurs ont change d'etat"; } else { $text = "Probleme lors de l'execution de la commande (le statut doit etre actif ou inactif)"; } $output->writeln($text); }
private function cleanupTerms(Treatment $treatment) { // find terms for this treatment $qb = $this->om->createQueryBuilder(); $qb->select('t2')->from('TermBundle:Term', 't2')->innerJoin('t2.termDocuments', 'td', Join::WITH, 'td.type = :treatmentType')->setParameter('treatmentType', TermDocument::TYPE_TREATMENT)->where('td.documentId = :treatmentId')->setParameter('treatmentId', $treatment->getId()); $terms = $qb->getQuery()->getResult(); $this->output->writeln('Cleaning terms for treatment #' . $treatment->getId() . ' [' . $treatment->getName() . ']'); if (\count($terms)) { $hasInternal = false; foreach ($terms as $term) { $this->output->write($this->indent() . $term->getName() . " [#{$term->getId()}]" . $this->indent()); if (!$term->getInternal()) { // if this has not been flagged as internal yet, flag it $term->setInternal(\strtolower($term->getName()) == \strtolower($treatment->getName())); } if (!$hasInternal) { $hasInternal = $term->getInternal(); } $this->om->persist($term); $this->output->writeln('[OK]'); } if (!$hasInternal) { $term = $this->createTermFromTreatment($treatment); $this->om->persist($term); $this->output->writeln($this->indent() . 'Added internal term'); } } else { $this->output->write($this->indent() . "Found no terms: "); $term = $this->createTermFromTreatment($treatment); $this->om->persist($term); $this->output->writeln('[OK]'); } }
/** * @param InputInterface $input * @param OutputInterface $output * * @return void */ public function execute(InputInterface $input, OutputInterface $output) { $kernel = $this->container->get('kernel'); $router = $this->container->get('router'); $route = $input->getOption('route'); $uri = $input->getOption('uri'); $uri = $route ? $router->generate($route) : $uri; $parameters = $input->getOption('parameters'); $parameters = json_decode($parameters, JSON_OBJECT_AS_ARRAY); $cookies = $input->getOption('cookies'); $cookies = json_decode($cookies, JSON_OBJECT_AS_ARRAY); $files = $input->getOption('files'); $files = json_decode($files, JSON_OBJECT_AS_ARRAY); $server = $input->getOption('server'); $server = json_decode($server, JSON_OBJECT_AS_ARRAY); $encoding = $input->getOption('encoding'); $content = $input->getOption('content'); $content = $this->decode($content, $encoding); $method = $input->getOption('method') ?: 'GET'; $method = ($method === 'GET' and $content) ? 'POST' : $method; $request = Request::create($uri, $method, $parameters, $cookies, $files, $server, $content); $response = $kernel->handle($request, Kernel::SUB_REQUEST); $result = $response->getContent(); if ($response->headers->get('Content-Type') === 'application/json') { $result = json_decode($result, JSON_OBJECT_AS_ARRAY); $result = json_encode($result, JSON_PRETTY_PRINT); } $output->writeln($result); return; }
protected function execute(InputInterface $input, OutputInterface $output) { $inputSource = $input->getOption('input'); $size = (int) $input->getOption('size'); if ($size < 1 || $size > 2000) { $output->writeln('<error>Sample size must be a positive integer between 1 and 2000.</error>'); return; } // Input size should be 10 times the size of the sample $streamSize = $size * 10; switch ($inputSource) { case 'stdin': $stream = new StreamIterator(); break; case 'random.org': $stream = new RandomOrgIterator($this->httpClient); $stream->setLength($streamSize); break; case 'internal': $stream = new RandomByteIterator(); $stream->setLength($streamSize); break; default: $output->writeln('<error>Unknown input source: "' . $inputSource . '". Use either stdin, random.org or internal.</error>'); return; } $this->sampler->setStream($stream); $result = $this->sampler->getSampleAsString($size); $output->writeln($result); }
protected function runCommand(InputInterface $input, OutputInterface $output) { $output->writeln(''); $executedMigrations = $this->manager->executedMigrations(); $output->writeln('<comment>Executed migrations</comment>'); if (empty($executedMigrations)) { $output->writeln('<info>No executed migrations</info>'); } else { $rows = []; foreach ($executedMigrations as $migration) { $rows[] = [ltrim($migration['classname'], '\\'), $migration['executed_at']]; } $this->printTable(['Class name', 'Executed at'], $rows, $output); } $output->writeln(''); $migrations = $this->manager->findMigrationsToExecute(Manager::TYPE_UP); $output->writeln('<comment>Migrations to execute</comment>'); if (empty($migrations)) { $output->writeln('<info>No migrations to execute</info>'); } else { $rows = []; foreach ($migrations as $migration) { $rows[] = [$migration->getClassName()]; } $this->printTable(['Class name'], $rows, $output); } }
protected function execute(InputInterface $input, OutputInterface $output) { $header_style = new OutputFormatterStyle('white', 'green', array('bold')); $output->getFormatter()->setStyle('header', $header_style); $start = intval($input->getOption('start')); $stop = intval($input->getOption('stop')); if ($start >= $stop || $start < 0) { throw new \InvalidArgumentException('Stop number should be greater than start number'); } $output->writeln('<header>Fibonacci numbers between ' . $start . ' - ' . $stop . '</header>'); $xnM2 = 0; // set x(n-2) $xnM1 = 1; // set x(n-1) $xn = 0; // set x(n) $totalFiboNr = 0; while ($xnM2 <= $stop) { if ($xnM2 >= $start) { $output->writeln('<header>' . $xnM2 . '</header>'); $totalFiboNr++; } $xn = $xnM1 + $xnM2; $xnM2 = $xnM1; $xnM1 = $xn; } $output->writeln('<header>Total of Fibonacci numbers found = ' . $totalFiboNr . ' </header>'); }
protected function execute(InputInterface $input, OutputInterface $output) { $command = $input->getArgument('cmd'); $params = json_decode($input->getArgument('params'), true); // Create new job /** @var JobFactory $jobFactory */ $jobFactory = $this->getContainer()->get('syrup.job_factory'); $jobFactory->setStorageApiClient($this->storageApi); $job = $jobFactory->create($command, $params); // Add job to Elasticsearch /** @var JobMapper $jobMapper */ $jobMapper = $this->getContainer()->get('syrup.elasticsearch.current_component_job_mapper'); $jobId = $jobMapper->create($job); $output->writeln('Created job id ' . $jobId); // Run Job if ($input->getOption('run')) { $runJobCommand = $this->getApplication()->find('syrup:run-job'); $returnCode = $runJobCommand->run(new ArrayInput(['command' => 'syrup:run-job', 'jobId' => $jobId]), $output); if ($returnCode == 0) { $output->writeln('Job successfully executed'); } elseif ($returnCode == 2 || $returnCode == 64) { $output->writeln('DB is locked. Run job later using syrup:run-job'); } else { $output->writeln('Error occured'); } } return 0; }
/** * {@inheritdoc } */ protected function execute(InputInterface $input, OutputInterface $output) { $privateKeyPath = $input->getOption('privateKey'); $keyBundlePath = $input->getOption('certificate'); $path = $input->getOption('path'); if (is_null($privateKeyPath) || is_null($keyBundlePath) || is_null($path)) { $output->writeln('--privateKey, --certificate and --path are required.'); return null; } $privateKey = $this->fileAccessHelper->file_get_contents($privateKeyPath); $keyBundle = $this->fileAccessHelper->file_get_contents($keyBundlePath); if ($privateKey === false) { $output->writeln(sprintf('Private key "%s" does not exists.', $privateKeyPath)); return null; } if ($keyBundle === false) { $output->writeln(sprintf('Certificate "%s" does not exists.', $keyBundlePath)); return null; } $rsa = new RSA(); $rsa->loadKey($privateKey); $x509 = new X509(); $x509->loadX509($keyBundle); $x509->setPrivateKey($rsa); $this->checker->writeCoreSignature($x509, $rsa, $path); $output->writeln('Successfully signed "core"'); }
/** * @see Console\Command\Command */ protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) { $dm = $this->getHelper('documentManager')->getDocumentManager(); $metadatas = $dm->getMetadataFactory()->getAllMetadata(); $metadatas = MetadataFilter::filter($metadatas, $input->getOption('filter')); // Process destination directory if (($destPath = $input->getArgument('dest-path')) === null) { $destPath = $dm->getConfiguration()->getProxyDir(); } if (!is_dir($destPath)) { mkdir($destPath, 0775, true); } $destPath = realpath($destPath); if (!file_exists($destPath)) { throw new \InvalidArgumentException(sprintf("Proxies destination directory '<info>%s</info>' does not exist.", $destPath)); } elseif (!is_writable($destPath)) { throw new \InvalidArgumentException(sprintf("Proxies destination directory '<info>%s</info>' does not have write permissions.", $destPath)); } if (count($metadatas)) { foreach ($metadatas as $metadata) { $output->write(sprintf('Processing document "<info>%s</info>"', $metadata->name) . PHP_EOL); } // Generating Proxies $dm->getProxyFactory()->generateProxyClasses($metadatas, $destPath); // Outputting information message $output->write(PHP_EOL . sprintf('Proxy classes generated to "<info>%s</INFO>"', $destPath) . PHP_EOL); } else { $output->write('No Metadata Classes to process.' . PHP_EOL); } }
/** * Execute the command. * * @param Input $input * @param Output $output * @return void */ protected function execute(Input $input, Output $output) { $name = $input->getArgument("name"); // Validate the name straight away. if (count($chunks = explode("/", $name)) != 2) { throw new \InvalidArgumentException("Invalid repository name '{$name}'."); } $output->writeln(sprintf("Cloning <comment>%s</comment> into <info>%s/%s</info>...", $name, getcwd(), end($chunks))); // If we're in a test environment, stop executing. if (defined("ADVISER_UNDER_TEST")) { return null; } // @codeCoverageIgnoreStart if (!$this->git->cloneGithubRepository($name)) { throw new \UnexpectedValueException("Repository https://github.com/{$name} doesn't exist."); } // Change the working directory. chdir($path = getcwd() . "/" . end($chunks)); $output->writeln(sprintf("Changed the current working directory to <comment>%s</comment>.", $path)); $output->writeln(""); // Running "AnalyseCommand"... $arrayInput = [""]; if (!is_null($input->getOption("formatter"))) { $arrayInput["--formatter"] = $input->getOption("formatter"); } $this->getApplication()->find("analyse")->run(new ArrayInput($arrayInput), $output); // Change back, remove the directory. chdir(getcwd() . "/.."); $this->removeDirectory($path); $output->writeln(""); $output->writeln(sprintf("Switching back to <info>%s</info>, removing <comment>%s</comment>...", getcwd(), $path)); // @codeCoverageIgnoreStop }
/** * Prints a result set from Detector::copyPasteDetection(). * * @param OutputInterface $output * @param CodeCloneMap $clones */ public function printResult(OutputInterface $output, CodeCloneMap $clones) { $numClones = count($clones); $verbose = $output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL; if ($numClones > 0) { $buffer = ''; $files = array(); $lines = 0; foreach ($clones as $clone) { foreach ($clone->getFiles() as $file) { $filename = $file->getName(); if (!isset($files[$filename])) { $files[$filename] = true; } } $lines += $clone->getSize() * (count($clone->getFiles()) - 1); $buffer .= "\n -"; foreach ($clone->getFiles() as $file) { $buffer .= sprintf("\t%s:%d-%d\n ", $file->getName(), $file->getStartLine(), $file->getStartLine() + $clone->getSize()); } if ($verbose) { $buffer .= "\n" . $clone->getLines(' '); } } $output->write(sprintf("Found %d exact clones with %d duplicated lines in %d files:\n%s", $numClones, $lines, count($files), $buffer)); } $output->write(sprintf("%s%s duplicated lines out of %d total lines of code.\n\n", $numClones > 0 ? "\n" : '', $clones->getPercentage(), $clones->getNumLines())); }
/** * @param InputInterface $input * @param OutputInterface $output * @param array $items * @param string $prefix */ protected function writeArrayInOutputFormat(InputInterface $input, OutputInterface $output, $items, $prefix = ' - ') { switch ($input->getOption('output')) { case self::OUTPUT_FORMAT_JSON: $output->writeln(json_encode($items)); break; case self::OUTPUT_FORMAT_JSON_PRETTY: $output->writeln(json_encode($items, JSON_PRETTY_PRINT)); break; default: foreach ($items as $key => $item) { if (is_array($item)) { $output->writeln($prefix . $key . ':'); $this->writeArrayInOutputFormat($input, $output, $item, ' ' . $prefix); continue; } if (!is_int($key)) { $value = $this->valueToString($item); if (!is_null($value)) { $output->writeln($prefix . $key . ': ' . $value); } else { $output->writeln($prefix . $key); } } else { $output->writeln($prefix . $this->valueToString($item)); } } break; } }
protected function execute(InputInterface $input, OutputInterface $output) { $groupPattern = $input->getArgument('group'); if (empty($groupPattern)) { $groupPattern = '.*'; } $cloudwatchLogsClient = \AwsInspector\SdkFactory::getClient('cloudwatchlogs'); /* @var $cloudwatchLogsClient \Aws\CloudWatchLogs\CloudWatchLogsClient */ $table = new Table($output); $table->setHeaders(['Name', 'Retention [days]', 'Size [MB]']); $totalBytes = 0; $nextToken = null; do { $params = ['limit' => 50]; if ($nextToken) { $params['nextToken'] = $nextToken; } $result = $cloudwatchLogsClient->describeLogGroups($params); foreach ($result->get('logGroups') as $logGroup) { $name = $logGroup['logGroupName']; if (preg_match('/' . $groupPattern . '/', $name)) { $table->addRow([$logGroup['logGroupName'], isset($logGroup['retentionInDays']) ? $logGroup['retentionInDays'] : 'Never', round($logGroup['storedBytes'] / (1024 * 1024))]); $totalBytes += $logGroup['storedBytes']; } } $nextToken = $result->get("nextToken"); } while ($nextToken); $table->render(); $output->writeln('Total size: ' . $this->formatBytes($totalBytes)); }
protected function execute(InputInterface $input, OutputInterface $output) { /* $manager = new DisconnectedMetadataFactory($this->getContainer()->get('doctrine')); try { $bundle = $this->getApplication()->getKernel()->getBundle($input->getArgument('name')); $output->writeln(sprintf('Getting info from entities "<info>%s</info>"', $bundle->getName())); $metadata = $manager->getBundleMetadata($bundle); } catch (\InvalidArgumentException $e) { $name = strtr($input->getArgument('name'), '/', '\\'); if (false !== $pos = strpos($name, ':')) { $name = $this->getContainer()->get('doctrine')->getAliasNamespace(substr($name, 0, $pos)).'\\'.substr($name, $pos + 1); } if (class_exists($name)) { $output->writeln(sprintf('Generating entity "<info>%s</info>"', $name)); $metadata = $manager->getClassMetadata($name, $input->getOption('path')); } else { $output->writeln(sprintf('Generating entities for namespace "<info>%s</info>"', $name)); $metadata = $manager->getNamespaceMetadata($name, $input->getOption('path')); } } $output->writeln($metadata); */ $generator = $this->getContainer()->get('gcob_ng_table.generator'); $generator->setEntity($input->getArgument('name')); $generator->generate(); $output->writeln('success'); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { if (false !== strpos($input->getFirstArgument(), ':d')) { $output->writeln('<comment>The use of "container:debug" command is deprecated since version 2.7 and will be removed in 3.0. Use the "debug:container" instead.</comment>'); } $this->validateInput($input); if ($input->getOption('parameters')) { $object = $this->getContainerBuilder()->getParameterBag(); $options = array(); } elseif ($parameter = $input->getOption('parameter')) { $object = $this->getContainerBuilder(); $options = array('parameter' => $parameter); } elseif ($input->getOption('tags')) { $object = $this->getContainerBuilder(); $options = array('group_by' => 'tags', 'show_private' => $input->getOption('show-private')); } elseif ($tag = $input->getOption('tag')) { $object = $this->getContainerBuilder(); $options = array('tag' => $tag, 'show_private' => $input->getOption('show-private')); } elseif ($name = $input->getArgument('name')) { $object = $this->getContainerBuilder(); $name = $this->findProperServiceName($input, $output, $object, $name); $options = array('id' => $name); } else { $object = $this->getContainerBuilder(); $options = array('show_private' => $input->getOption('show-private')); } $helper = new DescriptorHelper(); $options['format'] = $input->getOption('format'); $options['raw_text'] = $input->getOption('raw'); $helper->describe($output, $object, $options); if (!$input->getArgument('name') && $input->isInteractive()) { $output->writeln('To search for a service, re-run this command with a search term. <comment>debug:container log</comment>'); } }
protected function execute(InputInterface $input, OutputInterface $output) { $magento = new Magento($input->getOption('magento-root')); $config_adapter = new ConfigurationAdapter($magento); $yaml = new Parser(); if ($input->getArgument('config-yaml-file')) { $config_yaml_file = $input->getArgument('config-yaml-file'); if (!file_exists($config_yaml_file)) { throw new \Exception("File ({$config_yaml_file}) does not exist"); } if (!is_readable($config_yaml_file)) { throw new \Exception("File ({$config_yaml_file}) is not readable"); } $config_db_yaml = ConfigYaml::build($config_adapter); $config_file_contents = $yaml->parse(file_get_contents($config_yaml_file)); $config_file_yaml = new ConfigYaml($config_file_contents, $input->getOption('env')); $diff = ConfigYaml::compare($config_file_yaml, $config_db_yaml); if (count($diff) > 0) { $db_data = $config_db_yaml->getData(); $file_data = $config_file_yaml->getData(); $diff_count = 0; foreach ($diff as $scope => $scope_data) { foreach ($scope_data as $key => $value) { $diff_count++; $diff_message = sprintf("%s/%s is different (File: %s, DB: %s)", $scope, $key, $this->decorateValue($file_data[$scope][$key]), $this->decorateValue($db_data[$scope][$key])); $output->writeln($diff_message); } } return $diff_count; } else { return 0; } } }
protected function execute(InputInterface $input, OutputInterface $output) { $this->output = $output; $this->client = $client = SnsClient::factory(array('key' => $this->getContainer()->getParameter('amazon_s3.key'), 'secret' => $this->getContainer()->getParameter('amazon_s3.secret'), 'region' => $this->getContainer()->getParameter('amazon_s3.region'))); if ($input->getOption('list-android')) { $this->showEndpoints($this->getContainer()->getParameter('amazon_sns.android_arn'), 'List of GCM endpoints:'); } if ($input->getOption('list-ios')) { $this->showEndpoints($this->getContainer()->getParameter('amazon_sns.ios_arn'), 'List of APNS endpoints:'); } $endpoint = $input->getArgument('endpoint'); if ($endpoint) { if ($input->getOption('delete')) { $output->writeln('<comment>Delete endpoint</comment>'); $client->deleteEndpoint(array('EndpointArn' => $endpoint)); } else { $testMessage = 'Test notification'; try { $client->publish(array('TargetArn' => $endpoint, 'MessageStructure' => 'json', 'Message' => json_encode(array('APNS' => json_encode(array('aps' => array('alert' => $testMessage))), 'GCM' => json_encode(array('data' => array('message' => $testMessage))))))); } catch (\Aws\Sns\Exception\SnsException $e) { $output->writeln("<error>{$e->getMessage()}</error>"); } } } }
protected function execute(InputInterface $input, OutputInterface $output) { foreach ($this->dropOrder as $option) { if ($input->getOption($option)) { $drop[] = $option; } } // Default to the full drop order if no options were specified $drop = empty($drop) ? $this->dropOrder : $drop; $class = $input->getOption('class'); $sm = $this->getSchemaManager(); $isErrored = false; foreach ($drop as $option) { try { if (isset($class)) { $this->{'processDocument' . ucfirst($option)}($sm, $class); } else { $this->{'process' . ucfirst($option)}($sm); } $output->writeln(sprintf('Dropped <comment>%s%s</comment> for <info>%s</info>', $option, isset($class) ? self::INDEX === $option ? '(es)' : '' : (self::INDEX === $option ? 'es' : 's'), isset($class) ? $class : 'all classes')); } catch (\Exception $e) { $output->writeln('<error>' . $e->getMessage() . '</error>'); $isErrored = true; } } return $isErrored ? 255 : 0; }
protected function execute(InputInterface $input, OutputInterface $output) { $emName = $input->getOption('em'); $emName = $emName ? $emName : 'default'; $emServiceName = sprintf('doctrine.orm.%s_entity_manager', $emName); $em = $this->container->get($emServiceName); $dirOrFile = $input->getOption('fixtures'); if ($dirOrFile) { $paths = is_array($dirOrFile) ? $dirOrFile : array($dirOrFile); } else { $paths = array(); foreach ($this->application->getKernel()->getBundles() as $bundle) { $paths[] = $bundle->getPath() . '/DataFixtures/ORM'; } } $loader = new DataFixturesLoader($this->container); foreach ($paths as $path) { if (is_dir($path)) { $loader->loadFromDirectory($path); } } $fixtures = $loader->getFixtures(); $purger = new ORMPurger($em); $executor = new ORMExecutor($em, $purger); $executor->setLogger(function ($message) use($output) { $output->writeln(sprintf(' <comment>></comment> <info>%s</info>', $message)); }); $executor->execute($fixtures, $input->getOption('append')); }
protected function execute(InputInterface $input, OutputInterface $output) { $this->em = $this->getContainer()->get('doctrine')->getEntityManager(); $this->output = $output; $supported_locales = $this->getContainer()->getParameter('supported_locales'); $default_locale = $this->getContainer()->getParameter('locale'); $locales = $input->getOption('locale'); if (empty($locales)) { $locales = $supported_locales; } $path = $input->getArgument('path'); if (substr($path, -1) === '/') { $path = substr($path, 0, strlen($path) - 1); } $things = ['faction', 'type', 'cycle', 'pack']; foreach ($locales as $locale) { if ($locale === $default_locale) { continue; } $output->writeln("Importing translations for <info>{$locale}</info>"); foreach ($things as $thing) { $output->writeln("Importing translations for <info>{$thing}s</info> in <info>{$locale}</info>"); $fileInfo = $this->getFileInfo("{$path}/translations/{$locale}", "{$thing}s.json"); $this->importThingsJsonFile($fileInfo, $locale, $thing); } $this->em->flush(); $fileSystemIterator = $this->getFileSystemIterator("{$path}/translations/{$locale}"); $output->writeln("Importing translations for <info>cards</info> in <info>{$locale}</info>"); foreach ($fileSystemIterator as $fileInfo) { $output->writeln("Importing translations for <info>cards</info> from <info>" . $fileInfo->getFilename() . "</info>"); $this->importCardsJsonFile($fileInfo, $locale); } $this->em->flush(); } }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { if ($this->command !== null) { // help for an individual command $output->page($this->command->asText()); $this->command = null; } elseif ($name = $input->getArgument('command_name')) { // help for an individual command $output->page($this->getApplication()->get($name)->asText()); } else { // list available commands $commands = $this->getApplication()->all(); $width = 0; foreach ($commands as $command) { $width = strlen($command->getName()) > $width ? strlen($command->getName()) : $width; } $width += 2; foreach ($commands as $name => $command) { if ($name !== $command->getName()) { continue; } if ($command->getAliases()) { $aliases = sprintf(' <comment>Aliases:</comment> %s', implode(', ', $command->getAliases())); } else { $aliases = ''; } $messages[] = sprintf(" <info>%-{$width}s</info> %s%s", $name, $command->getDescription(), $aliases); } $output->page($messages); } }
protected function execute(InputInterface $input, OutputInterface $output) { $em = $this->getContainer()->get('doctrine')->getManager(); $scheduler = $this->getContainer()->get('scheduler'); $subject = $input->getArgument('subject'); $template = $input->getArgument('template'); $campaignId = $input->getArgument('campaignId'); $deliveryTime = new \DateTime($input->getArgument('deliverytime')); $date = $input->getArgument('date'); // The date at which the job is to be run $dateParts = explode('-', $date); if (!checkdate($dateParts[1], $dateParts[2], $dateParts[0])) { $output->writeLn("<error>Invalid date or format. Correct format is Y-m-d</error>"); return; } $now = new \DateTime(); $output->writeln("<comment>Scheduling announcement email started on {$now->format('Y-m-d H:i:s')}</comment>"); // Get All Users $qb = $em->createQueryBuilder(); $qb->add('select', 'u.id')->add('from', 'ClassCentralSiteBundle:User u')->join('u.userPreferences', 'up')->andWhere("up.value = 1")->andWhere("up.type=" . UserPreference::USER_PREFERENCE_FOLLOW_UP_EMAILs); $users = $qb->getQuery()->getArrayResult(); $scheduled = 0; foreach ($users as $user) { $id = $scheduler->schedule(new \DateTime($date), AnnouncementEmailJob::ANNOUNCEMENT_EMAIL_JOB_TYPE, 'ClassCentral\\MOOCTrackerBundle\\Job\\AnnouncementEmailJob', array('template' => $template, 'subject' => $subject, 'campaignId' => $campaignId, 'deliveryTime' => $deliveryTime->format(\DateTime::RFC2822)), $user['id']); if ($id) { $scheduled++; } } $output->writeln("<info>{$scheduled} jobs scheduled</info>"); }