table() public method

public table ( array $headers, array $rows )
$headers array
$rows array
 public function writeErrorReports(array $errorReports)
 {
     foreach ($errorReports as $file => $errors) {
         $this->symfonyStyle->section('FILE: ' . $file);
         $tableRows = $this->formatErrorsToTableRows($errors);
         $this->symfonyStyle->table(['Line', 'Error', 'Sniff Code', 'Fixable'], $tableRows);
         $this->symfonyStyle->newLine();
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function executeLocked(InputInterface $input, OutputInterface $output)
 {
     $this->io = new SymfonyStyle($input, $output);
     $this->rootDir = dirname($this->getContainer()->getParameter('kernel.root_dir'));
     $this->generateSymlinks();
     if (!empty($this->rows)) {
         $this->io->newLine();
         $this->io->table(['', 'Symlink', 'Target / Error'], $this->rows);
     }
     return 0;
 }
Exemplo n.º 3
0
 /**
  * @throws \InvalidArgumentException When route does not exist
  */
 protected function outputMailer($name)
 {
     try {
         $service = sprintf('swiftmailer.mailer.%s', $name);
         $mailer = $this->getContainer()->get($service);
     } catch (ServiceNotFoundException $e) {
         throw new \InvalidArgumentException(sprintf('The mailer "%s" does not exist.', $name));
     }
     $tableHeaders = array('Property', 'Value');
     $tableRows = array();
     $transport = $mailer->getTransport();
     $spool = $this->getContainer()->getParameter(sprintf('swiftmailer.mailer.%s.spool.enabled', $name)) ? 'YES' : 'NO';
     $delivery = $this->getContainer()->getParameter(sprintf('swiftmailer.mailer.%s.delivery.enabled', $name)) ? 'YES' : 'NO';
     $singleAddress = $this->getContainer()->getParameter(sprintf('swiftmailer.mailer.%s.single_address', $name));
     $this->io->title(sprintf('Configuration of the Mailer "%s"', $name));
     if ($this->isDefaultMailer($name)) {
         $this->io->comment('This is the default mailer');
     }
     $tableRows[] = array('Name', $name);
     $tableRows[] = array('Service', $service);
     $tableRows[] = array('Class', get_class($mailer));
     $tableRows[] = array('Transport', sprintf('%s (%s)', sprintf('swiftmailer.mailer.%s.transport.name', $name), get_class($transport)));
     $tableRows[] = array('Spool', $spool);
     if ($this->getContainer()->hasParameter(sprintf('swiftmailer.spool.%s.file.path', $name))) {
         $tableRows[] = array('Spool file', $this->getContainer()->getParameter(sprintf('swiftmailer.spool.%s.file.path', $name)));
     }
     $tableRows[] = array('Delivery', $delivery);
     $tableRows[] = array('Single Address', $singleAddress);
     $this->io->table($tableHeaders, $tableRows);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->title('Check Pre-commit requirements');
     $hasError = false;
     $resultOkVal = '<fg=green>✔</>';
     $resultNokVal = '<fg=red>✘</>';
     $commands = ['Composer' => array('command' => 'composer', 'result' => $resultOkVal), 'xmllint' => array('command' => 'xmllint', 'result' => $resultOkVal), 'jsonlint' => array('command' => 'jsonlint', 'result' => $resultOkVal), 'eslint' => array('command' => 'eslint', 'result' => $resultOkVal), 'sass-convert' => array('command' => 'sass-convert', 'result' => $resultOkVal), 'scss-lint' => array('command' => 'scss-lint', 'result' => $resultOkVal), 'phpcpd' => array('command' => 'phpcpd', 'result' => $resultOkVal), 'php-cs-fixer' => array('command' => 'php-cs-fixer', 'result' => $resultOkVal), 'phpmd' => array('command' => 'phpmd', 'result' => $resultOkVal), 'phpcs' => array('command' => 'phpcs', 'result' => $resultOkVal), 'box' => array('command' => 'box', 'result' => $resultOkVal)];
     foreach ($commands as $label => $command) {
         if (!$this->checkCommand($label, $command['command'])) {
             $commands[$label]['result'] = $resultNokVal;
             $hasError = true;
         }
     }
     // Check Php conf param phar.readonly
     if (!ini_get('phar.readonly')) {
         $commands['phar.readonly'] = array('result' => $resultOkVal);
     } else {
         $commands['phar.readonly'] = array('result' => 'not OK (set "phar.readonly = Off" on your php.ini)');
     }
     $headers = ['Command', 'check'];
     $rows = [];
     foreach ($commands as $label => $cmd) {
         $rows[] = [$label, $cmd['result']];
     }
     $io->table($headers, $rows);
     if (!$hasError) {
         $io->success('All Requirements are OK');
     } else {
         $io->note('Please fix all requirements');
     }
     exit(0);
 }
Exemplo n.º 5
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $namespace = $input->getArgument('namespace');
     /** @var RouteCollection $RouteCollection */
     $RouteCollection = Service::get('kernel.routes');
     $Routes = $RouteCollection->all();
     $io = new SymfonyStyle($input, $output);
     $io->newLine();
     $rows = array();
     /** @var Route $Route */
     foreach ($Routes as $name => $Route) {
         $path = $Route->getPath();
         $local = $Route->getOption('_locale');
         $controller = $Route->getDefault('controller');
         $host = $Route->getHost();
         $methods = implode(', ', $Route->getMethods());
         $schemes = implode(', ', $Route->getSchemes());
         $_requirements = $Route->getRequirements();
         $requirements = null;
         $name = $local ? str_replace("-{$local}", '', $name) : $name;
         foreach ($_requirements as $var => $patt) {
             $requirements .= "\"{$var}={$patt}\" ";
         }
         $requirements = $requirements ? rtrim($requirements, ',') : '';
         $rows[] = array($name, $path, $local, $methods, $schemes);
     }
     $io->table(array('Name', 'Path', 'Local', 'Method', 'Scheme'), $rows);
     $io->success('Se han mostrado las rutas del proyecto exitosamente.');
 }
Exemplo n.º 6
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->migrationPath = str_replace('/', DIRECTORY_SEPARATOR, $this->getContainer()->getParameter('campaignchain_update.bundle.schema_dir'));
     $io = new SymfonyStyle($input, $output);
     $io->title('Gathering migration files from CampaignChain packages');
     $io->newLine();
     $locator = $this->getContainer()->get('campaignchain.core.module.locator');
     $bundleList = $locator->getAvailableBundles();
     if (empty($bundleList)) {
         $io->error('No CampaignChain Module found');
         return;
     }
     $migrationsDir = $this->getContainer()->getParameter('doctrine_migrations.dir_name');
     $fs = new Filesystem();
     $table = [];
     foreach ($bundleList as $bundle) {
         $packageSchemaDir = $this->getContainer()->getParameter('kernel.root_dir') . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . $bundle->getName() . $this->migrationPath;
         if (!$fs->exists($packageSchemaDir)) {
             continue;
         }
         $migrationFiles = new Finder();
         $migrationFiles->files()->in($packageSchemaDir)->name('Version*.php');
         $files = [];
         /** @var SplFileInfo $migrationFile */
         foreach ($migrationFiles as $migrationFile) {
             $fs->copy($migrationFile->getPathname(), $migrationsDir . DIRECTORY_SEPARATOR . $migrationFile->getFilename(), true);
             $files[] = $migrationFile->getFilename();
         }
         $table[] = [$bundle->getName(), implode(', ', $files)];
     }
     $io->table(['Module', 'Versions'], $table);
     if (!$input->getOption('gather-only')) {
         $this->getApplication()->run(new ArrayInput(['command' => 'doctrine:migrations:migrate', '--no-interaction' => true]), $output);
     }
 }
 /**
  * @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;
 }
Exemplo n.º 8
0
 /**
  * Print the current definitions.
  */
 protected function printDefinitions()
 {
     $this->title('Definitions');
     $rows = [];
     foreach ($this->configuration->getDefinitionProviders() as $definition) {
         if ($definition instanceof ImmutableContainerAwareInterface) {
             $definition->setContainer(new Container());
         }
         $parameters = [];
         $reflection = new ReflectionClass($definition);
         if ($reflection->getProperties()) {
             foreach ($reflection->getProperties() as $parameter) {
                 if ($parameter->getName() === 'container') {
                     continue;
                 }
                 // Extract parameter type
                 $doc = $parameter->getDocComment();
                 preg_match('/.*@(type|var) (.+)\\n.*/', $doc, $type);
                 $type = $type[2];
                 $parameters[] = '<info>' . $parameter->getName() . '</info>: ' . $type;
             }
         }
         $definitions = array_keys($definition->getDefinitions());
         foreach ($definitions as $key => $binding) {
             $definitions[$key] = is_string($binding) ? $key + 1 . '. <comment>' . $binding . '</comment>' : null;
         }
         $rows[] = ['definition' => '<comment>' . get_class($definition) . '</comment>', 'options' => implode(PHP_EOL, $parameters), 'bindings' => implode(PHP_EOL, $definitions)];
         $rows[] = new TableSeparator();
     }
     $this->output->table(['Definition', 'Options', 'Bindings'], array_slice($rows, 0, -1));
 }
