Commit 8a6e8b06 authored by jmolivas's avatar jmolivas Committed by lussoluca

Issue #2840230 by jmolivas: Register DrupalConsole commands as services

parent 5b1ac46e
commands:
webprofiler:
export:
description: Exports Webprofiler profile/s to file.
arguments:
id: Profile id.
options:
directory: Destination directory to store exported file/s.
messages:
success: Succesfully exported to %s
exported_count: <info>Exported %s profiles</info>
error_writing: Error writing file %s
error_no_profile: No profile with id %s
progress:
exporting: Exporting profiles...
archive: Create archive...
delete_tmp: Delete temp files...
done: Done.
list:
description: Lists Webprofiler profiles.
options:
ip: Filter by IP.
url: Filter by URL.
method: Filter by HTTP method.
limit: Limit printed profiles.
rows:
time: D, m/d/Y - H:i:s
header:
token: Token
ip: IP
method: Method
url: URL
time: Time
benchmark:
description: Benchmark an url.
arguments:
url: Url to benchmark.
options:
runs: Number of runs.
file: Save results as file.
cache-rebuild: Rebuild cache before start benchmark.
messages:
not_git: Not in a git repository.
error_login: Impossibile to login in the user.
progress:
cache_rebuild: Rebuilding cache...
login: Login user...
get: Http request...
compute_avg: Compute average...
compute_median: Compute median...
compute_95percentile: Compute 95 percentile...
git_hash: Compute GIT hash...
yaml: Generate output...
done: Done.
commands:
webprofiler:
export:
description: Exportar Webprofiler perfil(es) a un archivo.
arguments:
id: Profile id.
options:
directory: Directorio de destiono para almacenar archivo(s) exportados.
messages:
success: Satisfactoriamente exportado en %s
exported_count: <info>Exportados %s perfiles</info>
error_writing: Error escribiendo el archivo %s
error_no_profile: No fue encontrado un perfil con id %s
progress:
exporting: Exportando perfiles...
archive: Creando archivos...
delete_tmp: Borrando archivos temporales...
done: Terminado.
list:
description: Listar perfiles Webprofiler.
options:
ip: Filtrar por IP.
url: Filtrar por URL.
method: Filtrar por método HTTP.
limit: Limitar perfiles a mostrar.
rows:
time: D, d/m/Y - H:i:s
header:
token: Token
ip: IP
method: Método
url: URL
time: Fecha
benchmark:
description: Benchmark una URL.
arguments:
url: Url para efectuar un benchmark.
options:
runs: Número de ejecuciones.
file: Guardar los resultados en un archivo.
cache-rebuild: Reconstruir cache antes de iniciar el benchmark.
messages:
not_git: No en un repositorio git.
error_login: Error ingresando al sistema.
progress:
cache_rebuild: Reconstruyendo cache...
login: Ingresando al sistema...
get: Solicitud Http...
compute_avg: Calculando promedio...
compute_median: Calculando media...
compute_95percentile: Calculando percentile 95...
git_hash: Calculando GIT hash...
yaml: Generando salida...
done: Terminado.
services:
webprofiler.list:
class: Drupal\webprofiler\Command\ListCommand
tags:
- { name: drupal.command }
lazy: true
webprofiler.export:
class: Drupal\webprofiler\Command\ExportCommand
tags:
- { name: drupal.command }
webprofiler.benchmark:
class: Drupal\webprofiler\Command\BenchmarkCommand
tags:
- { name: drupal.command }
description: Benchmark an url.
arguments:
url: Url to benchmark.
options:
runs: Number of runs.
file: Save results as file.
cache-rebuild: Rebuild cache before start benchmark.
messages:
not_git: Not in a git repository.
error_login: Impossibile to login in the user.
progress:
cache_rebuild: Rebuilding cache...
login: Login user...
get: Http request...
compute_avg: Compute average...
compute_median: Compute median...
compute_95percentile: Compute 95 percentile...
git_hash: Compute GIT hash...
yaml: Generate output...
done: Done.
description: Exports Webprofiler profile/s to file.
arguments:
id: Profile id.
options:
directory: Destination directory to store exported file/s.
messages:
success: Succesfully exported to %s
exported_count: <info>Exported %s profiles</info>
error_writing: Error writing file %s
error_no_profile: No profile with id %s
progress:
exporting: Exporting profiles...
archive: Create archive...
delete_tmp: Delete temp files...
done: Done.
description: Lists Webprofiler profiles.
options:
ip: Filter by IP.
url: Filter by URL.
method: Filter by HTTP method.
limit: Limit printed profiles.
rows:
time: D, m/d/Y - H:i:s
header:
token: Token
ip: IP
method: Method
url: URL
time: Time
description: Benchmark una URL.
arguments:
url: Url para efectuar un benchmark.
options:
runs: Número de ejecuciones.
file: Guardar los resultados en un archivo.
cache-rebuild: Reconstruir cache antes de iniciar el benchmark.
messages:
not_git: No en un repositorio git.
error_login: Error ingresando al sistema.
progress:
cache_rebuild: Reconstruyendo cache...
login: Ingresando al sistema...
get: Solicitud Http...
compute_avg: Calculando promedio...
compute_median: Calculando media...
compute_95percentile: Calculando percentile 95...
git_hash: Calculando GIT hash...
yaml: Generando salida...
done: Terminado.
description: Exportar Webprofiler perfil(es) a un archivo.
arguments:
id: Profile id.
options:
directory: Directorio de destiono para almacenar archivo(s) exportados.
messages:
success: Satisfactoriamente exportado en %s
exported_count: <info>Exportados %s perfiles</info>
error_writing: Error escribiendo el archivo %s
error_no_profile: No fue encontrado un perfil con id %s
progress:
exporting: Exportando perfiles...
archive: Creando archivos...
delete_tmp: Borrando archivos temporales...
done: Terminado.
description: Listar perfiles Webprofiler.
options:
ip: Filtrar por IP.
url: Filtrar por URL.
method: Filtrar por método HTTP.
limit: Limitar perfiles a mostrar.
rows:
time: D, d/m/Y - H:i:s
header:
token: Token
ip: IP
method: Método
url: URL
time: Fecha
......@@ -9,15 +9,24 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Drupal\Console\Command\ContainerAwareCommand;
use Drupal\Console\Core\Command\Shared\ContainerAwareCommandTrait;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\DomCrawler\Crawler;
use Symfony\Component\Process\Process;
use Symfony\Component\Yaml\Yaml;
use Drupal\Console\Annotations\DrupalCommand;
/**
* Class BenchmarkCommand
*
* @DrupalCommand (
* extension="webprofiler",
* extensionType="module"
* )
*/
class BenchmarkCommand extends ContainerAwareCommand {
class BenchmarkCommand extends Command {
use ContainerAwareCommandTrait;
/**
* {@inheritdoc}
......@@ -56,7 +65,7 @@ class BenchmarkCommand extends ContainerAwareCommand {
}
/** @var \Drupal\Core\Http\Client $client */
$client = $this->getContainer()->get('http_client');
$client = $this->container->get('http_client');
$progress = new ProgressBar($output, $runs + $steps);
$progress->setFormat(' %current%/%max% [%bar%] %percent:3s%% %message%');
......@@ -152,7 +161,7 @@ class BenchmarkCommand extends ContainerAwareCommand {
$token = $response->getHeader('X-Debug-Token');
/** @var \Drupal\webprofiler\Profiler\Profiler $profiler */
$profiler = $this->getContainer()->get('profiler');
$profiler = $this->container->get('profiler');
/** @var \Symfony\Component\HttpKernel\Profiler\Profile $profile */
$profile = $profiler->loadProfile($token);
......
......@@ -2,19 +2,28 @@
namespace Drupal\webprofiler\Command;
use Drupal\Console\Command\ContainerAwareCommand;
use Drupal\Console\Core\Command\Shared\ContainerAwareCommandTrait;
use Drupal\Core\Archiver\ArchiveTar;
use Drupal\webprofiler\Profiler\Profiler;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Output\OutputInterface;
use Drupal\Console\Annotations\DrupalCommand;
/**
* Class ExportCommand
*
* @DrupalCommand (
* extension="webprofiler",
* extensionType="module"
* )
*/
class ExportCommand extends ContainerAwareCommand {
class ExportCommand extends Command {
use ContainerAwareCommandTrait;
/** @var string */
private $filename;
......@@ -38,7 +47,7 @@ class ExportCommand extends ContainerAwareCommand {
$directory = $input->getOption('directory');
/** @var \Drupal\webprofiler\Profiler\Profiler $profiler */
$profiler = $this->getContainer()->get('profiler');
$profiler = $this->container->get('profiler');
try {
if ($id) {
......
......@@ -2,16 +2,25 @@
namespace Drupal\webprofiler\Command;
use Drupal\Console\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Drupal\Console\Core\Command\Shared\ContainerAwareCommandTrait;
use Drupal\Console\Annotations\DrupalCommand;
/**
* Class ListCommand
**
* @DrupalCommand (
* extension="webprofiler",
* extensionType="module"
* )
*/
class ListCommand extends ContainerAwareCommand {
class ListCommand extends Command {
use ContainerAwareCommandTrait;
/**
* {@inheritdoc}
......@@ -36,7 +45,7 @@ class ListCommand extends ContainerAwareCommand {
$limit = $input->getOption('limit');
/** @var \Drupal\webprofiler\Profiler\Profiler $profiler */
$profiler = $this->getContainer()->get('profiler');
$profiler = $this->container->get('profiler');
$profiles = $profiler->find($ip, $url, $limit, $method, '', '');
$rows = [];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment