本文整理汇总了PHP中Symfony\Component\Console\Helper\Table::setHeaders方法的典型用法代码示例。如果您正苦于以下问题:PHP Table::setHeaders方法的具体用法?PHP Table::setHeaders怎么用?PHP Table::setHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Helper\Table
的用法示例。
在下文中一共展示了Table::setHeaders方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* {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();
}
示例2: render
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();
}
示例3: _execute
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();
}
示例4: execute
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']);
}
示例5: execute
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();
}
示例6: test
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);
}
示例7: execute
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();
}
示例8: printRecievers
/**
* @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([]);
}
示例9: table
/**
* 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();
}
}
示例10: checkRequirements
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;
}
示例11: execute
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>");
}
}
示例12: execute
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();
}
示例13: installThemeFiles
/**
* 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();
}
}
示例14: execute
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();
}
示例15: execute
/**
* {@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();
}
}