Exemplo n.º 9
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $entityManager = $this->getContainer()->get('doctrine.orm.entity_manager');
     $groupRepository = $entityManager->getRepository('OctavaAdministratorBundle:Group');
     $resourceRepository = $entityManager->getRepository('OctavaAdministratorBundle:Resource');
     $groupNames = $input->getOption('group');
     foreach ($groupNames as $groupName) {
         /** @var Group $group */
         $group = $groupRepository->findOneBy(['name' => $groupName]);
         if (!$group) {
             $io->error(sprintf('Group "%s" not found', $groupName));
             continue;
         }
         $rows = [];
         $existsResources = $group->getResources();
         /** @var \Octava\Bundle\AdministratorBundle\Entity\Resource $resource */
         foreach ($resourceRepository->findAll() as $resource) {
             if ($existsResources->contains($resource)) {
                 continue;
             }
             $group->addResource($resource);
             $rows[] = [$resource->getResource(), $resource->getAction()];
         }
         if ($rows) {
             $io->section($groupName);
             $headers = ['Resource', 'Action'];
             $io->table($headers, $rows);
             $entityManager->persist($group);
             $entityManager->flush();
         }
     }
 }
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $pastDate = $input->getOption(self::PAST_DATE) ? new DateTime($input->getOption(self::PAST_DATE)) : null;
     $data = $this->vendorProcessor->getWallets($this->merchantGroupId, $pastDate);
     $io->title("Hipay Wallets");
     $io->table(array_keys(reset($data)), $data);
 }
