3 namespace Drupal\webprofiler\Command;
5 use Symfony\Component\Console\Command\Command;
6 use Symfony\Component\Console\Helper\Table;
7 use Symfony\Component\Console\Input\InputInterface;
8 use Symfony\Component\Console\Input\InputOption;
9 use Symfony\Component\Console\Output\OutputInterface;
10 use Drupal\Console\Core\Command\Shared\ContainerAwareCommandTrait;
11 use Drupal\Console\Annotations\DrupalCommand;
17 * extension="webprofiler",
18 * extensionType="module"
21 class ListCommand extends Command {
23 use ContainerAwareCommandTrait;
28 protected function configure() {
30 ->setName('webprofiler:list')
31 ->setDescription($this->trans('commands.webprofiler.list.description'))
32 ->addOption('ip', NULL, InputOption::VALUE_REQUIRED, $this->trans('commands.webprofiler.list.options.ip'), NULL)
33 ->addOption('url', NULL, InputOption::VALUE_REQUIRED, $this->trans('commands.webprofiler.list.options.url'), NULL)
34 ->addOption('method', NULL, InputOption::VALUE_REQUIRED, $this->trans('commands.webprofiler.list.options.method'), NULL)
35 ->addOption('limit', NULL, InputOption::VALUE_REQUIRED, $this->trans('commands.webprofiler.list.options.limit'), 10);
41 protected function execute(InputInterface $input, OutputInterface $output) {
42 $ip = $input->getOption('ip');
43 $url = $input->getOption('url');
44 $method = $input->getOption('method');
45 $limit = $input->getOption('limit');
47 /** @var \Drupal\webprofiler\Profiler\Profiler $profiler */
48 $profiler = $this->container->get('profiler');
49 $profiles = $profiler->find($ip, $url, $limit, $method, '', '');
52 foreach ($profiles as $profile) {
55 $row[] = $profile['token'];
56 $row[] = $profile['ip'];
57 $row[] = $profile['method'];
58 $row[] = $profile['url'];
59 $row[] = date($this->trans('commands.webprofiler.list.rows.time'), $profile['time']);
64 $table = new Table($output);
67 $this->trans('commands.webprofiler.list.header.token'),
68 $this->trans('commands.webprofiler.list.header.ip'),
69 $this->trans('commands.webprofiler.list.header.method'),
70 $this->trans('commands.webprofiler.list.header.url'),
71 $this->trans('commands.webprofiler.list.header.time'),
80 public function showMessage($output, $message, $type = 'info') {