class ListCommand in Devel 8
Same name in this branch
- 8 webprofiler/src/Command/ListCommand.php \Drupal\webprofiler\Command\ListCommand
- 8 webprofiler/src/ProxyClass/Command/ListCommand.php \Drupal\webprofiler\ProxyClass\Command\ListCommand
Same name and namespace in other branches
- 8.3 webprofiler/src/Command/ListCommand.php \Drupal\webprofiler\Command\ListCommand
- 8.2 webprofiler/src/Command/ListCommand.php \Drupal\webprofiler\Command\ListCommand
- 4.x webprofiler/src/Command/ListCommand.php \Drupal\webprofiler\Command\ListCommand
Class ListCommand * @DrupalCommand ( extension="webprofiler", extensionType="module" )
Hierarchy
- class \Drupal\webprofiler\Command\ListCommand extends \Symfony\Component\Console\Command\Command uses \Drupal\Console\Core\Command\Shared\ContainerAwareCommandTrait
Expanded class hierarchy of ListCommand
1 string reference to 'ListCommand'
- console.services.yml in webprofiler/
console.services.yml - webprofiler/console.services.yml
1 service uses ListCommand
File
- webprofiler/
src/ Command/ ListCommand.php, line 21
Namespace
Drupal\webprofiler\CommandView source
class ListCommand extends Command {
use ContainerAwareCommandTrait;
/**
* {@inheritdoc}
*/
protected function configure() {
$this
->setName('webprofiler:list')
->setDescription($this
->trans('commands.webprofiler.list.description'))
->addOption('ip', NULL, InputOption::VALUE_REQUIRED, $this
->trans('commands.webprofiler.list.options.ip'), NULL)
->addOption('url', NULL, InputOption::VALUE_REQUIRED, $this
->trans('commands.webprofiler.list.options.url'), NULL)
->addOption('method', NULL, InputOption::VALUE_REQUIRED, $this
->trans('commands.webprofiler.list.options.method'), NULL)
->addOption('limit', NULL, InputOption::VALUE_REQUIRED, $this
->trans('commands.webprofiler.list.options.limit'), 10);
}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output) {
$ip = $input
->getOption('ip');
$url = $input
->getOption('url');
$method = $input
->getOption('method');
$limit = $input
->getOption('limit');
/** @var \Drupal\webprofiler\Profiler\Profiler $profiler */
$profiler = $this->container
->get('profiler');
$profiles = $profiler
->find($ip, $url, $limit, $method, '', '');
$rows = [];
foreach ($profiles as $profile) {
$row = [];
$row[] = $profile['token'];
$row[] = $profile['ip'];
$row[] = $profile['method'];
$row[] = $profile['url'];
$row[] = date($this
->trans('commands.webprofiler.list.rows.time'), $profile['time']);
$rows[] = $row;
}
$table = new Table($output);
$table
->setHeaders([
$this
->trans('commands.webprofiler.list.header.token'),
$this
->trans('commands.webprofiler.list.header.ip'),
$this
->trans('commands.webprofiler.list.header.method'),
$this
->trans('commands.webprofiler.list.header.url'),
$this
->trans('commands.webprofiler.list.header.time'),
])
->setRows($rows);
$table
->render();
}
/**
* {@inheritdoc}
*/
public function showMessage($output, $message, $type = 'info') {
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ListCommand:: |
protected | function | Configures the current command. | |
ListCommand:: |
protected | function | Executes the current command. | |
ListCommand:: |
public | function |