本文整理汇总了PHP中Composer\Repository\RepositoryManager类的典型用法代码示例。如果您正苦于以下问题:PHP RepositoryManager类的具体用法?PHP RepositoryManager怎么用?PHP RepositoryManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RepositoryManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testInstaller
/**
* @dataProvider provideInstaller
*/
public function testInstaller(PackageInterface $rootPackage, $repositories, array $options)
{
$io = $this->getMock('Composer\\IO\\IOInterface');
$downloadManager = $this->getMock('Composer\\Downloader\\DownloadManager');
$config = $this->getMock('Composer\\Config');
$repositoryManager = new RepositoryManager($io, $config);
$repositoryManager->setLocalRepository(new WritableRepositoryMock());
$repositoryManager->setLocalDevRepository(new WritableRepositoryMock());
if (!is_array($repositories)) {
$repositories = array($repositories);
}
foreach ($repositories as $repository) {
$repositoryManager->addRepository($repository);
}
$locker = $this->getMockBuilder('Composer\\Package\\Locker')->disableOriginalConstructor()->getMock();
$installationManager = new InstallationManagerMock();
$eventDispatcher = $this->getMockBuilder('Composer\\Script\\EventDispatcher')->disableOriginalConstructor()->getMock();
$autoloadGenerator = $this->getMock('Composer\\Autoload\\AutoloadGenerator');
$installer = new Installer($io, $config, clone $rootPackage, $downloadManager, $repositoryManager, $locker, $installationManager, $eventDispatcher, $autoloadGenerator);
$result = $installer->run();
$this->assertTrue($result);
$expectedInstalled = isset($options['install']) ? $options['install'] : array();
$expectedUpdated = isset($options['update']) ? $options['update'] : array();
$expectedUninstalled = isset($options['uninstall']) ? $options['uninstall'] : array();
$installed = $installationManager->getInstalledPackages();
$this->assertSame($expectedInstalled, $installed);
$updated = $installationManager->getUpdatedPackages();
$this->assertSame($expectedUpdated, $updated);
$uninstalled = $installationManager->getUninstalledPackages();
$this->assertSame($expectedUninstalled, $uninstalled);
}
开发者ID:r15ch13,项目名称:composer,代码行数:34,代码来源:InstallerTest.php
示例2: mapContrib
public function mapContrib(InstallationManager $im, RepositoryManager $rm)
{
$typePathMap = $this->getTypePathMap();
$typeInstallMap = [];
$packages = $rm->getLocalRepository()->getCanonicalPackages();
foreach ($packages as $package) {
if ($drupalType = $this->getDrupalType($package)) {
if (!isset($typePathMap[$drupalType])) {
continue;
}
$installPath = self::changeSlashes($im->getInstaller($package->getType())->getInstallPath($package));
if (strpos($installPath, $root = $this->getRoot()) !== false) {
$installPath = self::changeSlashes($this->getFS()->makePathRelative($installPath, $root));
}
$name = explode('/', $package->getPrettyName())[1];
$mapRef =& $typeInstallMap[$drupalType][rtrim($installPath, DIRECTORY_SEPARATOR)];
if (in_array($drupalType, ['module', 'theme'])) {
$mapRef = sprintf($typePathMap[$drupalType] . DIRECTORY_SEPARATOR . '%s', 'contrib', $name);
} else {
$mapRef = sprintf($typePathMap[$drupalType], $name);
}
}
}
return array_intersect_key($typeInstallMap, $typePathMap);
}
开发者ID:mbolli,项目名称:drupal-tangler,代码行数:25,代码来源:Mapper.php
示例3: setVcsTypeRepositories
/**
* Sets vcs type repositories.
*
* @param RepositoryManager $rm
*/
public static function setVcsTypeRepositories(RepositoryManager $rm)
{
foreach (Assets::getTypes() as $assetType) {
foreach (Assets::getVcsRepositoryDrivers() as $driverType => $repositoryClass) {
$rm->setRepositoryClass($assetType . '-' . $driverType, $repositoryClass);
}
}
}
开发者ID:cychenyin,项目名称:postmill,代码行数:13,代码来源:AssetPlugin.php
示例4: addRepository
/**
* Add a repository to collection of repositories.
*
* @param \Composer\Repository\RepositoryManager $repoManager
* @param array $repositories
* @param array $repoJson
*/
private function addRepository(RepositoryManager $repoManager, array &$repositories, $repoJson)
{
if (isset($repoJson['type'])) {
$this->getLogger()->info("Prepending {$repoJson['type']} repository");
$repository = $repoManager->createRepository($repoJson['type'], $repoJson);
$repoManager->prependRepository($repository);
$repositories[] = $repository;
}
}
开发者ID:arcanedev,项目名称:composer,代码行数:16,代码来源:RepositoriesTrait.php
示例5: addRepositoryInstance
/**
* Add repository instance.
*
* @param IOInterface $io The IO instance
* @param RepositoryManager $rm The repository mamanger
* @param array $repos The list of already repository added (passed by reference)
* @param string $name The name of the new repository
* @param RepositoryInterface $repo The repository instance
* @param Pool|null $pool The pool
*/
public static function addRepositoryInstance(IOInterface $io, RepositoryManager $rm, array &$repos, $name, RepositoryInterface $repo, Pool $pool = null)
{
if (!isset($repos[$name])) {
static::writeAddRepository($io, $name);
$repos[$name] = $repo;
$rm->addRepository($repo);
if (null !== $pool) {
$pool->addRepository($repo);
}
}
}
开发者ID:MvegaR,项目名称:ingSotfware,代码行数:21,代码来源:Util.php
示例6: addRepository
/**
* @param RepositoryManager $rm The repository mamanger
* @param array $repos The list of already repository added (passed by reference)
* @param string $name The name of the new repository
* @param array $repoConfig The config of the new repository
* @param Pool|null $pool The pool
*/
public static function addRepository(RepositoryManager $rm, array &$repos, $name, array $repoConfig, Pool $pool = null)
{
if (!isset($repos[$name])) {
$repo = $rm->createRepository($repoConfig['type'], $repoConfig);
$repos[$name] = $repo;
$rm->addRepository($repo);
if (null !== $pool) {
$pool->addRepository($repo);
}
}
}
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:19,代码来源:Util.php
示例7: setUp
protected function setUp()
{
$this->tempDir = TestUtil::makeTempDir('puli-composer-plugin', __CLASS__);
$filesystem = new Filesystem();
$filesystem->mirror(__DIR__ . '/Fixtures/root', $this->tempDir);
$this->io = $this->getMock('Composer\\IO\\IOInterface');
$this->config = new Config(false, $this->tempDir);
$this->config->merge(array('config' => array('vendor-dir' => 'the-vendor')));
$this->installationManager = $this->getMockBuilder('Composer\\Installer\\InstallationManager')->disableOriginalConstructor()->getMock();
$this->installationManager->expects($this->any())->method('getInstallPath')->will($this->returnCallback(array($this, 'getInstallPath')));
$this->rootPackage = new RootPackage('vendor/root', '1.0', '1.0');
$this->rootPackage->setRequires(array('vendor/package1' => new Link('vendor/root', 'vendor/package1'), 'vendor/package2' => new Link('vendor/root', 'vendor/package2')));
$this->localRepository = new TestLocalRepository(array(new Package('vendor/package1', '1.0', '1.0'), new Package('vendor/package2', '1.0', '1.0')));
$this->repositoryManager = new RepositoryManager($this->io, $this->config);
$this->repositoryManager->setLocalRepository($this->localRepository);
$this->installPaths = array();
$this->composer = new Composer();
$this->composer->setRepositoryManager($this->repositoryManager);
$this->composer->setInstallationManager($this->installationManager);
$this->composer->setConfig($this->config);
$this->composer->setPackage($this->rootPackage);
$this->puliRunner = $this->getMockBuilder('Puli\\ComposerPlugin\\PuliRunner')->disableOriginalConstructor()->getMock();
$this->previousWd = getcwd();
chdir($this->tempDir);
$this->plugin = new PuliPlugin($this->puliRunner);
}
开发者ID:kormik,项目名称:composer-plugin,代码行数:26,代码来源:PuliPluginTest.php
示例8: setUp
protected function setUp()
{
while (false === mkdir($this->tempDir = sys_get_temp_dir() . '/puli-plugin/PuliPluginTest_root' . rand(10000, 99999), 0777, true)) {
}
$filesystem = new Filesystem();
$filesystem->mirror(__DIR__ . '/Fixtures/root', $this->tempDir);
$this->io = $this->getMock('Composer\\IO\\IOInterface');
$this->config = new Config(false, $this->tempDir);
$this->config->merge(array('config' => array('vendor-dir' => 'the-vendor')));
$this->installationManager = $this->getMockBuilder('Composer\\Installer\\InstallationManager')->disableOriginalConstructor()->getMock();
$this->installationManager->expects($this->any())->method('getInstallPath')->will($this->returnCallback(array($this, 'getInstallPath')));
$this->rootPackage = new RootPackage('vendor/root', '1.0', '1.0');
$this->localRepository = new TestLocalRepository(array(new Package('vendor/package1', '1.0', '1.0'), new Package('vendor/package2', '1.0', '1.0')));
$this->repositoryManager = new RepositoryManager($this->io, $this->config);
$this->repositoryManager->setLocalRepository($this->localRepository);
$this->installPaths = array();
$this->composer = new Composer();
$this->composer->setRepositoryManager($this->repositoryManager);
$this->composer->setInstallationManager($this->installationManager);
$this->composer->setConfig($this->config);
$this->composer->setPackage($this->rootPackage);
$this->puliRunner = $this->getMockBuilder('Puli\\ComposerPlugin\\PuliRunner')->disableOriginalConstructor()->getMock();
$this->previousWd = getcwd();
chdir($this->tempDir);
$this->plugin = new PuliPlugin($this->puliRunner);
}
开发者ID:niklongstone,项目名称:composer-plugin,代码行数:26,代码来源:PuliPluginTest.php
示例9: mapContrib
public function mapContrib(InstallationManager $im, RepositoryManager $rm)
{
$typePathMap = $this->getTypePathMap();
$typeInstallMap = [];
$packages = $rm->getLocalRepository()->getCanonicalPackages();
foreach ($packages as $package) {
if ($drupalType = $this->getDrupalType($package)) {
$installPath = $im->getInstaller($package->getType())->getInstallPath($package);
if (strpos($installPath, $root = $this->getRoot()) !== false) {
$installPath = $this->getFS()->makePathRelative($installPath, $root);
}
$name = explode('/', $package->getPrettyName())[1];
$typeInstallMap[$drupalType][rtrim($installPath, '/')] = sprintf($typePathMap[$drupalType] . '/%s', 'contrib', $name);
}
}
return array_intersect_key($typeInstallMap, $typePathMap);
}
开发者ID:davidbarratt,项目名称:drupal-tangler,代码行数:17,代码来源:Mapper.php
示例10: setUp
protected function setUp()
{
$this->last_wdir = getcwd();
chdir(__DIR__ . '/../');
$this->plugin = new Plugin();
$this->composer = new Composer();
$this->io = new BufferIO('', StreamOutput::VERBOSITY_VERY_VERBOSE);
$config = new Config(false);
$config->merge(['config' => ['vendor-dir' => __DIR__]]);
$repo_manager = new RepositoryManager($this->io, $config);
$repository = new InstalledArrayRepository();
$package = new RootPackage('foobar', 1, 1);
$event_dispatcher = new EventDispatcher($this->composer, $this->io);
$autoload_generator = new AutoloadGenerator($event_dispatcher, $this->io);
$package->setType('hostnet-entity');
$repo_manager->setLocalRepository($repository);
$this->composer->setConfig($config);
$this->composer->setRepositoryManager($repo_manager);
$this->composer->setPackage($package);
$this->composer->setAutoloadGenerator($autoload_generator);
}
开发者ID:hostnet,项目名称:entity-plugin-lib,代码行数:21,代码来源:GenerationTest.php
示例11: addLocalRepository
/**
* @param Repository\RepositoryManager $rm
* @param string $vendorDir
*/
protected function addLocalRepository(IOInterface $io, RepositoryManager $rm, $vendorDir)
{
$rm->setLocalRepository(new Repository\InstalledFilesystemRepository(new JsonFile($vendorDir . '/composer/installed.json', null, $io)));
}
开发者ID:tommygoud,项目名称:composer,代码行数:8,代码来源:Factory.php
示例12: createRepos
/**
* @return RepositoryInterface[]
*/
private static function createRepos(RepositoryManager $rm, array $repoConfigs)
{
$repos = array();
foreach ($repoConfigs as $index => $repo) {
if (is_string($repo)) {
throw new \UnexpectedValueException('"repositories" should be an array of repository definitions, only a single repository was given');
}
if (!is_array($repo)) {
throw new \UnexpectedValueException('Repository "' . $index . '" (' . json_encode($repo) . ') should be an array, ' . gettype($repo) . ' given');
}
if (!isset($repo['type'])) {
throw new \UnexpectedValueException('Repository "' . $index . '" (' . json_encode($repo) . ') must have a type defined');
}
$name = is_int($index) && isset($repo['url']) ? preg_replace('{^https?://}i', '', $repo['url']) : $index;
while (isset($repos[$name])) {
$name .= '2';
}
if ($repo['type'] === 'filesystem') {
$repos[$name] = new FilesystemRepository($repo['json']);
} else {
$repos[$name] = $rm->createRepository($repo['type'], $repo);
}
}
return $repos;
}
开发者ID:dazzle-libraries,项目名称:composer,代码行数:28,代码来源:RepositoryFactory.php
示例13: purgePackages
/**
* @param Repository\RepositoryManager $rm
* @param Installer\InstallationManager $im
*/
protected function purgePackages(Repository\RepositoryManager $rm, Installer\InstallationManager $im)
{
$repo = $rm->getLocalRepository();
foreach ($repo->getPackages() as $package) {
if (!$im->isPackageInstalled($repo, $package)) {
$repo->removePackage($package);
}
}
}
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:13,代码来源:Factory.php
示例14: createComposer
public function createComposer()
{
$cwd = sprintf('%s/%s', getcwd(), '.eva');
$factory = new Factory();
if (false) {
$composer = $factory->createComposer($this->io, $config, true, $cwd);
}
// -----------------
// -----------------
// -----------------
$fullLoad = true;
$composerFile = $cwd . '/manifest.composer.json';
$file = new JsonFile($composerFile);
$file->validateSchema(JsonFile::LAX_SCHEMA);
$localConfig = $file->read();
// -----------------
// -----------------
// -----------------
// Load config and override with local config/auth config
// $config = Factory::createConfig($this->io, $cwd);
$vendorDir = $cwd . '/manifests/vendor';
$config = $factory::createConfig($this->io, $cwd);
$config->merge($localConfig);
$config->merge(['config' => ['vendor-dir' => $vendorDir]]);
$localAuthFile = new JsonFile(dirname(realpath($composerFile)) . '/auth.json');
if ($localAuthFile->exists()) {
if ($this->io && $this->io->isDebug()) {
$this->io->writeError('Loading config file ' . $localAuthFile->getPath());
}
$config->merge(array('config' => $localAuthFile->read()));
$config->setAuthConfigSource(new JsonConfigSource($localAuthFile, true));
}
// initialize composer
$composer = new Composer();
$composer->setConfig($config);
// initialize event dispatcher
$dispatcher = new EventDispatcher($composer, $this->io);
$composer->setEventDispatcher($dispatcher);
// initialize repository manager
// $rm = $this->createRepositoryManager($io, $config, $dispatcher);
// $composer->setRepositoryManager($rm);
$rm = new RepositoryManager($this->io, $config, $dispatcher);
$rm->setRepositoryClass('composer', ComposerRepository::class);
$composer->setRepositoryManager($rm);
// load local repository
$rm->setLocalRepository(new InstalledFilesystemRepository(new JsonFile($vendorDir . '/composer/installed.json')));
// load package
$parser = new VersionParser();
$guesser = new VersionGuesser($config, new ProcessExecutor($this->io), $parser);
$loader = new RootPackageLoader($rm, $config, $parser, $guesser);
$package = $loader->load($localConfig);
$composer->setPackage($package);
// initialize installation manager
$im = new InstallationManager();
$composer->setInstallationManager($im);
if ($fullLoad) {
// initialize download manager
$dm = $factory->createDownloadManager($this->io, $config, $dispatcher);
$composer->setDownloadManager($dm);
// initialize autoload generator
$generator = new AutoloadGenerator($dispatcher, $this->io);
$composer->setAutoloadGenerator($generator);
}
// add installers to the manager (must happen after download manager is created since they read it out of $composer)
$im->addInstaller(new Installer\LibraryInstaller($this->io, $composer, null));
$im->addInstaller(new Installer\PearInstaller($this->io, $composer, 'pear-library'));
$im->addInstaller(new Installer\PluginInstaller($this->io, $composer));
$im->addInstaller(new Installer\MetapackageInstaller($this->io));
// if ($fullLoad) {
// $globalComposer = $this->createGlobalComposer($io, $config, $disablePlugins);
// $pm = $this->createPluginManager($io, $composer, $globalComposer);
// $composer->setPluginManager($pm);
//
// if (!$disablePlugins) {
// $pm->loadInstalledPlugins();
// }
//
// // once we have plugins and custom installers we can
// // purge packages from local repos if they have been deleted on the filesystem
// if ($rm->getLocalRepository()) {
// $this->purgePackages($rm->getLocalRepository(), $im);
// }
// }
// init locker if possible
if ($fullLoad && isset($composerFile)) {
$lockFile = "json" === pathinfo($composerFile, PATHINFO_EXTENSION) ? substr($composerFile, 0, -4) . 'lock' : $composerFile . '.lock';
$locker = new Locker($this->io, new JsonFile($lockFile, new RemoteFilesystem($this->io, $config)), $rm, $im, file_get_contents($composerFile));
$composer->setLocker($locker);
}
// -----------------
// -----------------
// -----------------
return $composer;
}
开发者ID:eva,项目名称:eva,代码行数:94,代码来源:ComposerFactory.php
示例15: addLocalRepository
protected function addLocalRepository(RepositoryManager $rm, $vendorDir)
{
// TODO BC feature, remove after June 15th
if (file_exists($vendorDir . '/.composer/installed.json')) {
if (!is_dir($vendorDir . '/composer')) {
mkdir($vendorDir . '/composer/', 0777, true);
}
rename($vendorDir . '/.composer/installed.json', $vendorDir . '/composer/installed.json');
}
if (file_exists($vendorDir . '/.composer/installed_dev.json')) {
if (!is_dir($vendorDir . '/composer')) {
mkdir($vendorDir . '/composer/', 0777, true);
}
rename($vendorDir . '/.composer/installed_dev.json', $vendorDir . '/composer/installed_dev.json');
}
if (file_exists($vendorDir . '/installed.json')) {
if (!is_dir($vendorDir . '/composer')) {
mkdir($vendorDir . '/composer/', 0777, true);
}
rename($vendorDir . '/installed.json', $vendorDir . '/composer/installed.json');
}
if (file_exists($vendorDir . '/installed_dev.json')) {
if (!is_dir($vendorDir . '/composer')) {
mkdir($vendorDir . '/composer/', 0777, true);
}
rename($vendorDir . '/installed_dev.json', $vendorDir . '/composer/installed_dev.json');
}
$rm->setLocalRepository(new Repository\InstalledFilesystemRepository(new JsonFile($vendorDir . '/composer/installed.json')));
$rm->setLocalDevRepository(new Repository\InstalledFilesystemRepository(new JsonFile($vendorDir . '/composer/installed_dev.json')));
}
开发者ID:nicodmf,项目名称:composer,代码行数:30,代码来源:Factory.php
示例16: mockLocalRepositories
/**
* Replace local repositories with InstalledArrayRepository instances
*
* This is to prevent any accidental modification of the existing repos on disk
*
* @param RepositoryManager $rm
*/
private function mockLocalRepositories(RepositoryManager $rm)
{
$packages = array_map(function ($p) {
return clone $p;
}, $rm->getLocalRepository()->getPackages());
foreach ($packages as $key => $package) {
if ($package instanceof AliasPackage) {
unset($packages[$key]);
}
}
$rm->setLocalRepository(new InstalledArrayRepository($packages));
$packages = array_map(function ($p) {
return clone $p;
}, $rm->getLocalDevRepository()->getPackages());
foreach ($packages as $key => $package) {
if ($package instanceof AliasPackage) {
unset($packages[$key]);
}
}
$rm->setLocalDevRepository(new InstalledArrayRepository($packages));
}
开发者ID:rkallensee,项目名称:composer,代码行数:28,代码来源:Installer.php
示例17: addLocalRepository
/**
* @param Repository\RepositoryManager $rm
* @param string $vendorDir
*/
protected function addLocalRepository(RepositoryManager $rm, $vendorDir)
{
$rm->setLocalRepository(new Repository\InstalledFilesystemRepository(new JsonFile($vendorDir . '/composer/installed.json')));
$rm->setLocalDevRepository(new Repository\InstalledFilesystemRepository(new JsonFile($vendorDir . '/composer/installed_dev.json')));
}
开发者ID:rkallensee,项目名称:composer,代码行数:9,代码来源:Factory.php
示例18: createInstallationManager
protected function createInstallationManager(Repository\RepositoryManager $rm, Downloader\DownloadManager $dm, $vendorDir, $binDir, IOInterface $io)
{
$im = new Installer\InstallationManager($vendorDir);
$im->addInstaller(new Installer\LibraryInstaller($vendorDir, $binDir, $dm, $rm->getLocalRepository(), $io, null));
$im->addInstaller(new Installer\InstallerInstaller($vendorDir, $binDir, $dm, $rm->getLocalRepository(), $io, $im));
return $im;
}
开发者ID:roadrunner,项目名称:composer,代码行数:7,代码来源:Factory.php
示例19: addPackagistRepository
protected function addPackagistRepository(RepositoryManager $rm)
{
$rm->addRepository(new Repository\ComposerRepository(array('url' => 'http://packagist.org')));
}
开发者ID:roadrunner,项目名称:composer,代码行数:4,代码来源:Factory.php
示例20: findDevPackage
/**
* Find the dev-master package.
*
* @param RepositoryManager $manager Composer repository manger
* @param string $name Package's name
*
* @return PackageInterface The found package
*/
protected function findDevPackage(RepositoryManager $manager, $name)
{
return $manager->findPackage($name, '9999999-dev');
}
开发者ID:mattketmo,项目名称:stone,代码行数:12,代码来源:BaseCommand.php
注:本文中的Composer\Repository\RepositoryManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论