/**
  * {inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->setApi(new \AdministrationApi());
     $args = array();
     if ($modules = $input->getOption('modules')) {
         $args['module_list'] = $modules;
     }
     if ($searchOnly = $input->getOption('searchOnly')) {
         $args['search_only'] = true;
     }
     if ($byBoost = $input->getOption('byBoost')) {
         $args['order_by_boost'] = true;
     }
     $result = $this->callApi('searchFields', $args);
     // handle output which is different when ordered by boost
     $table = new Table($output);
     if ($byBoost) {
         $table->setHeaders(array('Module', 'Field', 'Boost'));
         foreach ($result as $raw => $boost) {
             $raw = explode('.', $raw);
             $table->addRow([$raw[0], $raw[1], $boost]);
         }
     } else {
         $table->setHeaders(array('Module', 'Field', 'Type', 'Searchable', 'Boost'));
         foreach ($result as $module => $fields) {
             foreach ($fields as $field => $props) {
                 $searchAble = !empty($props['searchable']) ? 'yes' : 'no';
                 $boost = isset($props['boost']) ? $props['boost'] : 'n/a';
                 $table->addRow([$module, $field, $props['type'], $searchAble, $boost]);
             }
         }
     }
     $table->render();
 }
Example #2
0
 public function render()
 {
     if (null !== $this->label) {
         $this->output->writeln(sprintf('<comment>%s</comment>', $this->label));
     }
     $this->table->setHeaders($this->headers)->setRows($this->rows)->render();
 }
Example #3
0
 protected function _execute(InputInterface $input, OutputInterface $output)
 {
     $cnx = \jDb::getConnection('jacl2_profile');
     $table = new Table($output);
     $groupFiler = false;
     if ($input->getArgument('group')) {
         $id = $this->_getGrpId($input, true);
         $sql = "SELECT login FROM " . $cnx->prefixTable('jacl2_user_group') . " WHERE id_aclgrp =" . $cnx->quote($id);
         $table->setHeaders(array('Login'));
         $groupFiler = true;
     } else {
         $sql = "SELECT login, g.id_aclgrp, name FROM " . $cnx->prefixTable('jacl2_user_group') . " AS u " . " LEFT JOIN " . $cnx->prefixTable('jacl2_group') . " AS g\n                ON (u.id_aclgrp = g.id_aclgrp AND g.grouptype < 2)\n                ORDER BY login";
         $table->setHeaders(array('Login', 'group', 'group id'));
     }
     $cnx = \jDb::getConnection('jacl2_profile');
     $rs = $cnx->query($sql);
     foreach ($rs as $rec) {
         if ($groupFiler) {
             $table->addRow(array($rec->login));
         } else {
             $table->addRow(array($rec->login, $rec->name, $rec->id_aclgrp));
         }
     }
     $table->render();
 }
Example #4
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $table = new Table($output);
     $table->setStyle('compact');
     $environment = $input->getArgument('environment');
     if (in_array($environment, array('dev', 'prod'))) {
         $loadedConfigurations = $this->loadConfigurations($environment);
     } else {
         $output->writeln(' <error>' . $this->trans('commands.site.mode.messages.invalid-env') . '</error>');
     }
     $configurationOverrideResult = $this->overrideConfigurations($loadedConfigurations['configurations']);
     foreach ($configurationOverrideResult as $configName => $result) {
         $output->writeln(sprintf(' <info>%s:</info> <comment>%s</comment>', $this->trans('commands.site.mode.messages.configuration'), $configName));
         $table->setHeaders([$this->trans('commands.site.mode.messages.configuration-key'), $this->trans('commands.site.mode.messages.original'), $this->trans('commands.site.mode.messages.updated')]);
         $table->setRows($result);
         $table->render();
         $output->writeln('');
     }
     $servicesOverrideResult = $this->overrideServices($loadedConfigurations['services'], $output);
     if (!empty($servicesOverrideResult)) {
         $output->writeln(' <info>' . $this->trans('commands.site.mode.messages.new-services-settings') . '</info>');
         $table->setHeaders([$this->trans('commands.site.mode.messages.service'), $this->trans('commands.site.mode.messages.service-parameter'), $this->trans('commands.site.mode.messages.service-value')]);
         $table->setStyle('compact');
         $table->setRows($servicesOverrideResult);
         $table->render();
     }
     $this->getChain()->addCommand('cache:rebuild', ['cache' => 'all']);
 }
Example #5
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $enabledOnly = $input->getOption('enabledOnly');
     $list = $this->apiKeyService->listKeys($enabledOnly);
     $table = new Table($output);
     if ($enabledOnly) {
         $table->setHeaders([$this->translator->translate('Key'), $this->translator->translate('Expiration date')]);
     } else {
         $table->setHeaders([$this->translator->translate('Key'), $this->translator->translate('Is enabled'), $this->translator->translate('Expiration date')]);
     }
     /** @var ApiKey $row */
     foreach ($list as $row) {
         $key = $row->getKey();
         $expiration = $row->getExpirationDate();
         $rowData = [];
         $formatMethod = !$row->isEnabled() ? 'getErrorString' : ($row->isExpired() ? 'getWarningString' : 'getSuccessString');
         if ($enabledOnly) {
             $rowData[] = $this->{$formatMethod}($key);
         } else {
             $rowData[] = $this->{$formatMethod}($key);
             $rowData[] = $this->{$formatMethod}($this->getEnabledSymbol($row));
         }
         $rowData[] = isset($expiration) ? $expiration->format(\DateTime::ISO8601) : '-';
         $table->addRow($rowData);
     }
     $table->render();
 }
 protected function test($count, $classes, OutputInterface $output)
 {
     $this->table = new Table($output);
     $this->table->setHeaders(array('Implementation', 'Memory', 'Duration'));
     $output->writeln(sprintf('<info>%d elements</info>', $count));
     $this->process = new ProgressBar($output, count($classes));
     $this->process->start();
     foreach ($classes as $class) {
         $shortClass = $class;
         //            if (in_array($class, $blacklist)) {
         //                $this->table->addRow([$class, '--', '--']);
         //                continue;
         //            };
         $path = __DIR__ . '/../../bin/test.php';
         $result = `php {$path} {$class} {$count}`;
         $data = json_decode($result, true);
         if (!$data) {
             echo $result;
         }
         $this->table->addRow([$shortClass, sprintf('%11sb', number_format($data['memory'])), sprintf('%6.4fs', $data['time'])]);
         $this->process->advance();
     }
     $this->process->finish();
     $output->writeln('');
     $this->table->render($output);
 }