Exemplo n.º 11
0
 protected function displayAsTable(SymfonyStyle $io, $header, $results)
 {
     $rows = [];
     foreach ($results as $day => $shows_per_day) {
         foreach ($shows_per_day as $result) {
             $rows[] = $this->getRow(...$result);
         }
     }
     $io->table($header, $rows);
 }
Exemplo n.º 12
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output = new SymfonyStyle($input, $output);
     $queues = $this->queueRegistry->all();
     $tableInput = array();
     foreach ($queues as $queue) {
         $tableInput[] = array($queue->getName(), $queue->count());
     }
     $output->table(array('Name', 'Outstanding jobs'), $tableInput);
 }
 protected function listTransactions($transactions)
 {
     $rows = array();
     $timecolumn = 2;
     array_walk($transactions, function ($transaction) use(&$rows) {
         $row = [$transaction["txid"], $transaction["confirmations"], $transaction["time"]];
         $rows[] = $row;
     });
     usort($rows, function ($a, $b) use($timecolumn) {
         if ($a[$timecolumn] == $b[$timecolumn]) {
             return 0;
         }
         return $a[$timecolumn] < $b[$timecolumn] ? 1 : -1;
     });
     array_walk($rows, function (&$row) use($timecolumn) {
         $row[$timecolumn] = $this->time2str($row[$timecolumn]);
     });
     $this->io->table(["Txid", "Confirmations", "Time"], $rows);
 }
Exemplo n.º 14
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output = new SymfonyStyle($input, $output);
     $workers = $this->workerRegistry->all();
     $tableInput = array();
     foreach ($workers as $worker) {
         $tableInput[] = array($worker->getId(), $worker->getHostname(), $worker->getProcess()->getPid(), $worker->getCurrentJob());
     }
     $output->table(array('Id', 'Hostname', 'Pid', 'Current job'), $tableInput);
 }
Exemplo n.º 15
0
 protected function confirmConfiguration()
 {
     $rows = [];
     foreach ($this->config as $section => $values) {
         foreach ($values as $name => $value) {
             $rows[] = [$name, $value];
         }
     }
     $this->io->table(['Name', 'Value'], $rows);
     return $this->io->askQuestion(new ConfirmationQuestion('Are these settings correct?'));
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $name = $input->getArgument("name");
     // TODO
     $username = $input->hasArgument("username") ? $input->getArgument("username") : null;
     /** @var ClientManager $clientManager */
     $clientManager = $this->getContainer()->get("kr.oauth_server.manager.client");
     $client = $clientManager->createClient();
     $client->setName($name);
     $clientManager->saveClient($client);
     $io->success("Client has been created:");
     $io->table(["name", "id", "secret"], [[$client->getName(), $client->getId(), $client->getSecret()]]);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var SlackBot $slackBot */
     $slackBot = $this->getContainer()->get('wowapps.slackbot');
     $slackBotConfig = $slackBot->getConfig();
     $symfonyStyle = new SymfonyStyle($input, $output);
     echo PHP_EOL;
     $output->writeln('<bg=blue;options=bold;fg=white>                                               </>');
     $output->writeln('<bg=blue;options=bold;fg=white>           S L A C K B O T   T E S T           </>');
     $output->writeln('<bg=blue;options=bold;fg=white>                                               </>');
     echo PHP_EOL;
     $symfonyStyle->section('SlackBot general settings');
     $symfonyStyle->table(['api url'], [[$slackBotConfig['api_url']]]);
     $symfonyStyle->table(['default icon'], [[$slackBotConfig['default_icon']]]);
     $symfonyStyle->table(['default recipient'], [[$slackBotConfig['default_channel']]]);
     $symfonyStyle->section('SlackBot quote colors');
     $symfonyStyle->table(['default', 'info', 'warning', 'success', 'danger'], [[$slackBotConfig['quote_color']['default'], $slackBotConfig['quote_color']['info'], $slackBotConfig['quote_color']['warning'], $slackBotConfig['quote_color']['success'], $slackBotConfig['quote_color']['danger']]]);
     $symfonyStyle->section('Sending short message...');
     if ($this->sendTestMessage($slackBot)) {
         $symfonyStyle->success('Message sent successfully');
     } else {
         $symfonyStyle->error('Message not sent');
     }
 }
