1
0
Fork 0

Disable plugins across the board when --no-plugins is specified, fixes #5509

pull/5527/head
Jordi Boggiano 2016-07-12 16:13:02 +01:00
parent 06499749ff
commit 7bcd336c95
2 changed files with 12 additions and 5 deletions

View File

@ -40,11 +40,11 @@ abstract class BaseCommand extends Command
/** /**
* @param bool $required * @param bool $required
* @param bool $disablePlugins * @param bool|null $disablePlugins
* @throws \RuntimeException * @throws \RuntimeException
* @return Composer * @return Composer
*/ */
public function getComposer($required = true, $disablePlugins = false) public function getComposer($required = true, $disablePlugins = null)
{ {
if (null === $this->composer) { if (null === $this->composer) {
$application = $this->getApplication(); $application = $this->getApplication();

View File

@ -58,6 +58,7 @@ class Application extends BaseApplication
'; ';
private $hasPluginCommands = false; private $hasPluginCommands = false;
private $disablePluginsByDefault = false;
public function __construct() public function __construct()
{ {
@ -108,6 +109,8 @@ class Application extends BaseApplication
*/ */
public function doRun(InputInterface $input, OutputInterface $output) public function doRun(InputInterface $input, OutputInterface $output)
{ {
$this->disablePluginsByDefault = $input->hasParameterOption('--no-plugins');
$io = $this->io = new ConsoleIO($input, $output, $this->getHelperSet()); $io = $this->io = new ConsoleIO($input, $output, $this->getHelperSet());
ErrorHandler::register($io); ErrorHandler::register($io);
@ -127,7 +130,7 @@ class Application extends BaseApplication
} }
} }
if (!$input->hasParameterOption('--no-plugins') && !$this->hasPluginCommands && 'global' !== $commandName) { if (!$this->disablePluginsByDefault && !$this->hasPluginCommands && 'global' !== $commandName) {
try { try {
foreach ($this->getPluginCommands() as $command) { foreach ($this->getPluginCommands() as $command) {
if ($this->has($command->getName())) { if ($this->has($command->getName())) {
@ -300,12 +303,16 @@ class Application extends BaseApplication
/** /**
* @param bool $required * @param bool $required
* @param bool $disablePlugins * @param bool|null $disablePlugins
* @throws JsonValidationException * @throws JsonValidationException
* @return \Composer\Composer * @return \Composer\Composer
*/ */
public function getComposer($required = true, $disablePlugins = false) public function getComposer($required = true, $disablePlugins = null)
{ {
if (null === $disablePlugins) {
$disablePlugins = $this->disablePluginsByDefault;
}
if (null === $this->composer) { if (null === $this->composer) {
try { try {
$this->composer = Factory::create($this->io, null, $disablePlugins); $this->composer = Factory::create($this->io, null, $disablePlugins);