Example #7
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->table->setHeaders(['id', 'Title', 'Description']);
     foreach ($this->repository->getAll() as $exercise) {
         $this->table->addRow([$exercise->getId(), $exercise->getTitle(), $exercise->getDescription()]);
     }
     $this->table->render();
 }
Example #8
0
 /**
  * @param Reciever[] $recievers
  */
 public function printRecievers(array $recievers)
 {
     $this->table->setHeaders(['name', 'email']);
     $rows = [];
     foreach ($recievers as $reciever) {
         $rows[] = [$reciever->getFullName(), $reciever->getEmail()];
     }
     $this->table->setRows($rows);
     $this->table->render();
     $this->table->setRows([]);
 }
 /**
  * Draw console table
  *
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @param array                                             $content
  */
 protected function table(OutputInterface $output, array $content)
 {
     // write config table
     $table = new Table($output);
     if (count($content) > 0) {
         // multiple tables
         foreach ($content as $header => $rows) {
             $output->writeln(sprintf($this->tableHeader, $header));
             $table->setHeaders(array_keys($rows))->setRows([$rows])->render();
         }
     } else {
         $table->setHeaders(array_keys($content))->setRows(array_values($content));
         $table->render();
     }
 }
Example #10
0
 protected function checkRequirements()
 {
     $this->defaultOutput->writeln('<info><comment>Step 1 of 5.</comment> Checking system requirements.</info>');
     $fulfilled = true;
     $label = '<comment>PDO Driver</comment>';
     $status = '<info>OK!</info>';
     $help = '';
     if (!extension_loaded($this->getContainer()->getParameter('database_driver'))) {
         $fulfilled = false;
         $status = '<error>ERROR!</error>';
         $help = 'Database driver "' . $this->getContainer()->getParameter('database_driver') . '" is not installed.';
     }
     $rows = [];
     $rows[] = [$label, $status, $help];
     foreach ($this->functionExists as $functionRequired) {
         $label = '<comment>' . $functionRequired . '</comment>';
         $status = '<info>OK!</info>';
         $help = '';
         if (!function_exists($functionRequired)) {
             $fulfilled = false;
             $status = '<error>ERROR!</error>';
             $help = 'You need the ' . $functionRequired . ' function activated';
         }
         $rows[] = [$label, $status, $help];
     }
     $table = new Table($this->defaultOutput);
     $table->setHeaders(['Checked', 'Status', 'Recommendation'])->setRows($rows)->render();
     if (!$fulfilled) {
         throw new \RuntimeException('Some system requirements are not fulfilled. Please check output messages and fix them.');
     }
     $this->defaultOutput->writeln('<info>Success! Your system can run Wallabag properly.</info>');
     $this->defaultOutput->writeln('');
     return $this;
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $memcachedAddress = $input->getOption('address');
     $memcachedPort = $input->getOption('port');
     $memcachedHelper = new MemcachedHelper($memcachedAddress, $memcachedPort);
     if ($input->getOption('count')) {
         $keysCount = $memcachedHelper->getKeysCount();
         $output->writeln("<info>Number of the keys in storage: {$keysCount}</info>");
         return;
     }
     $keys = $input->getArgument('key');
     $compactMode = !empty($keys) && count($keys) <= 3 ? true : false;
     $keysNumber = $input->getOption('number');
     $mcData = $memcachedHelper->getMemcacheData($keys, $keysNumber, $compactMode);
     if ($compactMode && is_array($mcData) && !empty($mcData)) {
         $outputStyle = new OutputFormatterStyle('yellow', null, array('bold'));
         $output->getFormatter()->setStyle('compactInfo', $outputStyle);
         foreach ($mcData as $data) {
             $output->writeln("<compactInfo>Key:</compactInfo> {$data[0]}");
             $output->writeln("");
             $output->writeln("<compactInfo>Value:</compactInfo> {$data[1]}");
             $output->writeln("");
             $output->writeln("<fg=green;options=bold>------------------------------------------</>");
         }
     } elseif (is_array($mcData) && !empty($mcData)) {
         $table = new Table($output);
         $table->setHeaders(['Key', 'Value'])->setRows($mcData);
         $table->render();
     } else {
         $output->writeln("<error>Nothing to show! Check your memcached server.</error>");
     }
 }