Exemplo n.º 18
0
 private function showLocaleOverview()
 {
     $locale = array_map(function ($locale, $key) {
         $enabledMessage = null;
         $interfaceMessage = null;
         if ($this->defaultEnabledLocale === $key) {
             $enabledMessage = ' (default)';
         }
         if ($this->defaultInterfaceLocale === $key) {
             $interfaceMessage = ' (default)';
         }
         return ['key' => $key, 'locale' => $locale, 'installed' => array_key_exists($key, $this->installedLocale) ? 'Y' : 'N', 'interface' => (array_key_exists($key, $this->interfaceLocale) ? 'Y' : 'N') . $interfaceMessage, 'enabled' => (array_key_exists($key, $this->enabledLocale) ? 'Y' : 'N') . $enabledMessage, 'redirect' => array_key_exists($key, $this->redirectLocale) ? 'Y' : 'N'];
     }, $this->getInstallableLocale(), array_keys($this->getInstallableLocale()));
     $this->formatter->listing(["key:\t\tThe identifier of the locale", "locale:\tThe name of the locale", "installed:\tPossible locale to use as interface, enabled or redirect locale", "interface:\tLocale that the user in the backend can use for the interface", "enabled:\tLocale that are accessible for visitors", "redirect:\tLocale that people may automatically be redirected to based upon their browser locale"]);
     $this->formatter->table(['key', 'locale', 'installed', 'interface', 'enabled', 'redirect'], $locale);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     /** @var ClientManager $clientManager */
     $clientManager = $this->getContainer()->get("kr.oauth_server.manager.client");
     /** @var ClientInterface[] $clients */
     $clients = $clientManager->getRepository()->findAll();
     $rows = [];
     foreach ($clients as $client) {
         $username = "";
         if ($client->getUser()) {
             $username = $client->getUser()->getUsername();
         }
         $rows[] = [$client->getId(), $client->getSecret(), $username];
     }
     $io->table(["id", "secret", "user"], $rows);
 }
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->title("Banking information");
     $hipayID = $input->getArgument(self::HIPAY_ID);
     $vendor = new Vendor(false, false, $hipayID);
     $status = $this->vendorProcessor->getBankInfoStatus($vendor);
     $io->writeln($status);
     if (trim($status) == BankInfo::VALIDATED) {
         $bankData = $this->vendorProcessor->getBankInfo($vendor)->getData();
         $rows = array();
         foreach ($bankData as $key => $value) {
             $rows[] = array($key, $value);
         }
         $io->table(array('key', 'value'), $rows);
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $clientId = $input->getArgument("client_id");
     $io = new SymfonyStyle($input, $output);
     /** @var ClientRepository $clientRepository */
     $clientRepository = $this->getContainer()->get("kr.oauth_server.repository.client");
     /** @var ClientInterface $clients */
     $client = $clientRepository->find($clientId);
     $rows = [];
     $username = "";
     if ($client->getUser()) {
         $username = $client->getUser()->getUsername();
     }
     $grants = implode(", ", $client->getAllowedGrantTypes());
     $redirectUris = implode(", ", $client->getRedirectUris());
     $rows[] = [$client->getId(), $client->getSecret(), $username, $grants, $redirectUris];
     $io->table(["Id", "Secret", "Username", "Allowed grants", "Redirect uris"], $rows);
 }
