本文整理汇总了PHP中Symfony\Component\Console\Helper\Table类的典型用法代码示例。如果您正苦于以下问题:PHP Table类的具体用法?PHP Table怎么用?PHP Table使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Table类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->ensureExtensionLoaded('apc');
$regexp = $input->getArgument('regexp');
$user = $this->getCacheTool()->apc_cache_info('user');
$keys = array();
foreach ($user['cache_list'] as $key) {
$string = $key['info'];
if (preg_match('|' . $regexp . '|', $string)) {
$keys[] = $key;
}
}
$cpt = 0;
$table = new Table($output);
$table->setHeaders(array('Key', 'TTL'));
$table->setRows($keys);
$table->render($output);
foreach ($keys as $key) {
$success = $this->getCacheTool()->apc_delete($key['info']);
if ($output->isVerbose()) {
if ($success) {
$output->writeln("<comment>APC key <info>{$key['info']}</info> was deleted</comment>");
} else {
$output->writeln("<comment>APC key <info>{$key['info']}</info> could not be deleted.</comment>");
}
}
$cpt++;
}
if ($output->isVerbose()) {
$output->writeln("<comment>APC key <info>{$cpt}</info> keys treated.</comment>");
}
return 1;
}
示例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
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));
}
示例4: 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;
}
示例5: execute
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;
}
示例6: execute
/**
* @{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();
}
示例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
/**
* @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>');
}
}
示例9: 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();
}
示例10: execute
public function execute(InputInterface $input, OutputInterface $output)
{
$this->addStyles($output);
$suite = $input->getArgument('suite');
$config = $this->getSuiteConfig($suite, $input->getOption('config'));
$config['describe_steps'] = true;
$loader = new Gherkin($config);
$steps = $loader->getSteps();
foreach ($steps as $name => $context) {
/** @var $table Table **/
$table = new Table($output);
$table->setHeaders(array('Step', 'Implementation'));
$output->writeln("Steps from <bold>{$name}</bold> context:");
foreach ($context as $step => $callable) {
if (count($callable) < 2) {
continue;
}
$method = $callable[0] . '::' . $callable[1];
$table->addRow([$step, $method]);
}
$table->render();
}
if (!isset($table)) {
$output->writeln("No steps are defined, start creating them by running <bold>gherkin:snippets</bold>");
}
}
示例11: execute
/**
* @param InputInterface $input
* @param OutputInterface $output
*
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$channel = $input->getOption('channel');
$channelId = $input->getOption('id');
$key = $channel . $channelId;
if (!$this->checkRunStatus($input, $output, empty($key) ? 'all' : $key)) {
return 0;
}
$translator = $this->getContainer()->get('translator');
$translator->setLocale($this->getContainer()->get('mautic.helper.core_parameters')->getParameter('locale'));
$dispatcher = $this->getContainer()->get('event_dispatcher');
$event = $dispatcher->dispatch(CoreEvents::CHANNEL_BROADCAST, new ChannelBroadcastEvent($channel, $channelId, $output));
$results = $event->getResults();
$rows = [];
foreach ($results as $channel => $counts) {
$rows[] = [$channel, $counts['success'], $counts['failed']];
}
// Put a blank line after anything the event spits out
$output->writeln('');
$output->writeln('');
$table = new Table($output);
$table->setHeaders([$translator->trans('mautic.core.channel'), $translator->trans('mautic.core.channel.broadcast_success_count'), $translator->trans('mautic.core.channel.broadcast_failed_count')])->setRows($rows);
$table->render();
$this->completeRun();
return 0;
}
示例12: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$language = $input->getArgument('language');
$table = new Table($output);
$table->setStyle('compact');
$this->displayUpdates($language, $output, $table);
}
示例13: 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();
}
示例14: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$isVerbose = $output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE;
$projectCode = $input->getOption('project-code');
$enrollmentStatusCode = $input->getOption('enrollment-status-code');
$memberResource = new MemberResource($this->sourceClient);
$page = 0;
$perPage = 10;
$maxPages = 1;
$criteria = [];
if ($enrollmentStatusCode) {
$criteria['enrollment_status_code'] = $enrollmentStatusCode;
}
$data = [];
while ($page < $maxPages) {
$members = $memberResource->getList(++$page, $perPage, $criteria, [], [], ['project_code' => $projectCode]);
$maxPages = $members['pages'];
// if no items, return
if (!count($members['items']) || !$members['total']) {
break;
}
foreach ($members['items'] as $key => $member) {
if ($isVerbose) {
$no = ($page - 1) * $perPage + $key + 1;
// $output->writeln("{$no} - Reading member #{$member['id']}");
}
$data[] = ['code' => isset($member['code']) ? $member['code'] : '#' . $member['id'], 'email' => isset($member['email_within_project']) ? $member['email_within_project'] : '-', 'phone' => isset($member['phone_within_project']) ? $member['phone_within_project'] : '-', 'enrollment_status_code' => isset($member['enrollment_status_code']) ? $member['enrollment_status_code'] : '-'];
}
}
$table = new Table($output);
$table->setHeaders(['code', 'email', 'phone', 'enrollment_status_code'])->setRows($data);
$table->render();
}
示例15: execute
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();
}
}