/** * Verbose write line * * @param string $area Area * @param string $line Line */ public static function verboseWriteln($area, $line) { if (self::$output->isVerbose()) { // Special stuff if line is exception if ($line instanceof \Exception) { /** @var \Exception $e */ $e = $line; $line = array(); $line[] = '--- EXCEPTION ---'; $line[] = $e->getMessage(); $line[] = ' FILE: ' . $e->getFile(); $line[] = ' LINE: ' . $e->getLine(); $line = implode("\n", $line); } // Process lines $lineList = explode("\n", $line); if (count($lineList) >= 1) { unset($line); foreach ($lineList as &$line) { $line = ' ' . ltrim($line); } unset($line); $line = implode("\n", $lineList); } $line = sprintf("<info>[VERBOSE %s]</info>\n<comment>%s</comment>\n", $area, $line); self::$output->writeln($line); } }
protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln('[incidents:reports]: Starting.'); $output->write('[incidents:reports]: Getting reports...'); try { $report_files = glob($this->getContainer()->getParameter('cert_unlp.ngen.incident.report.markdown.path') . '/*'); // get all file names $common_report_files = glob($this->getContainer()->getParameter('cert_unlp.ngen.incident.report.markdown.path') . '/common/*'); $output->writeln('Done'); foreach ($report_files as $file) { // iterate files $filename = basename($file); if (!in_array($filename, ['TODO.md', 'template.md', 'common'])) { if ($output->isVerbose()) { $output->writeln('[incidents:reports]: parsing ' . $filename); } $html = $this->getContainer()->get('markdown.parser')->transformMarkdown(file_get_contents($file)); file_put_contents($this->getContainer()->getParameter('cert_unlp.ngen.incident.report.twig.path') . "/" . str_replace(".md", "Report.html.twig", basename($file)), $html); } } foreach ($common_report_files as $file) { // iterate files $filename = basename($file); if ($output->isVerbose()) { $output->writeln('[incidents:reports]: parsing ' . $filename); } $html = $this->getContainer()->get('markdown.parser')->transformMarkdown(file_get_contents($file), false); file_put_contents($this->getContainer()->getParameter('cert_unlp.ngen.incident.report.twig.path') . "/BaseReport/" . str_replace(".md", "Report.html.twig", basename($file)), $html); } } catch (Exception $ex) { $output->writeln('[incidents:reports]: Something is wrong.'); } $output->writeln('[incidents:reports]: Done.'); }
protected function execute(InputInterface $input, OutputInterface $output) { $range = $input->getArgument('range') ?: (isset($_SERVER['TRAVIS_COMMIT_RANGE']) ? $_SERVER['TRAVIS_COMMIT_RANGE'] : ''); if (!$range) { throw new \RuntimeException("No git range given via argument or TRAVIS_COMMIT_RANGE environment variable."); } exec('git diff --name-only ' . escapeshellarg($range), $result); $build = new Build(new ConsoleIO($input, $output, $this->getHelperSet())); $this->packages = $build->loadPackages(getcwd()); $changePackageName = rtrim($input->getArgument('package'), '/'); $this->calculateDependencies($changePackageName); if ($output->isVerbose()) { $output->writeln('Checking for changes in the following directories:'); foreach ($this->checkPaths as $checkPath) { $output->writeln('- ' . $checkPath); } $output->writeln(sprintf('Iterating the changed files in git commit range %s', $range)); } $found = false; foreach ($result as $changedFile) { if ($output->isVerbose()) { $output->writeln(sprintf("- %s", $changedFile)); } foreach ($this->checkPaths as $checkPath) { if (strpos(trim($changedFile), $checkPath) !== false) { if ($output->isVerbose()) { $output->writeln(sprintf(' Matches check path %s', $checkPath)); } $found = true; } } } exit($found ? 0 : 1); }
protected function execute(InputInterface $input, OutputInterface $output) { /* Get requests in the desired time frame. */ $em = $this->getContainer()->get('doctrine')->getManager(); $date = new \DateTime($input->getOption('time_frame')); $requests = $em->getRepository('SwdAnalyzerBundle:Request')->findByDate($date)->getResult(); if (empty($requests)) { if ($output->isVerbose()) { $output->writeln('No requests found'); } return; } /* Send e-mails to all users that have specified an address. */ $users = $em->getRepository('SwdAnalyzerBundle:User')->findByEmail()->getResult(); if (empty($users)) { if ($output->isVerbose()) { $output->writeln('No e-mail addresses found'); } return; } foreach ($users as $user) { if ($output->isVerbose()) { $output->writeln('Send email to ' . $user->getEmail()); } $message = \Swift_Message::newInstance()->setSubject('Shadow Daemon Report')->setFrom('*****@*****.**')->setTo($user->getEmail())->setBody($this->getContainer()->get('templating')->render('SwdAnalyzerBundle:Report:email.txt.twig', array('requests' => $requests))); $this->getContainer()->get('mailer')->send($message); } }
/** * @param $message */ public function write($message) { if ($this->output instanceof Output && !$this->output->isVerbose()) { $this->output->write('.'); } else { $this->output->write($message); } }
protected function execute(InputInterface $input, OutputInterface $output) { $config = $input->getArgument('config'); if ($config) { try { $this->loadConfig($config); } catch (\Exception $e) { if (!$output->isQuiet()) { $output->writeln(sprintf("Failed to load config: %s", $e->getMessage())); } exit(1); } } if (empty($this->config)) { if (!$output->isQuiet()) { $output->writeln("No configuration found."); } exit(1); } try { $params = array('version' => $this->config->getVersion(), 'region' => $this->config->getRegion(), 'credentials' => array('key' => $this->config->getCredentials()->getKey(), 'secret' => $this->config->getCredentials()->getSecret())); if ($this->config->getTimeout() !== NULL) { $params['http']['timeout'] = $this->config->getTimeout(); } $client = new S3Client($params); } catch (\Exception $e) { if (!$output->isQuiet()) { $output->writeln("Failed to connect to AWS."); } exit(1); } foreach ($this->config->getBuckets() as $bucket) { // Make sure the Bucket's destination is writable. $destination = $bucket->getDestination(); if (!is_writable($destination)) { $output->writeln(sprintf('Failed to write to destination "%s".', $destination)); exit(1); } if ($bucket->getObjects()) { try { $this->fetchBucketByObjects($bucket, $client); } catch (\Exception $e) { if ($output->isVerbose()) { $output->writeln(sprintf('An error occured fetching Bucket "%s": %s', $bucket->getName(), $e->getMessage())); } } } else { try { $this->fetchBucketByLimit($bucket, $client); } catch (\Exception $e) { if ($output->isVerbose()) { $output->writeln(sprintf('An error occured fetching Bucket "%s": %s', $bucket->getName(), $e->getMessage())); } } } } return true; }
protected function log($message, $verbosity = 1) { if (!$this->output instanceof OutputInterface) { return $this; } if (1 == $verbosity && $this->output->isVerbose()) { $this->output->writeln($message); } if (2 == $verbosity && $this->output->isVeryVerbose()) { $this->output->writeln(' ' . $message); } return $this; }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $args = []; $out = $input->getOption('out'); $psr4 = $input->getOption('psr4'); $protoc = $input->getOption('protoc'); $protos = $input->getArgument('protos'); $include = $input->getOption('include') ?: []; $builder = $this->createProcessBuilder($this->plugin, $protoc); if ($output->isVerbose()) { $args['verbose'] = 1; } if ($input->getOption('generate-imported')) { $args['generate-imported'] = 1; } if ($psr4) { $args['psr4'] = $psr4; } if ($input->getOption('include-descriptors')) { $builder->setIncludeDescriptors(true); $builder->setDescriptorPaths([__DIR__ . '/../../../google-protobuf-proto/src', __DIR__ . '/../../vendor/protobuf-php/google-protobuf-proto/src']); } $builder->assertVersion(); $process = $builder->createProcess($out, $protos, $include, $args); $command = $process->getCommandLine(); if ($output->isVerbose()) { $output->writeln("Generating protos with protoc -- {$command}"); } // Run command $process->run(function ($type, $buffer) use($output) { if (!$output->isVerbose() || !$buffer) { return; } $output->writeln($buffer); }); $return = $process->getExitCode(); $result = $process->getOutput(); if ($return === 0) { $output->writeln("<info>PHP classes successfully generate.</info>"); return $return; } $output->writeln('<error>protoc exited with an error (' . $return . ') when executed with: </error>'); $output->writeln(''); $output->writeln(' ' . $command); $output->writeln(''); $output->writeln($result); $output->writeln(''); $output->writeln($process->getErrorOutput()); $output->writeln(''); return $return; }
public function compare() { if (empty($this->stack)) { throw new \InvalidArgumentException('Stack not set'); } if (empty($this->blueprint)) { throw new \InvalidArgumentException('Blueprint not set'); } $tmp = []; try { // parameters if ($this->output->isVerbose()) { $this->output->writeln($this->stack->getName() . ': Comparing parameters'); } $parametersStack = $this->stack->getParameters(); $parametersBlueprint = $this->blueprint->getParameters(true); $parametersBlueprint = Div::flatten($parametersBlueprint, 'ParameterKey', 'ParameterValue'); if ($this->parametersAreEqual($parametersStack, $parametersBlueprint)) { $tmp['parameters'] = "<fg=green>equal</>"; } else { $tmp['parameters'] = "<fg=red>different</>"; $tmp['error'] = true; } // template if ($this->output->isVerbose()) { $this->output->writeln($this->stack->getName() . ': Comparing template'); } $templateStack = trim($this->stack->getTemplate()); $templateBlueprint = trim($this->blueprint->getPreprocessedTemplate()); $templateStack = $this->normalizeJson($templateStack); $templateBlueprint = $this->normalizeJson($templateBlueprint); if ($templateStack === $templateBlueprint) { $tmp['template'] = "<fg=green>equal</>"; } else { $tmp['template'] = "<fg=red>different</>"; $tmp['error'] = true; } } catch (CloudFormationException $e) { $tmp['parameters'] = 'Stack not found'; $tmp['template'] = 'Stack not found'; $tmp['error'] = true; } catch (\Exception $e) { $tmp['parameters'] = '<fg=red>EXCEPTION: ' . $e->getMessage() . '</>'; $tmp['template'] = 'EXCEPTION'; $tmp['error'] = true; } return $tmp; }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $realCacheDir = $this->getContainer()->getParameter('kernel.cache_dir'); // the old cache dir name must not be longer than the real one to avoid exceeding // the maximum length of a directory or file path within it (esp. Windows MAX_PATH) $oldCacheDir = substr($realCacheDir, 0, -1) . ('~' === substr($realCacheDir, -1) ? '+' : '~'); $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 $realCacheDir = realpath($realCacheDir); $warmupDir = substr($realCacheDir, 0, -1) . ('_' === substr($realCacheDir, -1) ? '-' : '_'); if ($filesystem->exists($warmupDir)) { if ($output->isVerbose()) { $output->writeln(' Clearing outdated warmup directory'); } $filesystem->remove($warmupDir); } if ($output->isVerbose()) { $output->writeln(' Warming up cache'); } $this->warmup($warmupDir, $realCacheDir, !$input->getOption('no-optional-warmers')); $filesystem->rename($realCacheDir, $oldCacheDir); if ('\\' === DIRECTORY_SEPARATOR) { sleep(1); // workaround for Windows PHP rename bug } $filesystem->rename($warmupDir, $realCacheDir); } if ($output->isVerbose()) { $output->writeln(' Removing old cache directory'); } $filesystem->remove($oldCacheDir); if ($output->isVerbose()) { $output->writeln(' Done'); } }
protected function _execute(InputInterface $input, OutputInterface $output) { $group = $input->getArgument('group'); $name = $input->getArgument('name'); $isDefault = $input->getOption('default'); if (!$name) { $name = $group; } $cnx = \jDb::getConnection('jacl2_profile'); try { $sql = "INSERT into " . $cnx->prefixTable('jacl2_group') . " (id_aclgrp, name, grouptype, ownerlogin) VALUES ("; $sql .= $cnx->quote($group) . ','; $sql .= $cnx->quote($name) . ','; if ($isDefault) { $sql .= '1, NULL)'; } else { $sql .= '0, NULL)'; } $cnx->exec($sql); } catch (\Exception $e) { throw new \Exception("this group already exists"); } if ($output->isVerbose()) { $output->writeln("Group '" . $group . "' is created"); } }
protected function execute(InputInterface $input, OutputInterface $output) { $limit = intval($input->getOption('limit')); if ($limit <= 0) { throw new \InvalidArgumentException('"limit" number must be positive'); } foreach ($this->numberGenerator($limit) as $i) { if ($output->isVerbose()) { $output->write("{$i}: "); } if ($i % 3 === 0) { if ($i % 5 === 0) { $this->showFizzBuzz($output); } else { $this->showFizz($output); } } else { if ($i % 5 === 0) { $this->showBuzz($output); } else { $this->showNumber($output, $i); } } } }
/** * @return int */ protected function listAttendants() { $attendants = array_map(function (CacheAttendantInterface $a) { return ClassInfo::getClassNameByInstance($a); }, $this->getCacheAttendants([], true)); $header = ['Cache Registrar Name', 'Enabled', 'Initialized']; if ($this->output->isVerbose()) { $header = array_merge($header, ['TTL', 'Key Prefix', 'Hash Algo', 'Item Count']); } $rows = []; foreach ($attendants as $i => $name) { $instance = $this->getCacheAttendants([$name])[0]; $rows[$i] = [$name, $instance->isEnabled() ? 'Yes' : '<fg=white>No</>', $instance->isInitialized() ? 'Yes' : '<fg=white>No</>']; if (!$this->output->isVerbose()) { continue; } $ttl = $this->getAttendantTtl($instance); $gen = $this->getAttendantKeyGenerator($instance); try { $num = count($instance->listKeys()); } catch (\Exception $e) { $num = '<fg=white>n/a</>'; } $rows[$i] = array_merge($rows[$i], [$ttl === 0 ? '<fg=white>0</>' : $ttl, $gen->getPrefix(), $gen->getAlgorithm(), $num]); } $this->io->section('Cache Registry Attendant Listing'); $this->io->table($header, $rows); return 0; }
/** * Runs local command. * * @param string $commandLine * @param OutputInterface|null $output * @param null|string $cwd The working directory * * @return string */ public function run($commandLine, OutputInterface $output = null, $cwd = null) { $previousCwd = getcwd(); if ($cwd) { chdir($cwd); !$this->logger ?: $this->logger->debug(sprintf('Changed CWD to %s', $cwd)); } !$this->logger ?: $this->logger->debug($commandLine); ob_start(); passthru($commandLine, $returnStatus); if ($output instanceof OutputInterface) { if ($returnStatus != 0) { // execute with error $output->writeln('<error>' . trim(ob_get_contents()) . '</error>'); } elseif ($output->isVerbose()) { $output->writeln(ob_get_contents(), OutputInterface::OUTPUT_RAW); } } elseif ($returnStatus != 0) { // execute with error if (!$this->logger) { throw new \RuntimeException(trim(ob_get_contents())); } else { $this->logger->debug(trim(ob_get_contents())); } } $this->lastReturnStatus = $returnStatus; !$previousCwd ?: chdir($previousCwd); return ob_get_clean(); }
protected function execute(InputInterface $input, OutputInterface $output) { $every = $this->validateDuration($input->getOption('every')); $needle = $input->getOption('search'); $timeout = $this->validateDuration($input->getOption('timeout')); $urls = $this->validateURLs($input->getOption('urls')); if (!$needle) { throw new InvalidArgumentException('Needle must be provided'); } $cycle = new MonitorCycle($urls, $timeout, $needle); while (true) { $last = new DateTimeImmutable(); $output->writeln(sprintf('<bg=green>%s</>', $last->format('Y-m-d H:i:s'))); list($success, $failed) = $cycle->run(); if ($output->isVerbose() && count($failed) > 0) { $output->writeln(sprintf('<fg=red>Failed URLs:</> %s', implode("\n ", $failed))); } $output->writeln(sprintf('<fg=green>%d</> successful; <fg=red>%d</> failed', count($success), count($failed))); $output->writeln(''); $next = $last->add(new DateInterval("PT{$every}S")); do { sleep(1); } while (new DateTimeImmutable() < $next); } }
protected function execute(InputInterface $input, OutputInterface $output) { $start = new \DateTime(); if ($input->getOption("discard-results")) { $this->_em = new FakeEntityManager(); } $tests = $this->testRepo->findTests($input->getOption("test")); if (empty($tests)) { throw new \InvalidArgumentException("Could not find any tests to run."); } $output->writeln($this->getApplication()->getLongVersion() . ", running <info>" . count($tests) . "</info> tests"); foreach ($tests as $test) { $result = $this->expectations->run($test); $this->results[$result->getStatus()]++; //Don't output if we're not running verbosely and the test passes. if ($result->getStatus() !== ResultStatus::PASSED || $output->isVerbose()) { $output->writeln(" > " . $test->getName() . " : " . $this->getColouredStatus($result->getStatus()) . " - " . $result->getInfo()); } $this->_em->persist($result); } $output->writeln($this->getSummary($start)); $this->_em->flush(); //Exit with status code equal to the number of tests that didn't pass return count($tests) - $this->results[ResultStatus::PASSED]; }
protected function execute(InputInterface $input, OutputInterface $output) { \Jelix\Core\AppManager::open(); if ($output->isVerbose()) { $output->writeln("Application is opened."); } }
protected function execute(InputInterface $input, OutputInterface $output) { $sugarEP = $this->getService('sugarcrm.entrypoint'); $output->writeln('<comment>Reparation</comment>: '); $progress = new ProgressIndicator($output); $progress->start('Starting...'); $progress->advance(); $sugarSystem = new SugarSystem($sugarEP); $progress->setMessage('Working...'); $messages = $sugarSystem->repairAll($input->getOption('force')); $progress->finish('<info>Repair Done.</info>'); if ($output->isVerbose()) { $output->writeln(PHP_EOL . '<comment>General Messages</comment>: '); $output->writeln($messages[0]); } if ($input->getOption('no-database') === true) { return; } $output->writeln(PHP_EOL . '<comment>Database Messages</comment>: '); // We have something to sync if (strpos($messages[1], 'Database tables are synced with vardefs') !== 0) { if ($input->getOption('force') === false) { $output->writeln($messages[1]); $output->writeln(PHP_EOL . '<error>You need to use --force to run the queries</error>'); } else { $output->writeln('<info>Queries run, try another repair to verify</info>'); } // Nothing to sync, default sugar message } else { $output->writeln($messages[1]); } }
protected function _execute(InputInterface $input, OutputInterface $output) { $group = $input->getArgument('group'); $labelkey = $input->getArgument('labelkey'); $label = $input->getArgument('label'); $cnx = \jDb::getConnection('jacl2_profile'); $sql = "SELECT id_aclsbjgrp FROM " . $cnx->prefixTable('jacl2_subject_group') . " WHERE id_aclsbjgrp=" . $cnx->quote($group); $rs = $cnx->query($sql); if ($rs->fetch()) { throw new \Exception("This subject group already exists"); } $sql = "INSERT into " . $cnx->prefixTable('jacl2_subject_group') . " (id_aclsbjgrp, label_key) VALUES ("; $sql .= $cnx->quote($group) . ','; $sql .= $cnx->quote($labelkey); $sql .= ')'; $cnx->exec($sql); if ($this->verbose()) { $ouput->writeln("Rights: group of subjects '" . $group . "' is created"); } if ($label && preg_match("/^([a-zA-Z0-9_\\.]+)~([a-zA-Z0-9_]+)\\.([a-zA-Z0-9_\\.]+)\$/", $labelkey, $m)) { $localestring = "\n" . $m[3] . '=' . $label; $path = $this->getModulePath($m[1]); $file = $path . 'locales/' . \jApp::config()->locale . '/' . $m[2] . '.' . \jApp::config()->charset . '.properties'; if (file_exists($file)) { $localestring = file_get_contents($file) . $localestring; } file_put_contents($file, $localestring); if ($output->isVerbose()) { $output->writeln("locale string " . $m[3] . " is created into " . $file); } } }
protected function execute(InputInterface $input, OutputInterface $output) { \Jelix\Core\AppManager::close($input->getArgument('message')); if ($output->isVerbose()) { $output->writeln("Application is closed."); } }
/** * {@inheritdoc} */ protected function initialize(InputInterface $input, OutputInterface $output) { $this->io = new SymfonyStyle($input, $output); $this->process = new ProgressIndicator($output); $this->verbose = $output->isVerbose(); $this->output = $output; }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $this->ensureExtensionLoaded('apc'); $file = $input->getOption('file'); $noVerification = $input->getOption('no-verification'); if (!$file) { $file = 'php://stdin'; } else { if (!is_file($file) || !is_readable($file)) { throw new \InvalidArgumentException(sprintf("Could not read from file: %s", $file)); } } $dump = file_get_contents($file); $flags = 0; if (!$noVerification) { $flags = APC_BIN_VERIFY_MD5 | APC_BIN_VERIFY_CRC32; } $success = $this->getCacheTool()->apc_bin_load($dump, $flags); if ($output->isVerbose()) { if ($success) { $output->writeln("<comment>Load was successful</comment>"); } else { $output->writeln("<comment>Load was unsuccessful</comment>"); } } return $success ? 0 : 1; }
protected function _execute(InputInterface $input, OutputInterface $output) { $cnx = \jDb::getConnection('jacl2_profile'); $group = $cnx->quote($this->_getGrpId($input)); $subject = $cnx->quote($input->getArgument('subject')); $resource = $cnx->quote($input->getArgument('resource')); $sql = "SELECT * FROM " . $cnx->prefixTable('jacl2_rights') . "\n WHERE id_aclgrp=" . $group . "\n AND id_aclsbj=" . $subject . "\n AND id_aclres=" . $resource; $rs = $cnx->query($sql); if ($rs->fetch()) { throw new \Exception("right already set"); } $sql = "SELECT * FROM " . $cnx->prefixTable('jacl2_subject') . " WHERE id_aclsbj=" . $subject; $rs = $cnx->query($sql); if (!($sbj = $rs->fetch())) { throw new \Exception("subject is unknown"); } $sql = "INSERT into " . $cnx->prefixTable('jacl2_rights') . " (id_aclgrp, id_aclsbj, id_aclres) VALUES ("; $sql .= $group . ','; $sql .= $subject . ','; $sql .= $resource . ')'; $cnx->exec($sql); if ($output->isVerbose()) { $output->writeln("Right is added on subject {$subject} with group {$group} and resource {$resource}"); } }
public function run(InputInterface $input, OutputInterface $output) { $feed = $this->blogFeedConsumer->refreshFeed(); if ($output->isVerbose()) { $output->writeln(print_r($feed, true)); } }
protected function newEnv(OutputInterface $output, $name, $overwrite = false) { $name = strtolower($name); $file = $this->getRootDirectory() . 'config/env/' . $name . '.yml'; if (file_exists($file) && !$overwrite) { throw new FileException("{$file} already exists"); } $values = ['routing.root_url' => 'myapp.dev/', 'database.main.driver' => 'pdo_mysql', 'database.main.dbname' => 'sandbox', 'database.main.user' => 'root', 'database.main.pass' => '', 'database.main.logger' => 'logger']; $config = new Config(); foreach ($values as $key => $value) { $config->set($key, $value); if (!$output->isVerbose()) { continue; } if (is_string($value) && !empty($value)) { $msg = sprintf("Config: Setting <info>%s</info> to <info>%s</info>", $key, $value); } else { $msg = sprintf("Config: Setting <info>%s</info>", $key); } $output->writeln($msg); } $yaml = Yaml::dump($config->get(), 100, 2); file_put_contents($file, $yaml); $output->writeln("Created <info>{$file}</info>"); }
/** * Runs the command. * * @param InputInterface $input * @param OutputInterface $output * @return int */ protected function execute(InputInterface $input, OutputInterface $output) { // load modResource dependency $this->modx->loadClass('modResource'); $partitions = $input->getArgument('partitions'); if (!$partitions || empty($partitions)) { $partitions = array_keys($this->config['data']); } foreach ($this->config['data'] as $folder => $options) { if (!in_array($folder, $partitions, true)) { if ($output->isVerbose()) { $output->writeln('Skipping ' . $folder); } continue; } $options['folder'] = $folder; switch (true) { case !empty($options['type']) && $options['type'] == 'content': // "content" is a shorthand for contexts + resources $this->extractContent(GITIFY_WORKING_DIR . $this->config['data_directory'] . $folder, $options); break; case !empty($options['class']): if (isset($options['package'])) { $this->getPackage($options['package'], $options); } $this->extractObjects(GITIFY_WORKING_DIR . $this->config['data_directory'] . $folder, $options); break; } } $output->writeln('Done! ' . $this->getRunStats()); return 0; }
protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln('Sending pending notification and response emails to enabled users'); $this->notificationService->setOutput($output->isVerbose() ? $output : NULL); $this->notificationService->setDryRun($input->getOption('dry-run')); $em = $this->doctrine->getManager(); /**@var NotificationRepository $notificationRepository*/ $notificationRepository = $em->getRepository('AppBundle:Notification'); //Send all pending notification $notifications = $notificationRepository->findBy(['status' => 'pending', 'emailed' => NULL]); if (!empty($notifications)) { $output->writeln('Sending new notifications'); $this->sendEmails($notifications, $output); } //Send all reminders $date = new \DateTime(); $date->sub(new \DateInterval($this->notificationPendingTimeout)); $notifications = $notificationRepository->findReminders($date); if (!empty($notifications)) { $output->writeln('Sending reminders'); $this->sendEmails($notifications, $output); } //Send all response $notifications = $notificationRepository->findResponses(); if (!empty($notifications)) { $output->writeln('Sending responses'); $this->sendEmails($notifications, $output); } }
/** * @param InputInterface $input * @param OutputInterface|Output $output * @return int|null|void */ protected function execute(InputInterface $input, OutputInterface $output) { $poll = $this->getContainer()->get('sonata.admin.pool'); $translator = $this->getContainer()->get('translator'); $manager = $this->getContainer()->get('doctrine.orm.entity_manager'); $repository = $manager->getRepository('OctavaAdminMenuBundle:AdminMenu'); $translation = $this->getContainer()->get('doctrine.orm.entity_manager')->getRepository('GedmoTranslatable:Translation'); foreach ($poll->getAdminGroups() as $name => $group) { $title = $translator->trans($group['label'], [], $group['label_catalogue']); $parent = $repository->findOneBy(['title' => $title, 'type' => AdminMenu::TYPE_FOLDER]); if ($output->isVerbose()) { $output->writeln(sprintf('Folder "%s"', $title)); } if (!$parent) { $parent = new AdminMenu(); $parent->setTitle($title); $parent->setType(AdminMenu::TYPE_FOLDER); if ($output->isVerbose()) { $output->writeln(sprintf('Generate "%s" folder', $title)); } $translation->translate($parent, 'title', 'en', $title); } $manager->persist($parent); foreach ($group['items'] as $item) { if ($output->isVerbose()) { $output->writeln(sprintf('Module "%s"', $item['admin'])); } $serviceId = $item['admin']; $title = $translator->trans($item['label'], [], $group['label_catalogue']); $menu = $repository->findOneBy(['serviceId' => $serviceId]); if (!$menu) { $menu = new AdminMenu(); $menu->setTitle($title); $menu->setType(AdminMenu::TYPE_MODULE); $menu->setServiceId($serviceId); $menu->setParent($parent); $translation->translate($menu, 'title', 'en', $title); $manager->persist($menu); if ($output->isVerbose()) { $output->writeln(sprintf('Generate "%s" item', $title)); } } } } $manager->flush(); }
/** * @param InputInterface $input * @param OutputInterface|Output $output * @return void */ protected function execute(InputInterface $input, OutputInterface $output) { $helper = $this->getContainer()->get('octava_mui.translation_manager'); $helper->clearCache(); if ($output->isVerbose()) { $output->writeln("<info>Translation clear cache completed</info>"); } }
private function getConfig() { $configPath = $this->input->getArgument(self::ARG_CONFIG); if ($this->output->isVerbose()) { $this->output->writeLn('Reading config file: ' . $configPath); } $this->config = $this->yaml->parse($this->filesystem->get($configPath)); }