Example #12
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $jobId = $input->getArgument('job-id');
     $stats = $this->getBeanstalk()->statsJob($jobId);
     $output->writeln("<info>[Job ID: {$jobId}]</info>");
     $table = new Table($output);
     $table->setStyle('compact');
     $details = array_intersect_key($stats, array_flip(['tube', 'state']));
     foreach ($details as $detail => $value) {
         if ($detail == 'state' && $value == 'buried') {
             $value = "<error>{$value}</error>";
         }
         $table->addRow([$detail, $value]);
     }
     $table->render();
     $created = time();
     $table = new Table($output);
     $stats = array_diff_key($stats, array_flip(['id', 'tube', 'state']));
     $table->setHeaders(['Stat', 'Value']);
     foreach ($stats as $stat => $value) {
         if ($stat == 'age') {
             $created = time() - (int) $value;
             $dt = date('Y-m-d H:i:s', $created);
             $table->addRow(['created', $dt]);
         } elseif ($stat == 'delay') {
             $dt = date('Y-m-d H:i:s', $created + (int) $value);
             $table->addRow(['scheduled', $dt]);
         }
         $table->addRow([$stat, $value]);
     }
     $table->render();
 }
 /**
  * instala arquivos do tema se tiver na extensao
  * @param $extension
  * @param $output
  */
 private function installThemeFiles($extension, $output)
 {
     $theme_files = Util::getFilesTheme($extension);
     if (count($theme_files)) {
         $table = new Table($output);
         $table->setHeaders(array('Theme Files'));
         $themes = Util::getThemesPath();
         foreach ($themes as $theme) {
             foreach ($theme_files as $theme_file) {
                 $dest = str_replace($extension . '/theme/', $theme . '/', $theme_file);
                 $dir = dirname($dest);
                 if (!is_dir($dir)) {
                     mkdir($dir, 0755, true);
                 }
                 if (!file_exists($dest)) {
                     $table->addRow(['<info>' . $dest . '</info>']);
                 } else {
                     $table->addRow(['<comment>' . $dest . '</comment>']);
                 }
                 @copy($theme_file, $dest);
             }
         }
         $table->render();
     }
 }
