mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/17048] Add method for getting composer in installer
PHPBB3-17048
This commit is contained in:
parent
09f2fe805c
commit
ef2b3a1d68
1 changed files with 33 additions and 16 deletions
|
@ -20,8 +20,10 @@ use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
|
||||||
use Composer\IO\IOInterface;
|
use Composer\IO\IOInterface;
|
||||||
use Composer\IO\NullIO;
|
use Composer\IO\NullIO;
|
||||||
use Composer\Json\JsonFile;
|
use Composer\Json\JsonFile;
|
||||||
|
use Composer\Json\JsonValidationException;
|
||||||
use Composer\Package\BasePackage;
|
use Composer\Package\BasePackage;
|
||||||
use Composer\Package\CompletePackage;
|
use Composer\Package\CompletePackage;
|
||||||
|
use Composer\PartialComposer;
|
||||||
use Composer\Repository\ComposerRepository;
|
use Composer\Repository\ComposerRepository;
|
||||||
use Composer\Semver\Constraint\ConstraintInterface;
|
use Composer\Semver\Constraint\ConstraintInterface;
|
||||||
use Composer\Util\HttpDownloader;
|
use Composer\Util\HttpDownloader;
|
||||||
|
@ -160,7 +162,8 @@ class installer
|
||||||
|
|
||||||
$this->generate_ext_json_file($packages);
|
$this->generate_ext_json_file($packages);
|
||||||
|
|
||||||
$composer = Factory::create($io, $this->get_composer_ext_json_filename(), false);
|
$composer = $this->get_composer($this->get_composer_ext_json_filename());
|
||||||
|
|
||||||
$install = \Composer\Installer::create($io, $composer);
|
$install = \Composer\Installer::create($io, $composer);
|
||||||
|
|
||||||
$composer->getInstallationManager()->setOutputProgress(false);
|
$composer->getInstallationManager()->setOutputProgress(false);
|
||||||
|
@ -217,6 +220,32 @@ class installer
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create instance of composer for supplied config file
|
||||||
|
*
|
||||||
|
* @param string|null $config_file Path to config file relative to phpBB root dir or null
|
||||||
|
*
|
||||||
|
* @return Composer|PartialComposer
|
||||||
|
* @throws JsonValidationException
|
||||||
|
*/
|
||||||
|
protected function get_composer(?string $config_file): PartialComposer
|
||||||
|
{
|
||||||
|
static $composer_factory;
|
||||||
|
if (!$composer_factory)
|
||||||
|
{
|
||||||
|
$composer_factory = new Factory();
|
||||||
|
}
|
||||||
|
|
||||||
|
$io = new NullIO();
|
||||||
|
|
||||||
|
return $composer_factory->createComposer(
|
||||||
|
$io,
|
||||||
|
$config_file,
|
||||||
|
false,
|
||||||
|
filesystem_helper::realpath('')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of currently installed packages
|
* Returns the list of currently installed packages
|
||||||
*
|
*
|
||||||
|
@ -232,19 +261,7 @@ class installer
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
static $composer_factory;
|
$composer = $this->get_composer($this->get_composer_ext_json_filename());
|
||||||
if (!$composer_factory)
|
|
||||||
{
|
|
||||||
$composer_factory = new Factory();
|
|
||||||
}
|
|
||||||
|
|
||||||
$io = new NullIO();
|
|
||||||
$composer = $composer_factory->createComposer(
|
|
||||||
$io,
|
|
||||||
$this->get_composer_ext_json_filename(),
|
|
||||||
false,
|
|
||||||
filesystem_helper::realpath('')
|
|
||||||
);
|
|
||||||
|
|
||||||
$installed = [];
|
$installed = [];
|
||||||
|
|
||||||
|
@ -302,7 +319,7 @@ class installer
|
||||||
$this->generate_ext_json_file($this->do_get_installed_packages(explode(',', self::PHPBB_TYPES)));
|
$this->generate_ext_json_file($this->do_get_installed_packages(explode(',', self::PHPBB_TYPES)));
|
||||||
|
|
||||||
$io = new NullIO();
|
$io = new NullIO();
|
||||||
$composer = Factory::create($io, $this->get_composer_ext_json_filename(), false);
|
$composer = $this->get_composer($this->get_composer_ext_json_filename());
|
||||||
|
|
||||||
/** @var ConstraintInterface $core_constraint */
|
/** @var ConstraintInterface $core_constraint */
|
||||||
$core_constraint = $composer->getPackage()->getRequires()['phpbb/phpbb']->getConstraint();
|
$core_constraint = $composer->getPackage()->getRequires()['phpbb/phpbb']->getConstraint();
|
||||||
|
@ -489,7 +506,7 @@ class installer
|
||||||
{
|
{
|
||||||
$io = new NullIO();
|
$io = new NullIO();
|
||||||
|
|
||||||
$composer = Factory::create($io, null, false);
|
$composer = $this->get_composer(null);
|
||||||
|
|
||||||
$core_packages = $this->get_core_packages($composer);
|
$core_packages = $this->get_core_packages($composer);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue