X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fdevel%2Fwebprofiler%2Fsrc%2FCommand%2FListCommand.php;fp=web%2Fmodules%2Fcontrib%2Fdevel%2Fwebprofiler%2Fsrc%2FCommand%2FListCommand.php;h=29f4d8fe7b33751272b6dd1d16ca52925a399ae6;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/modules/contrib/devel/webprofiler/src/Command/ListCommand.php b/web/modules/contrib/devel/webprofiler/src/Command/ListCommand.php new file mode 100644 index 000000000..29f4d8fe7 --- /dev/null +++ b/web/modules/contrib/devel/webprofiler/src/Command/ListCommand.php @@ -0,0 +1,82 @@ +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') { + } +}