Example #14
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $file = $input->getArgument("file");
     $list = array_filter($this->filesystem->listContents($file, true), function ($file) {
         return isset($file['type']) and ($file['type'] === "file" and isset($file['extension']) and $file['extension'] === "php");
     });
     // If the file argument is not directory, the listContents will return empty array.
     // In this case the user has specified a file
     if (empty($list)) {
         $list = [["path" => $this->filesystem->get($file)->getPath()]];
     }
     $dump = array_map(function ($file) use($output) {
         $output->writeln("Indexing " . $file['path'] . "...");
         return Indexer::index($this->filesystem->get($file['path']));
     }, $list);
     $table = new Table($output);
     $outputs = [];
     foreach ($dump as $a) {
         foreach ($a["functions"] as $val) {
             $outputs[] = [$val['file']->getPath(), $val['function'], implode(", ", array_map(function ($param) {
                 return implode('|', $param['type']) . " " . $param['name'];
             }, $val['arguments'])), implode(", ", $val['return']), (string) $val['scope']];
         }
     }
     $output->writeln("Indexing complete!");
     $output->writeln("Scanned " . count($list) . " files.");
     $output->writeln("Detected " . count($outputs) . " functions.");
     $output->writeln("Rendering Table...");
     $table->setHeaders(['File', 'Function', 'Arguments', 'Return', 'Scope'])->setRows($outputs);
     $table->render();
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $namespaces = $this->getContainer()->get('solr.doctrine.classnameresolver.known_entity_namespaces');
     $metaInformationFactory = $this->getContainer()->get('solr.meta.information.factory');
     foreach ($namespaces->getEntityClassnames() as $classname) {
         try {
             $metaInformation = $metaInformationFactory->loadInformation($classname);
         } catch (\RuntimeException $e) {
             $output->writeln(sprintf('<info>%s</info>', $e->getMessage()));
             continue;
         }
         $output->writeln(sprintf('<comment>%s</comment>', $classname));
         $output->writeln(sprintf('Documentname: %s', $metaInformation->getDocumentName()));
         $output->writeln(sprintf('Document Boost: %s', $metaInformation->getBoost() ? $metaInformation->getBoost() : '-'));
         $table = new Table($output);
         $table->setHeaders(array('Property', 'Document Fieldname', 'Boost'));
         foreach ($metaInformation->getFieldMapping() as $documentField => $property) {
             $field = $metaInformation->getField($documentField);
             if ($field === null) {
                 continue;
             }
             $table->addRow(array($property, $documentField, $field->boost));
         }
         $table->render();
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $missingOption = [];
     $optionScopeCount = 1;
     if (null === ($rainbowTablePath = $input->getOption("rainbow-table"))) {
         $missingOption[] = "rainbow-table";
     }
     if ($optionScopeCount === count($missingOption)) {
         throw MissingOptionException::create($missingOption);
     }
     $rainbowTable = new FileHandler($rainbowTablePath, FileHandlerInterface::MODE_READ_ONLY);
     $mode = RainbowPHPInterface::LOOKUP_MODE_SIMPLE;
     if ($input->getOption("partial")) {
         $mode |= RainbowPHPInterface::LOOKUP_MODE_PARTIAL;
     }
     if ($input->getOption("deep-search")) {
         $mode |= RainbowPHPInterface::LOOKUP_MODE_DEEP;
     }
     $hash = $input->getArgument("hash");
     $foundHashes = $this->rainbow->lookupHash($rainbowTable, $hash, $mode);
     if (empty($foundHashes)) {
         $output->writeln(sprintf("No value found for the hash '%s'", $hash));
     } else {
         $tableHelper = new Table($output);
         $tableHelper->setHeaders(["Hash", "Value"]);
         foreach ($foundHashes as $value => $foundHash) {
             $tableHelper->addRow([$foundHash, $value]);
         }
         $tableHelper->render();
     }
 }
