本文整理汇总了PHP中Symfony\Component\Console\Helper\Table::addRow方法的典型用法代码示例。如果您正苦于以下问题:PHP Table::addRow方法的具体用法?PHP Table::addRow怎么用?PHP Table::addRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Helper\Table
的用法示例。
在下文中一共展示了Table::addRow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: execute
/**
* {@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();
}
示例3: 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();
}
示例4: _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();
}
示例5: writeItem
/**
* Write the given item.
*
* @param mixed $item
*/
public function writeItem($item)
{
if ($this->autoDetectHeader && !$this->header) {
$this->handleAutoDetectHeader($item);
}
$this->table->addRow($this->getValues($item, $this->getKeys($item)));
}
示例6: renderReport
/**
* This method will be called when the engine has finished the source analysis
* phase.
*
* @param \PHPMD\Report $report
*/
public function renderReport(Report $report)
{
$this->output->writeln('');
$groupByFile = [];
/** @var RuleViolation $violation */
foreach ($report->getRuleViolations() as $violation) {
$groupByFile[$violation->getFileName()][] = $violation;
}
/** @var ProcessingError $error */
foreach ($report->getErrors() as $error) {
$groupByFile[$error->getFile()][] = $error;
}
foreach ($groupByFile as $file => $problems) {
$violationCount = 0;
$errorCount = 0;
$table = new Table($this->output);
$table->setStyle('borderless');
foreach ($problems as $problem) {
if ($problem instanceof RuleViolation) {
$table->addRow([$problem->getBeginLine(), '<comment>VIOLATION</comment>', $problem->getDescription()]);
++$violationCount;
}
if ($problem instanceof ProcessingError) {
$table->addRow(['-', '<error>ERROR</error>', $problem->getMessage()]);
++$errorCount;
}
}
$this->output->writeln([sprintf('<fg=white;options=bold>FILE: %s</>', str_replace($this->basePath . '/', '', $file)), sprintf('<fg=white;options=bold>FOUND %d ERRORS AND %d VIOLATIONS</>', $errorCount, $violationCount)]);
$table->render();
$this->output->writeln('');
}
}
示例7: 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();
}
}
示例8: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$reader = new AnnotationReader();
/** @var ManagerRegistry $doctrine */
$doctrine = $this->getContainer()->get('doctrine');
$em = $doctrine->getManager();
$cmf = $em->getMetadataFactory();
$existing = [];
$created = [];
/** @var ClassMetadata $metadata */
foreach ($cmf->getAllMetadata() as $metadata) {
$refl = $metadata->getReflectionClass();
if ($refl === null) {
$refl = new \ReflectionClass($metadata->getName());
}
if ($reader->getClassAnnotation($refl, 'Padam87\\AttributeBundle\\Annotation\\Entity') != null) {
$schema = $em->getRepository('Padam87AttributeBundle:Schema')->findOneBy(['className' => $metadata->getName()]);
if ($schema === null) {
$schema = new Schema();
$schema->setClassName($metadata->getName());
$em->persist($schema);
$em->flush($schema);
$created[] = $metadata->getName();
} else {
$existing[] = $metadata->getName();
}
}
}
$table = new Table($output);
$table->addRow(['Created:', implode(PHP_EOL, $created)]);
$table->addRow(new TableSeparator());
$table->addRow(['Existing:', implode(PHP_EOL, $existing)]);
$table->render();
}
示例9: write
/**
*
* {@inheritDoc}
*
* @see \SK\ITCBundle\Service\Table\Adapter\IAdapter::write()
*/
public function write(Table $table, OutputInterface $output)
{
$style = new TableStyle();
$style->setHorizontalBorderChar('<fg=magenta>-</>')->setVerticalBorderChar('<fg=magenta>|</>')->setCrossingChar('<fg=magenta>+</>');
$stable = new STable($output);
$stable->setStyle('default');
$stable->setHeaders($table->getHeaders());
$columns = $table->getColumns();
$colspan = count($columns);
$rows = $table->getRows();
foreach ($rows as $row) {
$rowModificated = [];
foreach ($columns as $iCol => $col) {
if (is_int($iCol)) {
$iCol = $col;
}
if (array_key_exists($iCol, $row)) {
$rowModificated[$iCol] = wordwrap($row[$iCol], $table->getMaxColWidth(), "\n", true);
} else {
$rowModificated[$iCol] = "";
}
}
$stable->addRow($rowModificated);
$stable->addRow(array(new TableSeparator(array('colspan' => $colspan))));
}
$stable->addRow(array(new TableCell("", array('colspan' => $colspan))));
$stable->addRow(array(new TableCell(sprintf("Found %s results.", count($rows)), array('colspan' => $colspan))));
$stable->render();
}
示例10: execute
/**
* Execute command
*
* @param InputInterface $input Input instance
* @param OutputInterface $output Output instance
*
* @return int|null|void
*/
public function execute(InputInterface $input, OutputInterface $output)
{
$this->elevateProcess($input, $output);
$procList = array();
$openFilesTotal = 0;
$command = new CommandBuilder('lsof', '-n');
$command->addPipeCommand(new CommandBuilder('grep', '-oE \'^[a-z]+\''))->addPipeCommand(new CommandBuilder('sort'))->addPipeCommand(new CommandBuilder('uniq', '-c'))->addPipeCommand(new CommandBuilder('sort', '-n'))->setOutputRedirect(CommandBuilder::OUTPUT_REDIRECT_NO_STDERR);
$execOutput = $command->execute()->getOutput();
foreach ($execOutput as $execOutputLine) {
// get open files and proc name from output
list($procOpenFiles, $procName) = explode(' ', trim($execOutputLine), 2);
// add to total stats
$openFilesTotal += $procOpenFiles;
$procList[] = array('name' => $procName, 'open_files' => $procOpenFiles);
}
// ########################
// Output
// ########################
/** @var \Symfony\Component\Console\Helper\Table $table */
$table = new Table($output);
$table->setHeaders(array('Process', 'Open Files'));
foreach ($procList as $procRow) {
$procRow['open_files'] = FormatUtility::number($procRow['open_files']);
$table->addRow(array_values($procRow));
}
// Stats: average
$table->addRow(new TableSeparator());
$statsRow = array();
$statsRow['name'] = 'Total';
$statsRow['open_files'] = FormatUtility::number($openFilesTotal);
$table->addRow(array_values($statsRow));
$table->render();
return 0;
}
示例11: dumpProcessors
/**
* @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();
}
示例12: execute
/**
* @param InputInterface $input
* @param OutputInterface $output
* @return void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$project = new Project(getcwd());
if ($project->isValid()) {
$book = $project->getBook($input->getArgument('name'), $input->getOption('locale'));
if ($book instanceof Book) {
$table = new Table($output);
$table->setHeaders(['Property', 'Value']);
$table->addRow(['Short Name', $book->getShortName()]);
$table->addRow(['Title', $book->getTitle()]);
$pages = $book->getPages();
if ($pages->count() > 0) {
$page_titles = [];
foreach ($pages as $page) {
$page_titles[] = $page->getTitle();
}
$table->addRow(['Pages', implode("\n", $page_titles)]);
} else {
$table->addRow(['Pages', '--']);
}
$table->render();
} else {
$output->writeln('<error>Book "' . $input->getArgument('name') . ' not found"</error>');
}
} else {
$output->writeln('<error>This is not a valid Shade project</error>');
}
}
示例13: interact
/**
*
* TODO Provide extensibility to list of Sugar 7 boxes (allow hard coding, usage of a web service, etc.)
* {inheritDoc}
*/
protected function interact(InputInterface $input, OutputInterface $output)
{
$box = $input->getArgument('box');
if (empty($box)) {
$output->writeln('You MUST provide a <info>Vagrant Box Name</info> for your Sugar instance.');
$output->writeln('<comment>You may pick one from below OR provide your own.</comment>');
$table = new Table($output);
$table->setHeaders(array('Box Name', 'PHP', 'Apache', 'MySQL', 'Elasticsearch', 'OS'));
$table->addRow(['mmarum/sugar7-php54', '5.4.x', '2.2.x', '5.5.x', '1.4.x', 'Ubuntu 12.04']);
$table->addRow(['mmarum/sugar7-php53', '5.3.x', '2.2.x', '5.5.x', '1.4.x', 'Ubuntu 12.04']);
$table->render();
$helper = $this->getHelper('question');
$question = new Question('<info>Name of Vagrant Box?</info> <comment>[mmarum/sugar7-php54]</comment> ', 'mmarum/sugar7-php54');
$question->setValidator(function ($answer) {
if (empty($answer)) {
throw new \RuntimeException('You must provide a Box Name to continue!');
}
return $answer;
});
$question->setMaxAttempts(2);
$box = $helper->ask($input, $output, $question);
$input->setArgument('box', $box);
}
$output->writeln("<info>Using {$box} ...</info>");
}
示例14: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
try {
$source = $input->getArgument('source');
if (!is_file($source) || !$this->isJpegImage($source)) {
throw new \Exception(sprintf('Invalid jpeg file %s', $source));
}
$exif = exif_read_data($source);
$formatter = $this->getHelper('formatter');
$formattedLine = $formatter->formatSection('Exif data', $source);
$output->writeln($formattedLine);
$table = new Table($output);
$table->setHeaders(array('Name', 'Value'));
foreach ($exif as $clave => $sección) {
if (is_array($sección)) {
foreach ($sección as $name => $value) {
$table->addRow(array($name, $value));
}
} else {
$table->addRow(array($clave, $sección));
}
}
$table->render();
} catch (\Exception $e) {
$output->writeln('<error>' . $e->getMessage() . '</error>');
return 1;
}
return 0;
}
示例15: 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();
}