本文整理汇总了PHP中Composer\Repository\RepositoryManager::createRepository方法的典型用法代码示例。如果您正苦于以下问题:PHP RepositoryManager::createRepository方法的具体用法?PHP RepositoryManager::createRepository怎么用?PHP RepositoryManager::createRepository使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\Repository\RepositoryManager
的用法示例。
在下文中一共展示了RepositoryManager::createRepository方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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'));
}
示例3: addRegistryRepositories
/**
* Adds asset registry repositories.
*
* @param RepositoryManager $rm
* @param VcsPackageFilter $filter
* @param array $extra
*/
public static function addRegistryRepositories(RepositoryManager $rm, VcsPackageFilter $filter, array $extra)
{
$opts = array_key_exists('asset-registry-options', $extra) ? $extra['asset-registry-options'] : array();
foreach (Assets::getRegistries() as $assetType => $registryClass) {
$config = array('repository-manager' => $rm, 'vcs-package-filter' => $filter, 'asset-options' => static::createAssetOptions($opts, $assetType));
$rm->setRepositoryClass($assetType, $registryClass);
$rm->addRepository($rm->createRepository($assetType, $config));
}
}
示例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;
}
}
示例5: 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);
}
}
}
示例6: 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;
}
示例7: __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);
}
}
示例8: addRepository
/**
* Add repository config.
*
* @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 array $repoConfig The config of the new repository
* @param Pool|null $pool The pool
*/
public static function addRepository(IOInterface $io, RepositoryManager $rm, array &$repos, $name, array $repoConfig, Pool $pool = null)
{
$repo = $rm->createRepository($repoConfig['type'], $repoConfig);
static::addRepositoryInstance($io, $rm, $repos, $name, $repo, $pool);
}
示例9: 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);
}