Example #17
0
 /**
  * Execute command
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $techHeader = new TechHeader();
     $techHeader->setRequest($this->request);
     $values = $techHeader->getHeaders($this->url);
     if (empty($values)) {
         if ($input->getOption('json')) {
             $this->output->write(json_encode(['error' => 'No detectable technology was found']));
         } else {
             $this->output->writeln('No detectable technology was found');
         }
         return;
     }
     if ($input->getOption('json')) {
         $this->output->write(json_encode($values));
     } else {
         $rows = array();
         foreach ($values as $key => $value) {
             $rows[] = array($key, $value);
         }
         $this->writeHeader('Server Technology');
         $table = new Table($this->output);
         $table->setHeaders(array('Key', 'Value'))->setRows($rows)->render();
     }
 }
 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));
 }
Example #19
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $project = new Project(getcwd());
     if ($project->isValid()) {
         $releases = $project->getReleases($input->getOption('locale'));
         if (count($releases)) {
             $table = new Table($output);
             $table->setHeaders(['Version']);
             foreach ($releases as $release) {
                 $table->addRow([$release->getVersionNumber()]);
             }
             $table->render();
             $output->writeln('');
             if (count($releases) === 1) {
                 $output->writeln('1 release found');
             } else {
                 $output->writeln(count($releases) . ' releases found');
             }
         } else {
             $output->writeln('0 releases found');
         }
     } else {
         $output->writeln('<error>This is not a valid Shade project</error>');
     }
 }
Example #20
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $project = new Project(getcwd());
     if ($project->isValid()) {
         $videos = $project->getVideos($input->getOption('locale'));
         if ($videos->count()) {
             $table = new Table($output);
             $table->setHeaders(['Name', 'Group', 'Title', 'Play Time', 'Wistia Code']);
             foreach ($videos as $video) {
                 $table->addRow([$video->getShortName(), $video->getGroupName(), $video->getTitle(), $video->getPlayTime(), $video->getProperty('wistia_code')]);
             }
             $table->render();
             $output->writeln('');
             if ($videos->count() === 1) {
                 $output->writeln('1 video found');
             } else {
                 $output->writeln($videos->count() . ' videos found');
             }
         } else {
             $output->writeln('0 videos found');
         }
     } else {
         $output->writeln('<error>This is not a valid Shade project</error>');
     }
 }
Example #21
0
 /**
  * This method is executed after initialize(). It usually contains the logic
  * to execute to complete this command task.
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $maxResults = $input->getOption('max-results');
     // Use ->findBy() instead of ->findAll() to allow result sorting and limiting
     $users = $this->em->getRepository('AppBundle:User')->findBy(array(), array('id' => 'DESC'), $maxResults);
     // Doctrine query returns an array of objects and we need an array of plain arrays
     $usersAsPlainArrays = array_map(function ($user) {
         return array($user->getId(), $user->getUsername(), $user->getEmail(), implode(', ', $user->getRoles()));
     }, $users);
     // In your console commands you should always use the regular output type,
     // which outputs contents directly in the console window. However, this
     // particular command uses the BufferedOutput type instead.
     // The reason is that the table displaying the list of users can be sent
     // via email if the '--send-to' option is provided. Instead of complicating
     // things, the BufferedOutput allows to get the command output and store
     // it in a variable before displaying it.
     $bufferedOutput = new BufferedOutput();
     $table = new Table($bufferedOutput);
     $table->setHeaders(array('ID', 'Username', 'Email', 'Roles'))->setRows($usersAsPlainArrays);
     $table->render();
     // instead of displaying the table of users, store it in a variable
     $tableContents = $bufferedOutput->fetch();
     if (null !== ($email = $input->getOption('send-to'))) {
         $this->sendReport($tableContents, $email);
     }
     $output->writeln($tableContents);
 }
Example #22
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $repository = $this->getRepository();
     /** @var FilesystemInterface $master */
     $master = $this->getContainer()->get('repository.master_storage');
     /** @var CertificateParser $certificateParser */
     $certificateParser = $this->getContainer()->get('ssl.certificate_parser');
     $table = new Table($output);
     $table->setHeaders(['Domain', 'Issuer', 'Valid from', 'Valid to', 'Needs renewal?']);
     $directories = $master->listContents('certs');
     foreach ($directories as $directory) {
         if ($directory['type'] !== 'dir') {
             continue;
         }
         $parsedCertificate = $certificateParser->parse($repository->loadDomainCertificate($directory['basename']));
         $domainString = $parsedCertificate->getSubject();
         $alternativeNames = array_diff($parsedCertificate->getSubjectAlternativeNames(), [$parsedCertificate->getSubject()]);
         if (count($alternativeNames)) {
             sort($alternativeNames);
             $last = array_pop($alternativeNames);
             foreach ($alternativeNames as $alternativeName) {
                 $domainString .= "\n ├── " . $alternativeName;
             }
             $domainString .= "\n └── " . $last;
         }
         $table->addRow([$domainString, $parsedCertificate->getIssuer(), $parsedCertificate->getValidFrom()->format('Y-m-d H:i:s'), $parsedCertificate->getValidTo()->format('Y-m-d H:i:s'), $parsedCertificate->getValidTo()->format('U') - time() < 604800 ? '<comment>Yes</comment>' : 'No']);
     }
     $table->render();
 }
 protected function execute(InputInterface $input, OutputInterface $output) : int
 {
     if (!$output->isQuiet()) {
         $output->writeln($this->getApplication()->getLongVersion());
     }
     $composerJson = $input->getArgument('composer-json');
     $this->checkJsonFile($composerJson);
     $getPackageSourceFiles = new LocateComposerPackageSourceFiles();
     $sourcesASTs = new LocateASTFromFiles((new ParserFactory())->create(ParserFactory::PREFER_PHP7));
     $definedVendorSymbols = (new LocateDefinedSymbolsFromASTRoots())->__invoke($sourcesASTs((new ComposeGenerators())->__invoke($getPackageSourceFiles($composerJson), (new LocateComposerPackageDirectDependenciesSourceFiles())->__invoke($composerJson))));
     $options = $this->getCheckOptions($input);
     $definedExtensionSymbols = (new LocateDefinedSymbolsFromExtensions())->__invoke((new DefinedExtensionsResolver())->__invoke($composerJson, $options->getPhpCoreExtensions()));
     $usedSymbols = (new LocateUsedSymbolsFromASTRoots())->__invoke($sourcesASTs($getPackageSourceFiles($composerJson)));
     $unknownSymbols = array_diff($usedSymbols, $definedVendorSymbols, $definedExtensionSymbols, $options->getSymbolWhitelist());
     if (!$unknownSymbols) {
         $output->writeln("There were no unknown symbols found.");
         return 0;
     }
     $output->writeln("The following unknown symbols were found:");
     $table = new Table($output);
     $table->setHeaders(['unknown symbol', 'guessed dependency']);
     $guesser = new DependencyGuesser();
     foreach ($unknownSymbols as $unknownSymbol) {
         $guessedDependencies = [];
         foreach ($guesser($unknownSymbol) as $guessedDependency) {
             $guessedDependencies[] = $guessedDependency;
         }
         $table->addRow([$unknownSymbol, implode("\n", $guessedDependencies)]);
     }
     $table->render();
     return (int) (bool) $unknownSymbols;
 }