Exemplo n.º 22
0
 private function showAdvisorsList(SymfonyStyle $io)
 {
     $io->writeln('List of registered advisors in the container');
     $aspectContainer = $this->aspectKernel->getContainer();
     $advisors = $this->loadAdvisorsList($aspectContainer);
     $tableRows = [];
     foreach ($advisors as $id => $advisor) {
         list(, $id) = explode('.', $id, 2);
         $advice = $advisor->getAdvice();
         $expression = '';
         try {
             $pointcutExpression = new \ReflectionProperty($advice, 'pointcutExpression');
             $pointcutExpression->setAccessible('true');
             $expression = $pointcutExpression->getValue($advice);
         } catch (\ReflectionException $e) {
             // nothing here, just ignore
         }
         $tableRows[] = [$id, $expression];
     }
     $io->table(['Id', 'Expression'], $tableRows);
     $io->writeln(['If you want to query an information about concrete advisor, then just query it', 'by adding <info>--advisor="Advisor\\Name"</info> to the command']);
 }
Exemplo n.º 23
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $date = new \DateTime($input->getArgument('datetime'));
     // Get departure/arrival stops
     $departure = $this->getStop($input->getArgument('departure'), 'Which departure ?');
     $arrival = $this->getStop($input->getArgument('arrival'), 'Which arrival ?');
     $io->title(sprintf('%s -> %s (%s)', $departure['value'], $arrival['value'], $date->format('d.m.y H:i')));
     // Query
     $times = $this->cff->query($departure, $arrival, $date);
     // Compute delays
     $delays = array();
     $now = new \DateTime();
     foreach ($times as $time) {
         $diff = $now->diff(\DateTime::createFromFormat('d.m.y H:i', $time['date'] . ' ' . $time['departure']));
         $delays[] = (int) ($diff->format('%r') . ($diff->h * 60 + $diff->i));
     }
     // Show output table
     $formattedTimes = array_map(function ($v, $d) {
         unset($v['date']);
         $v = array('in' => $d . '´') + $v;
         $v['infos'] = '<error>' . $v['infos'] . '</error>';
         return $v;
     }, $times, $delays);
     $io->table(array('In', 'Dep.', 'Arr.', 'Dur.', 'Chg.', 'With', 'Infos'), $formattedTimes);
     // Show notification
     if ($input->getOption('notify')) {
         $notifier = NotifierFactory::create();
         $body = '';
         foreach ($times as $t => $time) {
             $body .= sprintf("%s - %s | %s | %s chg. | %s | in %s´ %s\r\n", $time['departure'], $time['arrival'], $time['duration'], $time['change'], $time['product'], $delays[$t], $time['infos']);
         }
         $notification = (new Notification())->setTitle(sprintf("%s -> %s", $departure['value'], $arrival['value']))->setBody($body);
         $notifier->send($notification);
     }
 }
Exemplo n.º 24
0
 public function table(array $headers, array $rows)
 {
     $application = new Application();
     $dimensions = $application->getTerminalDimensions();
     $terminalWidth = $dimensions[0] ?: self::MAX_LINE_LENGTH;
     $maxHeaderWidth = strlen($headers[0]);
     foreach ($rows as $row) {
         $length = strlen($row[0]);
         if ($maxHeaderWidth === null || $length > $maxHeaderWidth) {
             $maxHeaderWidth = $length;
         }
     }
     $wrap = function ($rows) use($terminalWidth, $maxHeaderWidth) {
         return array_map(function ($row) use($terminalWidth, $maxHeaderWidth) {
             return array_map(function ($s) use($terminalWidth, $maxHeaderWidth) {
                 if ($terminalWidth > $maxHeaderWidth + 5) {
                     return wordwrap($s, $terminalWidth - $maxHeaderWidth - 5, "\n", true);
                 }
                 return $s;
             }, $row);
         }, $rows);
     };
     parent::table($headers, $wrap($rows));
 }
Exemplo n.º 25
0
 /**
  * @param array $array
  */
 private function renderEventListenerTable(EventDispatcherInterface $eventDispatcher, $event, array $eventListeners, SymfonyStyle $io)
 {
     $tableHeaders = array('Order', 'Callable', 'Priority');
     $tableRows = array();
     $order = 1;
     foreach ($eventListeners as $order => $listener) {
         $tableRows[] = array(sprintf('#%d', $order + 1), $this->formatCallable($listener), $eventDispatcher->getListenerPriority($event, $listener));
     }
     $io->table($tableHeaders, $tableRows);
 }
 public function handle(Event $event)
 {
     $io = new SymfonyStyle(new StringInput(''), $this->output);
     $io->section('Payroll sending report');
     $io->table(array('Month', $event->getMonth()), array(array('Employees', $event->getProgress()->getTotal()), array('Sent emails', $event->getProgress()->getSent()), array('Payrolls not found', $event->getProgress()->getNotFound()), array('Emails Failed', $event->getProgress()->getFailed())));
 }
