Example #1
1
 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 initialize(InputInterface $input, OutputInterface $output)
 {
     // Validate we can run.
     if ($this->platformConfig === null) {
         $output->writeln('<error>Must run command within a Platform.sh project</error>');
         exit(1);
     }
     $this->projectPath = LocalProject::getProjectRoot();
     $this->projectName = Platform::projectName();
     $this->stdOut = $output;
     $this->stdErr = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
     $this->stdIn = $input;
     self::$interactive = $input->isInteractive();
 }
Example #3
0
 protected function notifyFile(SourceFileInfo $file)
 {
     $output = $this->output instanceof ConsoleOutputInterface ? $this->output->getErrorOutput() : $this->output;
     if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
         $output->writeln("<info>Scanning {$file->getRelativePathname()}</info>");
     }
 }
 /**
  * @return OutputInterface
  */
 private function getErrorOutput()
 {
     if ($this->output instanceof ConsoleOutputInterface) {
         return $this->output->getErrorOutput();
     }
     return $this->output;
 }
 /**
  *
  * {@inheritdoc}
  *
  */
 public function log($level, $message, array $context = array())
 {
     if (!isset($this->verbosityLevelMap[$level])) {
         throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level));
     }
     // Write to the error output if necessary and available
     if ($this->formatLevelMap[$level] === self::ERROR && $this->output instanceof ConsoleOutputInterface) {
         $output = $this->output->getErrorOutput();
     } else {
         $output = $this->output;
     }
     if ($output->getVerbosity() >= $this->verbosityLevelMap[$level]) {
         $output->writeln(sprintf('<%1$s>[%2$s] %3$s</%1$s>', $this->formatLevelMap[$level], $level, $this->interpolate($message, $context)));
     }
 }
 /**
  * @param int $count
  * @param int $minVerbosity
  *
  * @return ProgressBar
  */
 public function createProgressBar($count, $minVerbosity = OutputInterface::VERBOSITY_NORMAL)
 {
     $stream = new NullOutput();
     if ($this->applicationInput->hasOption('progress') && $this->applicationInput->getOption('progress')) {
         if ($this->applicationOutput instanceof ConsoleOutput) {
             if ($this->applicationOutput->getVerbosity() >= $minVerbosity) {
                 $stream = $this->applicationOutput->getErrorOutput();
             }
         }
     }
     $progress = new ProgressBar($stream, $count);
     // add an additional space, in case logging is also enabled
     $progress->setFormat($progress->getFormatDefinition('normal') . ' ');
     $progress->start();
     return $progress;
 }
 /**
  * @inheritdoc
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     $this->stdOut = $output;
     $this->stdErr = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
     $this->stdIn = $input;
     self::$interactive = $input->isInteractive();
 }
Example #8
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $error = $output->getErrorOutput();
     $path = $input->getArgument("path");
     $includeRoot = $input->getOption("include-root");
     if (!\file_exists($path)) {
         throw new \Exception("File {$path} doesn't exist");
     }
     try {
         list($inform, $format) = \detectCertFormat($path);
         $cert = \parseFormattedCert(\readCertificate($path, $inform, $format));
     } catch (\Exception $e) {
         $err = implode("\n", $e->output);
         throw new \Exception("Unable to load certificate: {$err}");
     }
     // perform some basic checks
     if (\isExpired($cert)) {
         $error->writeln("Certificate has expired");
     }
     if (\areCertsLinked($cert, $cert)) {
         throw new \Exception("Self-signed or CA cert");
     }
     // this can fail with an exception
     $out = \buildChain($cert, $path, $includeRoot);
     $output->write($out);
 }
Example #9
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     # If possible log to stderr because stdout receives the dot file
     $logger = new SymfonyConsoleOutput($output instanceof ConsoleOutput ? $output->getErrorOutput() : $output);
     $project = new Project($logger);
     if ($input->getOption('quiet')) {
         $logger->setReportingLevel(Logger::ERROR);
     } else {
         if ($input->getOption('verbose')) {
             $logger->setReportingLevel(Logger::INFO);
         }
     }
     SourceHandler::addSourcesToProject($input, $project);
     # Necessary setup to generate the objectGraph
     $project->addAnalyzer(new Parser(new \PhpParser\Parser(new Lexer())));
     $project->addAnalyzer(new NameResolver());
     $project->addAnalyzer($objectGraph = new ObjectGraph());
     $project->analyze();
     $graphviz = new GraphvizConverter();
     $graphviz->setGraph($objectGraph);
     # Console configuration
     $graphviz->setNamespaceWhitelist($input->getOption('namespaces'));
     $graphviz->setShowNamespace($input->getOption('show-namespace'));
     $graphviz->setShowOnlyConnected($input->getOption('show-only-connected'));
     $graphviz->setClusterByNamespace($input->getOption('cluster-namespaces'));
     $graphviz->setNestClusters($input->getOption('nest-clusters'));
     $output->write($graphviz->generate());
 }
Example #10
0
 /**
  * @param array $messages
  * @param bool  $newline
  * @param bool  $stderr
  */
 private function doWrite($messages, $newline, $stderr)
 {
     if (true === $stderr && $this->output instanceof ConsoleOutputInterface) {
         $this->output->getErrorOutput()->write($messages, $newline);
         return;
     }
     $this->output->write($messages, $newline);
 }
 /**
  * {@inheritdoc}
  */
 protected function write(array $record)
 {
     if ($record['level'] >= Logger::ERROR && $this->output instanceof ConsoleOutputInterface) {
         $this->output->getErrorOutput()->write((string) $record['formatted']);
     } else {
         $this->output->write((string) $record['formatted']);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function getOutput($level = LogLevel::NOTICE)
 {
     $output = $this->output;
     if ($this->output instanceof ConsoleOutputInterface && in_array($level, array(LogLevel::EMERGENCY, LogLevel::ALERT, LogLevel::CRITICAL, LogLevel::ERROR))) {
         $output = $this->output->getErrorOutput();
     }
     return $output;
 }
Example #13
0
 private function error_log($errorString)
 {
     if ($this->output instanceof ConsoleOutputInterface) {
         $this->output->getErrorOutput()->writeln($errorString);
     } else {
         error_log($errorString);
     }
 }
Example #14
0
 /**
  * @inheritdoc
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     $this->stdOut = $output;
     $this->stdErr = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
     $this->stdIn = $input;
     self::$interactive = $input->isInteractive();
     // Check if this command requires a project to be defined in order to run.
     $this->checkProjectRequired();
 }
Example #15
0
    public function execute(InputInterface $input, OutputInterface $output)
    {
        $stderr = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
        include_once $input->getArgument('input');
        $config = array();
        // 1. One-to-one maps
        foreach ($this->option_map as $old => $new) {
            if (defined($old)) {
                $config[$new] = constant($old);
            }
        }
        // 2. Special processing
        if (defined('SIMPLEID_CLEAN_URL') && !constant('SIMPLEID_CLEAN_URL')) {
            $stderr->writeln('<error>SIMPLEID_CLEAN_URL is set to false. This is not supported by SimpleID 2.</error>');
        }
        if (defined('SIMPLEID_STORE') && constant('SIMPLEID_STORE') != 'filesystem') {
            $stderr->writeln('<error>Warning: Custom SIMPLEID_STORE.  This will need to be migrated manually.</error>');
        }
        if (defined('SIMPLEID_CACHE_DIR')) {
            $config['cache'] = 'folder=' . constant('SIMPLEID_CACHE_DIR');
        }
        if (defined('SIMPLEID_LOGLEVEL')) {
            $config['log_level'] = $this->log_level_map[constant('SIMPLEID_LOGLEVEL')];
        }
        // 3. Add required configuration
        $config = array_merge($config, $this->additional_config);
        // 4. Results.
        $results = <<<_END_HEADER_
<?php
#
# SimpleID configuration file.
#
# ** Generated by SimpleIDTool **
#
# ** Review this file against config.php.dist and make additional manual
# changes **
#
# By default, the SimpleID configuration is formatted as YAML.  However
# you can insert PHP code after the YAML section for further configuration.
#
{$config} = Spyc::YAMLLoadString(<<<_END_YAML_

_END_HEADER_;
        $results .= Spyc::YAMLDump($config, 4, false, true);
        $results .= <<<_END_FOOTER_
_END_YAML_
);

?>
_END_FOOTER_;
        if ($input->getArgument('output')) {
            file_put_contents($input->getArgument('output', $results));
        } else {
            $output->writeln($results);
        }
    }
Example #16
0
 /**
  * @inheritdoc
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     $this->stdOut = $output;
     $this->stdErr = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
     $this->stdIn = $input;
     self::$interactive = $input->isInteractive();
     if (empty(Config::get())) {
         $this->getApplication()->find('init')->run($input, $output);
         exit(1);
     }
 }
Example #17
0
 /**
  * Gets the output written to STDERR by the application.
  *
  * @param bool $normalize Whether to normalize end of lines to \n or not
  *
  * @return string
  */
 public function getErrorOutput($normalize = false)
 {
     if (!$this->captureStreamsIndependently) {
         throw new \LogicException('The error output is not available when the tester is run without "capture_stderr_separately" option set.');
     }
     rewind($this->output->getErrorOutput()->getStream());
     $display = stream_get_contents($this->output->getErrorOutput()->getStream());
     if ($normalize) {
         $display = str_replace(PHP_EOL, "\n", $display);
     }
     return $display;
 }
 /**
  * @param CerberePreActionEvent $event
  */
 public function onCerberePreAction(CerberePreActionEvent $event)
 {
     if ($max = count($event->getProjects())) {
         // Returns and jump new line.
         $this->output->getErrorOutput()->writeln('');
         $format = " Project: %project%\n";
         $format .= ProgressBar::getFormatDefinition('debug');
         $progress = new ProgressBar($this->output, $max);
         $progress->setFormat($format);
         $progress->setRedrawFrequency(1);
         $progress->setMessage('Action starts');
         $this->progress = $progress;
     }
 }
Example #19
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $error = $output->getErrorOutput();
     $dir = new \RecursiveDirectoryIterator($input->getArgument("directory"));
     $iter = new \RecursiveIteratorIterator($dir);
     $certs = new \RegexIterator($iter, '/^.+\\.(crt|pem)/i', \RecursiveRegexIterator::MATCH);
     foreach ($certs as $cert) {
         $regex = "/BEGIN CERTIFICATE/";
         $n = \preg_match_all($regex, \file_get_contents($cert->getPathname()), $matches);
         if ($n <= 1) {
             $output->writeln("likely no chain: {$cert}");
         }
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $hostname = file_get_contents("http://instance-data/latest/meta-data/hostname");
     if (!$hostname) {
         $output->getErrorOutput()->writeln("<error>Couldn't get machine hostname. This script should be run on ec2 instance.</error>");
         return 1;
     }
     if (isset($_ENV['KWF_CONFIG_SECTION'])) {
         file_put_contents('config_section', $_ENV['KWF_CONFIG_SECTION']);
     }
     if (!isset($_ENV['RDS_HOSTNAME'])) {
         $output->getErrorOutput()->writeln("<error>Couldn't get RDS_HOSTNAME, make sure you configured RDS correclty.</error>");
         return 1;
     }
     $config = "[production]\n        database.web.host = {$_ENV['RDS_HOSTNAME']}\n        database.web.port = {$_ENV['RDS_PORT']}\n        database.web.user = {$_ENV['RDS_USERNAME']}\n        database.web.password = {$_ENV['RDS_PASSWORD']}\n        database.web.name = {$_ENV['RDS_DB_NAME']}\n\n        server.baseUrl = \"\"\n        server.domain = {$hostname}\n        server.redirectToDomain = false\n        ";
     if (isset($_ENV['S3_UPLOADS_BUCKET'])) {
         $config .= "aws.uploadsBucket = {$_ENV['S3_UPLOADS_BUCKET']}\n";
     }
     if (isset($_ENV['ELASTICACHE_HOST'])) {
         $config .= "server.memcache.host = {$_ENV['ELASTICACHE_HOST']}\n";
     }
     $config .= "server.replaceVars.remoteAddr.if = 172.*\n        server.replaceVars.remoteAddr.replace = HTTP_X_FORWARDED_FOR\n        \n";
     file_put_contents('config.local.ini', $config);
 }
Example #21
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $curveName = $input->getOption('curve');
     if (!$curveName) {
         throw new \InvalidArgumentException('Curve name is required. Use "list-curves" to get available names.');
     }
     $generator = CurveFactory::getGeneratorByName($curveName);
     if ($output instanceof ConsoleOutputInterface) {
         $output->getErrorOutput()->writeln('Using curve "' . $curveName . "'");
     }
     $privKeySerializer = $this->getPrivateKeySerializer($input, 'out');
     $pubKeySerializer = $this->getPublicKeySerializer($input, 'out');
     $privKey = $generator->createPrivateKey();
     $output->writeln($privKeySerializer->serialize($privKey));
     $pubKey = $privKey->getPublicKey();
     $output->writeln($pubKeySerializer->serialize($pubKey));
 }
Example #22
0
 /**
  * {@inheritdoc}
  */
 protected function write(array $record)
 {
     $formatted = (string) $record['formatted'];
     $formatted = str_replace('[COMMON]', '', $formatted);
     $formatted = str_replace('[Main][SUCCESS] ', '[Main]', $formatted);
     $formatted = str_replace('[] []', '', $formatted);
     $formatted = trim($formatted) . "\n";
     if (!$this->logged && $this->isHandling($record)) {
         $this->output->writeln("");
     }
     if ($record['level'] >= Logger::ERROR && $this->output instanceof ConsoleOutputInterface) {
         $this->output->getErrorOutput()->write($formatted);
     } else {
         $this->output->write($formatted);
     }
     $this->logged = true;
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $lrPadding = $input->getOption('lr');
     $tbPadding = $input->getOption('tb');
     if ($input->getOption('stdin')) {
         $text = '';
         while ($line = fgets(STDIN)) {
             $text .= $line;
         }
     } else {
         $text = $input->getOption('text');
     }
     if (empty($text)) {
         $output->getErrorOutput()->writeln('<error>Convert text cannot be empty</error>');
         return;
     }
     $map = array(0 => '<whitec>  </whitec>', 1 => '<blackc>  </blackc>');
     $this->initStyle($output);
     $text = QRcode::text($text);
     $length = strlen($text[0]);
     $screenSize = $this->getTTYSize();
     if (!$screenSize) {
         $output->getErrorOutput()->writeln('<comment>Get Screen Size Failed</comment>');
     } else {
         list($maxLines, $maxCols) = $screenSize;
         $qrCols = 2 * ($length + $lrPadding * 2);
         $qrLines = count($text) + $tbPadding * 2;
         if ($qrCols > $maxCols || $qrLines > $maxLines) {
             $output->getErrorOutput()->writeln('<error>Max Lines/Columns Reached</error>');
             return;
         }
     }
     $paddingLine = str_repeat($map[0], $length + $lrPadding * 2) . "\n";
     $after = $before = str_repeat($paddingLine, $tbPadding);
     $output->write($before);
     foreach ($text as $line) {
         $output->write(str_repeat($map[0], $lrPadding));
         for ($i = 0; $i < $length; $i++) {
             $type = substr($line, $i, 1);
             $output->write($map[$type]);
         }
         $output->writeln(str_repeat($map[0], $lrPadding));
     }
     $output->write($after);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $errOutput = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
     $action = new RegisterUserAction();
     $action->setUsername($input->getOption('username'));
     $action->setDisplayName($input->getOption('display-name'));
     $action->setEmail($input->getOption('email'));
     $action->setPassword($input->getOption('password'));
     $validator = $this->getContainer()->get('validator');
     $violations = $validator->validate($action);
     if (count($violations) > 0) {
         $errOutput->writeln('<comment>There are some errors:</comment>');
         foreach ($violations as $violation) {
             $errOutput->writeln(sprintf('  - %s: <error>%s</error>', $violation->getPropertyPath(), $violation->getMessage()));
         }
         return 1;
     }
     $user = $this->getContainer()->get('openl10n.processor.register_user')->execute($action);
     $output->writeln(sprintf('<info>User <comment>%s</comment> created</info>', $user->getUsername()));
 }
 protected function execute(InputInterface $input, OutputInterface $stdout)
 {
     // capture error output
     $stderr = $stdout instanceof ConsoleOutputInterface ? $stdout->getErrorOutput() : $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('');
     // establish a temporary status file
     $cache = sys_get_temp_dir() . '/assetic_watch_' . substr(sha1($this->basePath), 0, 7);
     if ($input->getOption('force') || !file_exists($cache)) {
         $previously = array();
     } else {
         $previously = unserialize(file_get_contents($cache));
         if (!is_array($previously)) {
             $previously = array();
         }
     }
     $error = '';
     while (true) {
         try {
             foreach ($this->am->getNames() as $name) {
                 if ($this->checkAsset($name, $previously)) {
                     $this->dumpAsset($name, $stdout);
                 }
             }
             // reset the asset manager
             $this->am->clear();
             $this->am->load();
             file_put_contents($cache, serialize($previously));
             $error = '';
         } catch (\Exception $e) {
             if ($error != ($msg = $e->getMessage())) {
                 $stderr->writeln('<error>[error]</error> ' . $msg);
                 $error = $msg;
             }
         }
         clearstatcache();
         sleep($input->getOption('period'));
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $errOutput = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
     $stream = $this->getEventStream();
     $eventImporter = $this->getEventImporter();
     /** @var DomainEventStream $eventStream */
     foreach ($stream() as $eventStream) {
         /** @var DomainMessage $message */
         foreach ($eventStream->getIterator() as $message) {
             if ($message->getType() !== 'CultuurNet.UDB3.Event.Events.EventImportedFromUDB2') {
                 continue;
             }
             $output->writeln($message->getRecordedOn()->toString() . ' ' . $message->getType() . ' (' . $message->getId() . ')');
             try {
                 $eventImporter->updateEventFromUDB2($message->getId());
             } catch (EventNotFoundException $e) {
                 $errOutput->writeln("<error>{$e->getMessage()} The event probably has been removed from UDB2.</error>");
             }
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     ////
     // CONFIGURATION
     ////
     if ($file = realpath($input->getOption('config'))) {
         chdir(dirname($file));
     } else {
         throw new \Exception(sprintf("Could not find configuration file at '%s'", $file));
     }
     $processor = new Processor();
     $raw_config = json_decode(file_get_contents($file), true);
     $this->config = $processor->processConfiguration(new Configuration(), array($raw_config));
     ////
     // SYSTEM
     ////
     date_default_timezone_set($this->config['timezone']);
     ////
     // LOGGER
     ////
     $level = false;
     if ($input->getOption('verbose')) {
         $level = Logger::DEBUG;
     }
     $this->logger = new Logger('phorever');
     if ($input->hasOption('daemon') && $input->getOption('daemon')) {
         if (!file_exists($this->config['logging']['directory'])) {
             if (!mkdir($this->config['logging']['directory'], 0777, true)) {
                 throw new \Exception("Unable to create logging directory");
             }
         }
         $this->logger->pushHandler($handler = new StreamHandler($this->config['logging']['directory'] . 'phorever.log', $level ?: Logger::INFO));
         $handler->setFormatter(new FileFormatter());
     } else {
         $this->logger->pushHandler($stdoutHandler = new ConsoleHandler($output, $level ?: Logger::INFO));
         $this->logger->pushHandler($stderrHandler = new ConsoleHandler($output->getErrorOutput(), Logger::ERROR, false));
         $stderrHandler->setFormatter(new ConsoleFormatter());
         $stdoutHandler->setFormatter(new ConsoleFormatter());
     }
 }
 /**
  * @param OutputInterface $output
  *
  * @return int
  */
 protected function listBackups(OutputInterface $output)
 {
     $environment = $this->getSelectedEnvironment();
     $stdErr = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
     $stdErr->writeln("Finding backups for the environment <info>{$environment['id']}</info>");
     $results = $environment->getActivities(10, 'environment.backup');
     if (!$results) {
         $stdErr->writeln('No backups found');
         return 1;
     }
     $headers = array("Created", "% Complete", "Backup name");
     $rows = array();
     foreach ($results as $result) {
         $payload = $result->getProperty('payload');
         $backup_name = !empty($payload['backup_name']) ? $payload['backup_name'] : 'N/A';
         $rows[] = array(date('Y-m-d H:i:s', strtotime($result->getProperty('created_at'))), $result->getCompletionPercent(), $backup_name);
     }
     $table = new Table($output);
     $table->setHeaders($headers);
     $table->setRows($rows);
     $table->render();
     return 0;
 }
Example #29
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $error = $output->getErrorOutput();
     $fmt = $this->getHelper("formatter");
     $dir = new \RecursiveDirectoryIterator($input->getArgument("directory"));
     $iter = new \RecursiveIteratorIterator($dir);
     if ($input->getOption("expiry")) {
         $expiry = strtotime($input->getOption("expiry"));
         if ($expiry === false) {
             $expiry = time();
             $error->writeln("Invalid expiry arg, defaulting to now");
         }
     } else {
         $expiry = time();
     }
     $certs = new \RegexIterator($iter, '/^.+\\.(crt|pem)/i', \RecursiveRegexIterator::MATCH);
     foreach ($certs as $path) {
         try {
             $expirationDate = "";
             $inform = "";
             $format = "";
             list($inform, $format) = \detectCertFormat($path);
             $cert = \parseFormattedCert(\readCertificate($path, $inform, $format));
             if (isExpired($cert, $expiry)) {
                 $expirationDate = \date('Y-m-d H:i:s e', $cert["expires"]);
                 $output->writeln("Certificate {$path} expires on {$expirationDate}");
             }
         } catch (\Exception $e) {
             $msgs = ["Unable to load {$path}"];
             if ($output->isVerbose()) {
                 $msgs = array_merge($msgs, ["", "{$e->cmd} said:", ""], $e->output);
             }
             $block = $fmt->formatBlock($msgs, 'error', true);
             $error->writeln($block);
         }
     }
 }
Example #30
0
 protected function execute(InputInterface $input, OutputInterface $stdout)
 {
     // capture error output
     $stderr = $stdout instanceof ConsoleOutputInterface ? $stdout->getErrorOutput() : $stdout;
     // print the header
     $stdout->writeln(sprintf('Dumping all assets.'));
     $stdout->writeln(sprintf('Debug mode is <comment>%s</comment>.', $this->debug ? 'on' : 'off'));
     $stdout->writeln('');
     if ($this->am instanceof LazyAssetManager) {
         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);
             }
         }
     } else {
         $this->aw->writeManagerAssets($this->am);
     }
 }