Example #24
0
 /**
  * @param OutputInterface $output
  * @param string          $action
  */
 protected function dumpProcessors(OutputInterface $output, $action)
 {
     /** @var ProcessorBagInterface $processorBag */
     $processorBag = $this->getContainer()->get('oro_api.processor_bag');
     $table = new Table($output);
     $table->setHeaders(['Processor', 'Attributes']);
     $context = new Context();
     $context->setAction($action);
     $processors = $processorBag->getProcessors($context);
     $processors->setApplicableChecker(new ChainApplicableChecker());
     $i = 0;
     foreach ($processors as $processor) {
         if ($i > 0) {
             $table->addRow(new TableSeparator());
         }
         $processorColumn = sprintf('<comment>%s</comment>%s%s', $processors->getProcessorId(), PHP_EOL, get_class($processor));
         $processorDescription = $this->getClassDocComment(get_class($processor));
         if (!empty($processorDescription)) {
             $processorColumn .= PHP_EOL . $processorDescription;
         }
         $attributesColumn = $this->formatProcessorAttributes($processors->getProcessorAttributes());
         $table->addRow([$processorColumn, $attributesColumn]);
         $i++;
     }
     $table->render();
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $templates = [];
     foreach ($this->defaults as $name => $defaults) {
         $templates[$name] = ['environments' => [], 'scalingProfiles' => []];
     }
     foreach ($this->environments as $template => $environments) {
         foreach ($environments as $name => $options) {
             $templates[$template]['environments'][] = $name;
         }
     }
     foreach ($this->scalingProfiles as $template => $scalingProfiles) {
         foreach ($scalingProfiles as $name => $options) {
             $templates[$template]['scalingProfiles'][] = $name;
         }
     }
     $table = new Table($output);
     $table->setHeaders(['Name', 'Environments', 'Scaling profiles']);
     $i = 0;
     foreach ($templates as $name => $data) {
         ++$i;
         $table->addRow([$name, implode("\n", $data['environments']), implode("\n", $data['scalingProfiles'])]);
         if ($i !== count($templates)) {
             $table->addRow(new TableSeparator());
         }
     }
     $table->render();
 }
 /**
  * @{inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->classContentManager = $this->getApplication()->getApplication()->getContainer()->get('classcontent.manager');
     $this->classContents = $this->classContentManager->getAllClassContentClassnames();
     /*
      * @todo: better to use isEnabled to hide this function if no class contents were found ?
      */
     if (!is_array($this->classContents) || count($this->classContents) <= 0) {
         throw new \LogicException('You don`t have any Class content in application');
     }
     if ($input->getArgument('classname')) {
         $output->writeln($this->describeClassContent($input->getArgument('classname')));
         return;
     }
     $output->writeln($this->getHelper('formatter')->formatSection('Class Contents', 'List of available Class Contents'));
     $output->writeln('');
     $headers = array('Name', 'Classname');
     $table = new Table($output);
     $table->setHeaders($headers)->setStyle('compact');
     foreach ($this->classContents as $classContent) {
         $instance = new $classContent();
         $table->addRow([$instance->getProperty('name'), $classContent]);
     }
     $table->render();
 }