Exemplo n.º 27
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $locale = $input->getArgument('locale');
     $domain = $input->getOption('domain');
     /** @var TranslationLoader $loader */
     $loader = $this->getContainer()->get('translation.loader');
     /** @var Kernel $kernel */
     $kernel = $this->getContainer()->get('kernel');
     // Define Root Path to App folder
     $transPaths = array($kernel->getRootDir() . '/Resources/');
     // Override with provided Bundle info
     if (null !== $input->getArgument('bundle')) {
         try {
             $bundle = $kernel->getBundle($input->getArgument('bundle'));
             $transPaths = array($bundle->getPath() . '/Resources/', sprintf('%s/Resources/%s/', $kernel->getRootDir(), $bundle->getName()));
         } catch (\InvalidArgumentException $e) {
             // such a bundle does not exist, so treat the argument as path
             $transPaths = array($input->getArgument('bundle') . '/Resources/');
             if (!is_dir($transPaths[0])) {
                 throw new \InvalidArgumentException(sprintf('"%s" is neither an enabled bundle nor a directory.', $transPaths[0]));
             }
         }
     } elseif ($input->getOption('all')) {
         foreach ($kernel->getBundles() as $bundle) {
             $transPaths[] = $bundle->getPath() . '/Resources/';
             $transPaths[] = sprintf('%s/Resources/%s/', $kernel->getRootDir(), $bundle->getName());
         }
     }
     // Extract used messages
     $extractedCatalogue = $this->extractMessages($locale, $transPaths);
     // Load defined messages
     $currentCatalogue = $this->loadCurrentMessages($locale, $transPaths, $loader);
     // Merge defined and extracted messages to get all message ids
     $mergeOperation = new MergeOperation($extractedCatalogue, $currentCatalogue);
     $allMessages = $mergeOperation->getResult()->all($domain);
     if (null !== $domain) {
         $allMessages = array($domain => $allMessages);
     }
     // No defined or extracted messages
     if (empty($allMessages) || null !== $domain && empty($allMessages[$domain])) {
         $outputMessage = sprintf('No defined or extracted messages for locale "%s"', $locale);
         if (null !== $domain) {
             $outputMessage .= sprintf(' and domain "%s"', $domain);
         }
         $io->warning($outputMessage);
         return;
     }
     // Load the fallback catalogues
     $fallbackCatalogues = $this->loadFallbackCatalogues($locale, $transPaths, $loader);
     // Display header line
     $headers = array('State', 'Domain', 'Id', sprintf('Message Preview (%s)', $locale));
     foreach ($fallbackCatalogues as $fallbackCatalogue) {
         $headers[] = sprintf('Fallback Message Preview (%s)', $fallbackCatalogue->getLocale());
     }
     $rows = array();
     // Iterate all message ids and determine their state
     foreach ($allMessages as $domain => $messages) {
         foreach (array_keys($messages) as $messageId) {
             $value = $currentCatalogue->get($messageId, $domain);
             $states = array();
             if ($extractedCatalogue->defines($messageId, $domain)) {
                 if (!$currentCatalogue->defines($messageId, $domain)) {
                     $states[] = self::MESSAGE_MISSING;
                 }
             } elseif ($currentCatalogue->defines($messageId, $domain)) {
                 $states[] = self::MESSAGE_UNUSED;
             }
             if (!in_array(self::MESSAGE_UNUSED, $states) && true === $input->getOption('only-unused') || !in_array(self::MESSAGE_MISSING, $states) && true === $input->getOption('only-missing')) {
                 continue;
             }
             foreach ($fallbackCatalogues as $fallbackCatalogue) {
                 if ($fallbackCatalogue->defines($messageId, $domain) && $value === $fallbackCatalogue->get($messageId, $domain)) {
                     $states[] = self::MESSAGE_EQUALS_FALLBACK;
                     break;
                 }
             }
             $row = array($this->formatStates($states), $domain, $this->formatId($messageId), $this->sanitizeString($value));
             foreach ($fallbackCatalogues as $fallbackCatalogue) {
                 $row[] = $this->sanitizeString($fallbackCatalogue->get($messageId, $domain));
             }
             $rows[] = $row;
         }
     }
     $io->table($headers, $rows);
 }
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return null
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // Important vars
     $container = $this->getContainer();
     $em = $container->get('doctrine')->getManager();
     $io = new SymfonyStyle($input, $output);
     // API's
     $apiPM = $container->get('spirit_dev_dbox_portal_bundle.api.redmine');
     $apiVCS = $container->get('spirit_dev_dbox_portal_bundle.api.gitlab');
     // Get PM Projects
     $pmProjects = $apiPM->listProjects();
     if ($pmProjects["total_count"] > $pmProjects["limit"]) {
         $pmProjects = $apiPM->listProjects(array("limit" => $pmProjects["total_count"]));
     }
     $pmProjects = $pmProjects["projects"];
     // Get VCS Projects
     $vcsProjects = $apiVCS->listProjects(1, 10000);
     // Get local projects
     $dbProjects = $em->getRepository('SpiritDevDBoxPortalBundle:Project')->findAll();
     // Merge all arrays
     $allProjects = array();
     foreach ($pmProjects as $pm) {
         $allProjects[] = array('name' => $pm['name'], 'type' => 'pm', 'id' => $pm['id']);
     }
     foreach ($vcsProjects as $vcs) {
         $allProjects[] = array('name' => $vcs['name'], 'type' => 'vcs', 'id' => $vcs['id']);
     }
     foreach ($dbProjects as $db) {
         $allProjects[] = array('name' => $db->getName(), 'type' => 'db', 'id' => $db->getId());
     }
     // Shake and shake and shake
     // Fix PM projects (public, modules)
     $pmOnly = array();
     $vsnOnly = array();
     $dbOnly = array();
     $io->title('CHECKING CORRESPONDENCES');
     $globalTableRow = array();
     foreach ($allProjects as $project) {
         $pmPresent = false;
         $vcsPresent = false;
         $dbPresent = false;
         foreach ($pmProjects as $pm) {
             if (strtolower($project['name']) == strtolower($pm['name'])) {
                 $pmPresent = true;
             }
         }
         foreach ($vcsProjects as $vcs) {
             if (strtolower($project['name']) == strtolower($vcs['name'])) {
                 $vcsPresent = true;
             }
         }
         foreach ($dbProjects as $db) {
             if (strtolower($project['name']) == strtolower($db->getName())) {
                 $dbPresent = true;
             }
         }
         $globalTableRow[] = array($project['name'], $project['type'], $project['id'], $pmPresent, $vcsPresent, $dbPresent);
     }
     if (!$input->getOption('resume-only')) {
         $io->section('Global Checkup');
         $io->table(array('Project', 'Type', 'Id', 'PM Present', 'VCS Present', 'DB Present'), $globalTableRow);
     }
     $tmpFocusedTableRow = array();
     foreach ($globalTableRow as $globalRow) {
         $alreadyExists = false;
         foreach ($tmpFocusedTableRow as $focusRow) {
             if (strtolower($focusRow[0]) == strtolower($globalRow[0])) {
                 $alreadyExists = true;
             }
         }
         if (!$alreadyExists && $globalRow[3] && $globalRow[4]) {
             $tmpFocusedTableRow[] = array($globalRow[0], $globalRow[3], $globalRow[4], $globalRow[5]);
         }
     }
     $focusedTableRow = array();
     foreach ($tmpFocusedTableRow as $trow) {
         $pmId = null;
         $pmName = null;
         $vcsId = null;
         $vcsName = null;
         foreach ($globalTableRow as $grow) {
             if (strtolower($grow[0]) == strtolower($trow[0])) {
                 if ($grow[1] == "pm") {
                     $pmId = $grow[2];
                 }
                 $pmName = $grow[0];
                 if ($grow[1] == "vcs") {
                     $vcsId = $grow[2];
                 }
                 $vcsName = $grow[0];
             }
         }
         $focusedTableRow[] = array($trow[0], $trow[1], $pmName, $pmId, $trow[2], $vcsId, $vcsName, $trow[3]);
     }
     $io->section('Focused Checkup');
     $io->table(array('Project', 'PM Present', 'PM ID', 'PM Name', 'VCS Present', 'VCS ID', 'VCS Name', 'DB Present'), $focusedTableRow);
 }
