function BaseCommand::initialize
@inheritDoc
Return value
void
Overrides Command::initialize
2 calls to BaseCommand::initialize()
- ConfigCommand::initialize in vendor/
composer/ composer/ src/ Composer/ Command/ ConfigCommand.php - ConfigCommand::initialize in vendor/
composer/ composer/ src/ Composer/ Command/ ConfigCommand.php
1 method overrides BaseCommand::initialize()
- ConfigCommand::initialize in vendor/
composer/ composer/ src/ Composer/ Command/ ConfigCommand.php
File
-
vendor/
composer/ composer/ src/ Composer/ Command/ BaseCommand.php, line 221
Class
- BaseCommand
- Base class for Composer commands
Namespace
Composer\CommandCode
protected function initialize(InputInterface $input, OutputInterface $output) {
// initialize a plugin-enabled Composer instance, either local or global
$disablePlugins = $input->hasParameterOption('--no-plugins');
$disableScripts = $input->hasParameterOption('--no-scripts');
$application = parent::getApplication();
if ($application instanceof Application && $application->getDisablePluginsByDefault()) {
$disablePlugins = true;
}
if ($application instanceof Application && $application->getDisableScriptsByDefault()) {
$disableScripts = true;
}
if ($this instanceof SelfUpdateCommand) {
$disablePlugins = true;
$disableScripts = true;
}
$composer = $this->tryComposer($disablePlugins, $disableScripts);
$io = $this->getIO();
if (null === $composer) {
$composer = Factory::createGlobal($this->getIO(), $disablePlugins, $disableScripts);
}
if ($composer) {
$preCommandRunEvent = new PreCommandRunEvent(PluginEvents::PRE_COMMAND_RUN, $input, $this->getName());
$composer->getEventDispatcher()
->dispatch($preCommandRunEvent->getName(), $preCommandRunEvent);
}
if (true === $input->hasParameterOption([
'--no-ansi',
]) && $input->hasOption('no-progress')) {
$input->setOption('no-progress', true);
}
$envOptions = [
'COMPOSER_NO_AUDIT' => [
'no-audit',
],
'COMPOSER_NO_DEV' => [
'no-dev',
'update-no-dev',
],
'COMPOSER_PREFER_STABLE' => [
'prefer-stable',
],
'COMPOSER_PREFER_LOWEST' => [
'prefer-lowest',
],
'COMPOSER_MINIMAL_CHANGES' => [
'minimal-changes',
],
];
foreach ($envOptions as $envName => $optionNames) {
foreach ($optionNames as $optionName) {
if (true === $input->hasOption($optionName)) {
if (false === $input->getOption($optionName) && (bool) Platform::getEnv($envName)) {
$input->setOption($optionName, true);
}
}
}
}
if (true === $input->hasOption('ignore-platform-reqs')) {
if (!$input->getOption('ignore-platform-reqs') && (bool) Platform::getEnv('COMPOSER_IGNORE_PLATFORM_REQS')) {
$input->setOption('ignore-platform-reqs', true);
$io->writeError('<warning>COMPOSER_IGNORE_PLATFORM_REQS is set. You may experience unexpected errors.</warning>');
}
}
if (true === $input->hasOption('ignore-platform-req') && (!$input->hasOption('ignore-platform-reqs') || !$input->getOption('ignore-platform-reqs'))) {
$ignorePlatformReqEnv = Platform::getEnv('COMPOSER_IGNORE_PLATFORM_REQ');
if (0 === count($input->getOption('ignore-platform-req')) && is_string($ignorePlatformReqEnv) && '' !== $ignorePlatformReqEnv) {
$input->setOption('ignore-platform-req', explode(',', $ignorePlatformReqEnv));
$io->writeError('<warning>COMPOSER_IGNORE_PLATFORM_REQ is set to ignore ' . $ignorePlatformReqEnv . '. You may experience unexpected errors.</warning>');
}
}
parent::initialize($input, $output);
}