Example #27
0
 /**
  * Executes the current command.
  *
  * This method is not abstract because you can use this class
  * as a concrete class. In this case, instead of defining the
  * execute() method, you set the code to execute by passing
  * a Closure to the setCode() method.
  *
  * @param InputInterface $input An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @return null|int null or 0 if everything went fine, or an error code
  *
  * @throws \LogicException When this abstract method is not implemented
  *
  * @see setCode()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var DefinitionChecker $checker */
     $checker = $this->getContainer()->get('babymarkt_ext_cron.service.definitionchecker');
     $checker->setApplication($this->getApplication());
     /** @var Definition[] $definitions */
     $definitions = $this->getContainer()->getParameter('babymarkt_ext_cron.definitions');
     $errorFound = false;
     if (count($definitions)) {
         $resultList = [];
         foreach ($definitions as $alias => $definition) {
             $definition = new Definition($definition);
             if ($definition->isDisabled()) {
                 $resultList[] = ['alias' => $alias, 'command' => $definition->getCommand(), 'result' => '<comment>Disabled</comment>'];
             } else {
                 if (!$checker->check($definition)) {
                     $resultList[] = ['alias' => $alias, 'command' => $definition->getCommand(), 'result' => '<error>' . $checker->getResult() . '</error>'];
                     $errorFound = true;
                 } else {
                     $resultList[] = ['alias' => $alias, 'command' => $definition->getCommand(), 'result' => '<info>OK</info>'];
                 }
             }
         }
         $table = new Table($output);
         $table->setHeaders(['Alias', 'Command', 'Result']);
         $table->setRows($resultList);
         $table->render();
     } else {
         $output->writeln('<comment>No cron job definitions found.</comment>');
     }
     return (int) $errorFound;
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $client = $this->get('client');
     $features = array();
     if (!empty($input->getOption('features'))) {
         $features = explode(',', $input->getOption('features'));
     }
     try {
         $result = $client->api('clients')->getList($features);
         $clients = array();
         if ('ok' === strtolower($result['stat']) && !empty($result['results'])) {
             $clients = $result['results'];
         }
         $rows = array();
         foreach ($clients as $client) {
             $rows[] = array($client['client_id'], $client['client_secret'], $client['description']);
         }
         $table = new Table($output);
         $table->setHeaders(array('client_id', 'client_secret', 'description'))->setRows($rows);
         $table->render();
         exit(0);
     } catch (\Exception $e) {
         $output->writeln('<error>' . $e->getMessage() . '</error>');
         exit(1);
     }
 }