Exemplo n.º 29
0
 /**
  * Shows an information about aspect pointcuts and advisors
  *
  * @param SymfonyStyle $io Input-output style
  * @param Aspect $aspect Instance of aspect to query information
  */
 private function showAspectPointcutsAndAdvisors(SymfonyStyle $io, Aspect $aspect)
 {
     /** @var AspectLoader $aspectLoader */
     $container = $this->aspectKernel->getContainer();
     $aspectLoader = $container->get('aspect.loader');
     $io->writeln('<comment>Pointcuts and advices</comment>');
     $aspectItems = $aspectLoader->load($aspect);
     $aspectItemsInfo = [];
     foreach ($aspectItems as $itemId => $item) {
         $itemType = 'Unknown';
         if ($item instanceof Pointcut) {
             $itemType = 'Pointcut';
         }
         if ($item instanceof Advisor) {
             $itemType = 'Advisor';
         }
         $aspectItemsInfo[] = [$itemType, $itemId];
     }
     $io->table(['Type', 'Identifier'], $aspectItemsInfo);
 }
Exemplo n.º 30
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output = new SymfonyStyle($input, $output);
     if (false !== strpos($input->getFirstArgument(), ':d')) {
         $output->caution('The use of "translation:debug" command is deprecated since version 2.7 and will be removed in 3.0. Use the "debug:translation" instead.');
     }
     $locale = $input->getArgument('locale');
     $domain = $input->getOption('domain');
     $loader = $this->getContainer()->get('translation.loader');
     $kernel = $this->getContainer()->get('kernel');
     // Define Root Path to App folder
     $rootPath = $kernel->getRootDir();
     // Override with provided Bundle info
     if (null !== $input->getArgument('bundle')) {
         try {
             $rootPath = $kernel->getBundle($input->getArgument('bundle'))->getPath();
         } catch (\InvalidArgumentException $e) {
             // such a bundle does not exist, so treat the argument as path
             $rootPath = $input->getArgument('bundle');
             if (!is_dir($rootPath)) {
                 throw new \InvalidArgumentException(sprintf('"%s" is neither an enabled bundle nor a directory.', $rootPath));
             }
         }
     }
     // get bundle directory
     $translationsPath = $rootPath . '/Resources/translations';
     // Extract used messages
     $extractedCatalogue = new MessageCatalogue($locale);
     if (is_dir($rootPath . '/Resources/views')) {
         $this->getContainer()->get('translation.extractor')->extract($rootPath . '/Resources/views', $extractedCatalogue);
     }
     // Load defined messages
     $currentCatalogue = new MessageCatalogue($locale);
     if (is_dir($translationsPath)) {
         $loader->loadMessages($translationsPath, $currentCatalogue);
     }
     // Merge defined and extracted messages to get all message ids
     $mergeOperation = new MergeOperation($extractedCatalogue, $currentCatalogue);
     $allMessages = $mergeOperation->getResult()->all($domain);
     if (null !== $domain) {
         $allMessages = array($domain => $allMessages);
     }
     // No defined or extracted messages
     if (empty($allMessages) || null !== $domain && empty($allMessages[$domain])) {
         $outputMessage = sprintf('No defined or extracted messages for locale "%s"', $locale);
         if (null !== $domain) {
             $outputMessage .= sprintf(' and domain "%s"', $domain);
         }
         $output->warning($outputMessage);
         return;
     }
     // Load the fallback catalogues
     $fallbackCatalogues = array();
     $translator = $this->getContainer()->get('translator');
     if ($translator instanceof Translator) {
         foreach ($translator->getFallbackLocales() as $fallbackLocale) {
             if ($fallbackLocale === $locale) {
                 continue;
             }
             $fallbackCatalogue = new MessageCatalogue($fallbackLocale);
             $loader->loadMessages($translationsPath, $fallbackCatalogue);
             $fallbackCatalogues[] = $fallbackCatalogue;
         }
     }
     // Display header line
     $headers = array('State', 'Domain', 'Id', sprintf('Message Preview (%s)', $locale));
     foreach ($fallbackCatalogues as $fallbackCatalogue) {
         $headers[] = sprintf('Fallback Message Preview (%s)', $fallbackCatalogue->getLocale());
     }
     $rows = array();
     // Iterate all message ids and determine their state
     foreach ($allMessages as $domain => $messages) {
         foreach (array_keys($messages) as $messageId) {
             $value = $currentCatalogue->get($messageId, $domain);
             $states = array();
             if ($extractedCatalogue->defines($messageId, $domain)) {
                 if (!$currentCatalogue->defines($messageId, $domain)) {
                     $states[] = self::MESSAGE_MISSING;
                 }
             } elseif ($currentCatalogue->defines($messageId, $domain)) {
                 $states[] = self::MESSAGE_UNUSED;
             }
             if (!in_array(self::MESSAGE_UNUSED, $states) && true === $input->getOption('only-unused') || !in_array(self::MESSAGE_MISSING, $states) && true === $input->getOption('only-missing')) {
                 continue;
             }
             foreach ($fallbackCatalogues as $fallbackCatalogue) {
                 if ($fallbackCatalogue->defines($messageId, $domain) && $value === $fallbackCatalogue->get($messageId, $domain)) {
                     $states[] = self::MESSAGE_EQUALS_FALLBACK;
                     break;
                 }
             }
             $row = array($this->formatStates($states), $domain, $this->formatId($messageId), $this->sanitizeString($value));
             foreach ($fallbackCatalogues as $fallbackCatalogue) {
                 $row[] = $this->sanitizeString($fallbackCatalogue->get($messageId, $domain));
             }
             $rows[] = $row;
         }
     }
     $output->table($headers, $rows);
 }