本文整理汇总了PHP中Composer\Repository\RepositoryManager::setRepositoryClass方法的典型用法代码示例。如果您正苦于以下问题:PHP RepositoryManager::setRepositoryClass方法的具体用法?PHP RepositoryManager::setRepositoryClass怎么用?PHP RepositoryManager::setRepositoryClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\Repository\RepositoryManager
的用法示例。
在下文中一共展示了RepositoryManager::setRepositoryClass方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRepoCreation
/**
* @dataProvider creationCases
*/
public function testRepoCreation($type, $options, $exception = null)
{
if ($exception) {
$this->setExpectedException($exception);
}
$rm = new RepositoryManager(
$this->getMock('Composer\IO\IOInterface'),
$config = $this->getMock('Composer\Config', array('get')),
$this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')->disableOriginalConstructor()->getMock()
);
$tmpdir = $this->tmpdir;
$config
->expects($this->any())
->method('get')
->will($this->returnCallback(function ($arg) use ($tmpdir) {
return 'cache-repo-dir' === $arg ? $tmpdir : null;
}))
;
$rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository');
$rm->setRepositoryClass('vcs', 'Composer\Repository\VcsRepository');
$rm->setRepositoryClass('package', 'Composer\Repository\PackageRepository');
$rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository');
$rm->setRepositoryClass('git', 'Composer\Repository\VcsRepository');
$rm->setRepositoryClass('svn', 'Composer\Repository\VcsRepository');
$rm->setRepositoryClass('perforce', 'Composer\Repository\VcsRepository');
$rm->setRepositoryClass('hg', 'Composer\Repository\VcsRepository');
$rm->setRepositoryClass('artifact', 'Composer\Repository\ArtifactRepository');
$rm->createRepository('composer', array('url' => 'http://example.org'));
$rm->createRepository($type, $options);
}
示例2: setUp
protected function setUp()
{
/* @var IOInterface $io */
$io = $this->getMock('Composer\IO\IOInterface');
$config = new Config();
$config->merge(array(
'config' => array(
'home' => sys_get_temp_dir() . '/composer-test',
'cache-repo-dir' => sys_get_temp_dir() . '/composer-test-cache-repo',
),
));
$rm = new RepositoryManager($io, $config);
$rm->setRepositoryClass($this->getType() . '-vcs', 'Fxp\Composer\AssetPlugin\Tests\Fixtures\Repository\MockAssetRepository');
$repoConfig = array(
'repository-manager' => $rm,
'asset-options' => array(
'searchable' => true,
),
);
$this->io = $io;
$this->config = $config;
$this->rm = $rm;
$this->registry = $this->getRegistry($repoConfig, $io, $config);
$this->pool = $this->getMock('Composer\DependencyResolver\Pool');
}
示例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);
}
}
}
示例4: testRepoCreation
/**
* @dataProvider creationCases
*/
public function testRepoCreation($type, $config)
{
$rm = new RepositoryManager($this->getMock('Composer\\IO\\IOInterface'), $this->getMock('Composer\\Config'), $this->getMockBuilder('Composer\\EventDispatcher\\EventDispatcher')->disableOriginalConstructor()->getMock());
$rm->setRepositoryClass('composer', 'Composer\\Repository\\ComposerRepository');
$rm->setRepositoryClass('vcs', 'Composer\\Repository\\VcsRepository');
$rm->setRepositoryClass('package', 'Composer\\Repository\\PackageRepository');
$rm->setRepositoryClass('pear', 'Composer\\Repository\\PearRepository');
$rm->setRepositoryClass('git', 'Composer\\Repository\\VcsRepository');
$rm->setRepositoryClass('svn', 'Composer\\Repository\\VcsRepository');
$rm->setRepositoryClass('perforce', 'Composer\\Repository\\VcsRepository');
$rm->setRepositoryClass('hg', 'Composer\\Repository\\VcsRepository');
$rm->setRepositoryClass('artifact', 'Composer\\Repository\\ArtifactRepository');
$rm->createRepository('composer', array('url' => 'http://example.org'));
$rm->createRepository('composer', array('url' => 'http://example.org'));
$rm->createRepository('composer', array('url' => 'http://example.org'));
}
示例5: setUp
protected function setUp()
{
$io = $this->getMockBuilder('Composer\\IO\\IOInterface')->getMock();
$io->expects($this->any())->method('isVerbose')->will($this->returnValue(true));
/* @var IOInterface $io */
$config = new Config();
$config->merge(array('config' => array('home' => sys_get_temp_dir() . '/composer-test', 'cache-repo-dir' => sys_get_temp_dir() . '/composer-test-cache-repo')));
$rm = new RepositoryManager($io, $config);
$rm->setRepositoryClass($this->getType() . '-vcs', 'Fxp\\Composer\\AssetPlugin\\Tests\\Fixtures\\Repository\\MockAssetRepository');
$repoConfig = array_merge(array('repository-manager' => $rm, 'asset-options' => array('searchable' => true)), $this->getCustomRepoConfig());
$this->io = $io;
$this->config = $config;
$this->rm = $rm;
$this->registry = $this->getRegistry($repoConfig, $io, $config);
$this->pool = $this->getMockBuilder('Composer\\DependencyResolver\\Pool')->getMock();
}
示例6: createRepositoryManager
/**
* @param IOInterface $io
* @param Config $config
* @param EventDispatcher $eventDispatcher
* @return Repository\RepositoryManager
*/
protected function createRepositoryManager(IOInterface $io, Config $config, EventDispatcher $eventDispatcher = null, RemoteFilesystem $rfs = null)
{
$rm = new RepositoryManager($io, $config, $eventDispatcher, $rfs);
$rm->setRepositoryClass('composer', 'Composer\\Repository\\ComposerRepository');
$rm->setRepositoryClass('vcs', 'Composer\\Repository\\VcsRepository');
$rm->setRepositoryClass('package', 'Composer\\Repository\\PackageRepository');
$rm->setRepositoryClass('pear', 'Composer\\Repository\\PearRepository');
$rm->setRepositoryClass('git', 'Composer\\Repository\\VcsRepository');
$rm->setRepositoryClass('gitlab', 'Composer\\Repository\\VcsRepository');
$rm->setRepositoryClass('svn', 'Composer\\Repository\\VcsRepository');
$rm->setRepositoryClass('perforce', 'Composer\\Repository\\VcsRepository');
$rm->setRepositoryClass('hg', 'Composer\\Repository\\VcsRepository');
$rm->setRepositoryClass('artifact', 'Composer\\Repository\\ArtifactRepository');
$rm->setRepositoryClass('path', 'Composer\\Repository\\PathRepository');
return $rm;
}
示例7: createRepositoryManager
/**
* @param IOInterface $io
* @param Config $config
* @return Repository\RepositoryManager
*/
protected function createRepositoryManager(IOInterface $io, Config $config)
{
$rm = new RepositoryManager($io, $config);
$rm->setRepositoryClass('composer', 'Composer\\Repository\\ComposerRepository');
$rm->setRepositoryClass('vcs', 'Composer\\Repository\\VcsRepository');
$rm->setRepositoryClass('package', 'Composer\\Repository\\PackageRepository');
$rm->setRepositoryClass('pear', 'Composer\\Repository\\PearRepository');
$rm->setRepositoryClass('git', 'Composer\\Repository\\VcsRepository');
$rm->setRepositoryClass('svn', 'Composer\\Repository\\VcsRepository');
$rm->setRepositoryClass('hg', 'Composer\\Repository\\VcsRepository');
$rm->setRepositoryClass('artifact', 'Composer\\Repository\\ArtifactRepository');
return $rm;
}
示例8: __construct
public function __construct()
{
require_once ABSPATH . 'wp-admin/includes/plugin.php';
$this->config = new Config();
$this->repositoryManager = $rm = new RepositoryManager(new NullIO(), $this->config);
$rm->setRepositoryClass('composer', 'Composer\\Repository\\ComposerRepository');
$rm->setRepositoryClass('vcs', 'Composer\\Repository\\VcsRepository');
$rm->setRepositoryClass('package', 'Composer\\Repository\\PackageRepository');
$rm->setRepositoryClass('pear', 'Composer\\Repository\\PearRepository');
$rm->setRepositoryClass('git', 'Composer\\Repository\\VcsRepository');
$rm->setRepositoryClass('svn', 'Composer\\Repository\\VcsRepository');
$rm->setRepositoryClass('perforce', 'Composer\\Repository\\VcsRepository');
$rm->setRepositoryClass('hg', 'Composer\\Repository\\VcsRepository');
$rm->setRepositoryClass('artifact', 'Composer\\Repository\\ArtifactRepository');
$home = $this->getHomeDir();
$cache = $this->getCacheDir($home);
$this->config->merge(array('config' => array('home' => $home, 'cache-dir' => $cache)));
foreach ($this->config->getRepositories() as $index => $repo) {
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';
}
$repo_object = $rm->createRepository($repo['type'], $repo);
$rm->addRepository($repo_object);
}
}
示例9: createRepositoryManager
protected function createRepositoryManager(IOInterface $io)
{
$rm = new RepositoryManager($io);
$rm->setRepositoryClass('composer', 'Composer\\Repository\\ComposerRepository');
$rm->setRepositoryClass('vcs', 'Composer\\Repository\\VcsRepository');
$rm->setRepositoryClass('pear', 'Composer\\Repository\\PearRepository');
$rm->setRepositoryClass('package', 'Composer\\Repository\\PackageRepository');
return $rm;
}
示例10: 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;
}
示例11: buildRegistry
/**
* @param string $type
* @param RepositoryManager $rm
* @return mixed
*/
protected static function buildRegistry($type, $rm)
{
$config = ['repository-manager' => $rm, 'asset-options' => []];
$rm->setRepositoryClass($type, static::$classes[$type]);
return $rm->createRepository($type, $config);
}