Example #29
0
 private function printTable(array $headers, array $rows, OutputInterface $output)
 {
     $table = new Table($output);
     $table->setHeaders($headers);
     $table->setRows($rows);
     $table->render();
 }
Example #30
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $source = $input->getArgument('source');
     if (is_dir($source) === false && is_file($source) === false) {
         throw new \InvalidArgumentException(sprintf('"%s" is not a file or a directory', $source));
     }
     $logger = new Logger($this->output, $input->getOption('debug'));
     if (is_dir($source) === true) {
         $collector = new DirectoryCodeCollector(array($source));
     } elseif (is_file($source) === true) {
         $collector = new FileCodeCollector(array($source));
     }
     foreach ($this->engine->convert($collector, $logger, $input->getArgument('file')) as $file) {
         $this->fileRender->render($file);
     }
     $table = new Table($this->output);
     $table->setHeaders(array(array(new TableCell('Incompatibility', array('colspan' => 4))), array('Type', 'Message', 'Line', 'Class')));
     $table->setRows($logger->getIncompatibility());
     $table->render();
     if ($input->getOption('v') === true) {
         $table = new Table($this->output);
         $table->setHeaders(array(array(new TableCell('Log', array('colspan' => 3))), array('Message', 'Line', 'Class')));
         $table->setRows($logger->getLogs());
         $table->render();
     }
 }