[WebServerBundle] Prevent commands from being registered by convention
This commit is contained in:
parent
d484f7282a
commit
57b7d832d9
@ -29,6 +29,8 @@ class ServerLogCommand extends Command
|
|||||||
private $el;
|
private $el;
|
||||||
private $handler;
|
private $handler;
|
||||||
|
|
||||||
|
protected static $defaultName = 'server:log';
|
||||||
|
|
||||||
public function isEnabled()
|
public function isEnabled()
|
||||||
{
|
{
|
||||||
if (!class_exists(ConsoleFormatter::class)) {
|
if (!class_exists(ConsoleFormatter::class)) {
|
||||||
@ -40,8 +42,6 @@ class ServerLogCommand extends Command
|
|||||||
|
|
||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this->setName('server:log');
|
|
||||||
|
|
||||||
if (!class_exists(ConsoleFormatter::class)) {
|
if (!class_exists(ConsoleFormatter::class)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,8 @@ class ServerRunCommand extends ServerCommand
|
|||||||
private $documentRoot;
|
private $documentRoot;
|
||||||
private $environment;
|
private $environment;
|
||||||
|
|
||||||
|
protected static $defaultName = 'server:run';
|
||||||
|
|
||||||
public function __construct($documentRoot = null, $environment = null)
|
public function __construct($documentRoot = null, $environment = null)
|
||||||
{
|
{
|
||||||
$this->documentRoot = $documentRoot;
|
$this->documentRoot = $documentRoot;
|
||||||
@ -50,7 +52,6 @@ class ServerRunCommand extends ServerCommand
|
|||||||
new InputOption('docroot', 'd', InputOption::VALUE_REQUIRED, 'Document root, usually where your front controllers are stored'),
|
new InputOption('docroot', 'd', InputOption::VALUE_REQUIRED, 'Document root, usually where your front controllers are stored'),
|
||||||
new InputOption('router', 'r', InputOption::VALUE_REQUIRED, 'Path to custom router script'),
|
new InputOption('router', 'r', InputOption::VALUE_REQUIRED, 'Path to custom router script'),
|
||||||
))
|
))
|
||||||
->setName('server:run')
|
|
||||||
->setDescription('Runs a local web server')
|
->setDescription('Runs a local web server')
|
||||||
->setHelp(<<<'EOF'
|
->setHelp(<<<'EOF'
|
||||||
<info>%command.name%</info> runs a local web server: By default, the server
|
<info>%command.name%</info> runs a local web server: By default, the server
|
||||||
|
@ -30,6 +30,8 @@ class ServerStartCommand extends ServerCommand
|
|||||||
private $documentRoot;
|
private $documentRoot;
|
||||||
private $environment;
|
private $environment;
|
||||||
|
|
||||||
|
protected static $defaultName = 'server:start';
|
||||||
|
|
||||||
public function __construct($documentRoot = null, $environment = null)
|
public function __construct($documentRoot = null, $environment = null)
|
||||||
{
|
{
|
||||||
$this->documentRoot = $documentRoot;
|
$this->documentRoot = $documentRoot;
|
||||||
@ -44,7 +46,6 @@ class ServerStartCommand extends ServerCommand
|
|||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setName('server:start')
|
|
||||||
->setDefinition(array(
|
->setDefinition(array(
|
||||||
new InputArgument('addressport', InputArgument::OPTIONAL, 'The address to listen to (can be address:port, address, or port)'),
|
new InputArgument('addressport', InputArgument::OPTIONAL, 'The address to listen to (can be address:port, address, or port)'),
|
||||||
new InputOption('docroot', 'd', InputOption::VALUE_REQUIRED, 'Document root'),
|
new InputOption('docroot', 'd', InputOption::VALUE_REQUIRED, 'Document root'),
|
||||||
|
@ -26,13 +26,14 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
|||||||
*/
|
*/
|
||||||
class ServerStatusCommand extends ServerCommand
|
class ServerStatusCommand extends ServerCommand
|
||||||
{
|
{
|
||||||
|
protected static $defaultName = 'server:status';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setName('server:status')
|
|
||||||
->setDefinition(array(
|
->setDefinition(array(
|
||||||
new InputOption('pidfile', null, InputOption::VALUE_REQUIRED, 'PID file'),
|
new InputOption('pidfile', null, InputOption::VALUE_REQUIRED, 'PID file'),
|
||||||
new InputOption('filter', null, InputOption::VALUE_REQUIRED, 'The value to display (one of port, host, or address)'),
|
new InputOption('filter', null, InputOption::VALUE_REQUIRED, 'The value to display (one of port, host, or address)'),
|
||||||
|
@ -25,13 +25,14 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
|||||||
*/
|
*/
|
||||||
class ServerStopCommand extends ServerCommand
|
class ServerStopCommand extends ServerCommand
|
||||||
{
|
{
|
||||||
|
protected static $defaultName = 'server:stop';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setName('server:stop')
|
|
||||||
->setDefinition(array(
|
->setDefinition(array(
|
||||||
new InputOption('pidfile', null, InputOption::VALUE_REQUIRED, 'PID file'),
|
new InputOption('pidfile', null, InputOption::VALUE_REQUIRED, 'PID file'),
|
||||||
))
|
))
|
||||||
|
@ -26,5 +26,9 @@
|
|||||||
<service id="web_server.command.server_status" class="Symfony\Bundle\WebServerBundle\Command\ServerStatusCommand">
|
<service id="web_server.command.server_status" class="Symfony\Bundle\WebServerBundle\Command\ServerStatusCommand">
|
||||||
<tag name="console.command" command="server:status" />
|
<tag name="console.command" command="server:status" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
<service id="web_server.command.server_log" class="Symfony\Bundle\WebServerBundle\Command\ServerLogCommand">
|
||||||
|
<tag name="console.command" command="server:log" />
|
||||||
|
</service>
|
||||||
</services>
|
</services>
|
||||||
</container>
|
</container>
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Bundle\WebServerBundle\Tests\DependencyInjection;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Bundle\WebServerBundle\DependencyInjection\WebServerExtension;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
|
||||||
|
class WebServerExtensionTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testLoad()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
(new WebServerExtension())->load(array(), $container);
|
||||||
|
|
||||||
|
$this->assertTrue($container->hasDefinition('web_server.command.server_run'));
|
||||||
|
$this->assertTrue($container->hasDefinition('web_server.command.server_start'));
|
||||||
|
$this->assertTrue($container->hasDefinition('web_server.command.server_stop'));
|
||||||
|
$this->assertTrue($container->hasDefinition('web_server.command.server_status'));
|
||||||
|
$this->assertTrue($container->hasDefinition('web_server.command.server_log'));
|
||||||
|
}
|
||||||
|
}
|
@ -17,7 +17,9 @@
|
|||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^5.5.9|>=7.0.8",
|
"php": "^5.5.9|>=7.0.8",
|
||||||
"symfony/console": "~3.3|~4.0",
|
"symfony/config": "~3.4|~4.0",
|
||||||
|
"symfony/console": "~3.4|~4.0",
|
||||||
|
"symfony/dependency-injection": "~3.4|~4.0",
|
||||||
"symfony/http-kernel": "~3.3|~4.0",
|
"symfony/http-kernel": "~3.3|~4.0",
|
||||||
"symfony/process": "~3.3|~4.0"
|
"symfony/process": "~3.3|~4.0"
|
||||||
},
|
},
|
||||||
@ -27,9 +29,6 @@
|
|||||||
"/Tests/"
|
"/Tests/"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"conflict": {
|
|
||||||
"symfony/dependency-injection": "<3.3"
|
|
||||||
},
|
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
|
Reference in New Issue
Block a user