本文整理汇总了PHP中Composer\Installer\InstallationManager类的典型用法代码示例。如果您正苦于以下问题:PHP InstallationManager类的具体用法?PHP InstallationManager怎么用?PHP InstallationManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了InstallationManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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
示例2: setUp
protected function setUp()
{
$this->fs = new Filesystem();
$that = $this;
$this->workingDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'cmptest-' . md5(uniqid('', true));
$this->fs->ensureDirectoryExists($this->workingDir);
$this->vendorDir = $this->workingDir . DIRECTORY_SEPARATOR . 'composer-test-autoload';
$this->ensureDirectoryExistsAndClear($this->vendorDir);
$this->config = $this->getMock('Composer\\Config');
$this->config->expects($this->at(0))->method('get')->with($this->equalTo('vendor-dir'))->will($this->returnCallback(function () use($that) {
return $that->vendorDir;
}));
$this->config->expects($this->at(1))->method('get')->with($this->equalTo('vendor-dir'))->will($this->returnCallback(function () use($that) {
return $that->vendorDir;
}));
$this->origDir = getcwd();
chdir($this->workingDir);
$this->im = $this->getMockBuilder('Composer\\Installer\\InstallationManager')->disableOriginalConstructor()->getMock();
$this->im->expects($this->any())->method('getInstallPath')->will($this->returnCallback(function ($package) use($that) {
$targetDir = $package->getTargetDir();
return $that->vendorDir . '/' . $package->getName() . ($targetDir ? '/' . $targetDir : '');
}));
$this->repository = $this->getMock('Composer\\Repository\\InstalledRepositoryInterface');
$this->eventDispatcher = $this->getMockBuilder('Composer\\EventDispatcher\\EventDispatcher')->disableOriginalConstructor()->getMock();
$this->generator = new AutoloadGenerator($this->eventDispatcher);
}
开发者ID:aminembarki,项目名称:composer,代码行数:26,代码来源:AutoloadGeneratorTest.php
示例3: build
public function build($rootDirectory, $optimize = false, $noDevMode = false)
{
$packages = $this->loadPackages($rootDirectory);
$evm = new EventDispatcher(new Composer(), $this->io);
$generator = new AutoloadGenerator($evm, $this->io);
$generator->setDevMode(!$noDevMode);
$installationManager = new InstallationManager();
$installationManager->addInstaller(new FiddlerInstaller());
$this->io->write('Building fiddler.json projects.');
foreach ($packages as $packageName => $config) {
if (strpos($packageName, 'vendor') === 0) {
continue;
}
$this->io->write(' [Build] <info>' . $packageName . '</info>');
$mainPackage = new Package($packageName, "@stable", "@stable");
$mainPackage->setType('fiddler');
$mainPackage->setAutoload($config['autoload']);
$mainPackage->setDevAutoload($config['autoload-dev']);
$localRepo = new FiddlerInstalledRepository();
$this->resolvePackageDependencies($localRepo, $packages, $packageName);
$composerConfig = new Config(true, $rootDirectory);
$composerConfig->merge(array('config' => array('vendor-dir' => $config['path'] . '/vendor')));
$generator->dump($composerConfig, $localRepo, $mainPackage, $installationManager, 'composer', $optimize);
}
}
开发者ID:sidisinsane,项目名称:fiddler,代码行数:25,代码来源:Build.php
示例4: setUp
protected function setUp()
{
$this->package = $this->getMockBuilder('Composer\\Package\\RootPackageInterface')->getMock();
$this->assetType = $this->getMockBuilder('Fxp\\Composer\\AssetPlugin\\Type\\AssetTypeInterface')->getMock();
$versionConverter = $this->getMockBuilder('Fxp\\Composer\\AssetPlugin\\Converter\\VersionConverterInterface')->getMock();
$versionConverter->expects($this->any())->method('convertVersion')->will($this->returnCallback(function ($value) {
return $value;
}));
$this->assetType->expects($this->any())->method('getVersionConverter')->will($this->returnValue($versionConverter));
$this->installationManager = $this->getMockBuilder('Composer\\Installer\\InstallationManager')->disableOriginalConstructor()->getMock();
$this->installationManager->expects($this->any())->method('isPackageInstalled')->will($this->returnValue(true));
}
开发者ID:stefangr,项目名称:composer-asset-plugin,代码行数:12,代码来源:VcsPackageFilterTest.php
示例5: activate
/**
* Apply plugin modifications to composer
*
* @param \Composer\Composer $composer
* @param \Composer\IO\IOInterface $io
* @return void
*/
public function activate(Composer $composer, IOInterface $io)
{
$this->io = $io;
$this->composer = $composer;
$this->factory = $this->getFactory();
$this->manager = $this->getInstallationManager($composer);
// The connection factory is used to create the actual connection instances on
// the database. We will inject the factory into the manager so that it may
// make the connections while they are actually needed and not of before.
$installers = $this->factory->getInstallers();
foreach ($installers as $name) {
$this->manager->addInstaller($this->factory->make($name, $composer, $io));
}
}
开发者ID:lappuse,项目名称:composer-installer,代码行数:21,代码来源:Plugin.php
示例6: 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
示例7: 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
示例8: setUp
protected function setUp()
{
$this->fs = new Filesystem();
$that = $this;
$this->workingDir = $this->getUniqueTmpDirectory();
$this->vendorDir = $this->workingDir . DIRECTORY_SEPARATOR . 'composer-test-autoload';
$this->ensureDirectoryExistsAndClear($this->vendorDir);
$this->config = $this->getMock('Composer\\Config');
$this->configValueMap = array('vendor-dir' => function () use($that) {
return $that->vendorDir;
});
$this->config->expects($this->atLeastOnce())->method('get')->will($this->returnCallback(function ($arg) use($that) {
$ret = null;
if (isset($that->configValueMap[$arg])) {
$ret = $that->configValueMap[$arg];
if (is_callable($ret)) {
$ret = $ret();
}
}
return $ret;
}));
$this->origDir = getcwd();
chdir($this->workingDir);
$this->im = $this->getMockBuilder('Composer\\Installer\\InstallationManager')->disableOriginalConstructor()->getMock();
$this->im->expects($this->any())->method('getInstallPath')->will($this->returnCallback(function ($package) use($that) {
$targetDir = $package->getTargetDir();
return $that->vendorDir . '/' . $package->getName() . ($targetDir ? '/' . $targetDir : '');
}));
$this->repository = $this->getMock('Composer\\Repository\\InstalledRepositoryInterface');
$this->eventDispatcher = $this->getMockBuilder('Composer\\EventDispatcher\\EventDispatcher')->disableOriginalConstructor()->getMock();
$this->generator = new AutoloadGenerator($this->eventDispatcher);
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:32,代码来源:AutoloadGeneratorTest.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: updateFull
/**
* @test
*
* @depends testInstallerCreationShouldNotCreateVendorDirectory
* @depends testInstallerCreationShouldNotCreateBinDirectory
*/
public function updateFull()
{
/** @var InstallationManager|\PHPUnit_Framework_MockObject_MockObject $im */
$this->im->expects($this->once())->method('uninstall');
$this->im->expects($this->once())->method('install');
$installer = $this->createInstaller();
$initial = $this->createPackageMock('letudiant/bar-foo');
$target = $this->createPackageMock();
$installer->update($this->repository, $initial, $target);
}
开发者ID:letudiant,项目名称:composer-shared-package-plugin,代码行数:16,代码来源:SharedPackageInstallerTest.php
示例11: build
public function build($rootDirectory, $optimize = false, $noDevMode = false)
{
$this->io->write(sprintf('<info>Generating autoload files for monorepo sub-packages %s dev-dependencies.</info>', $noDevMode ? 'without' : 'with'));
$start = microtime(true);
$packages = $this->loadPackages($rootDirectory);
$evm = new EventDispatcher(new Composer(), $this->io);
$generator = new AutoloadGenerator($evm, $this->io);
$generator->setDevMode(!$noDevMode);
$installationManager = new InstallationManager();
$installationManager->addInstaller(new MonorepoInstaller());
foreach ($packages as $packageName => $config) {
if (strpos($packageName, 'vendor') === 0) {
continue;
}
$this->io->write(sprintf(' [Subpackage] <comment>%s</comment>', $packageName));
$mainPackage = new Package($packageName, "@stable", "@stable");
$mainPackage->setType('monorepo');
$mainPackage->setAutoload($config['autoload']);
$mainPackage->setDevAutoload($config['autoload-dev']);
$localRepo = new MonorepoInstalledRepository();
$this->resolvePackageDependencies($localRepo, $packages, $packageName);
$composerConfig = new Config(true, $rootDirectory);
$composerConfig->merge(array('config' => array('vendor-dir' => $config['path'] . '/vendor')));
$generator->dump($composerConfig, $localRepo, $mainPackage, $installationManager, 'composer', $optimize);
$binDir = $config['path'] . '/vendor/bin';
// remove old symlinks
array_map('unlink', glob($binDir . '/*'));
foreach ($localRepo->getPackages() as $package) {
foreach ($package->getBinaries() as $binary) {
if (!is_dir($binDir)) {
mkdir($binDir, 0755, true);
}
$binFile = $binDir . '/' . basename($binary);
symlink($rootDirectory . '/' . $binary, $binFile);
}
}
}
$duration = microtime(true) - $start;
$this->io->write(sprintf('Monorepo subpackage autoloads generated in <comment>%0.2f</comment> seconds.', $duration));
}
开发者ID:beberlei,项目名称:composer-monorepo-plugin,代码行数:40,代码来源:Build.php
示例12: setUp
public function setUp()
{
$this->filesystem = new Filesystem();
$this->composer = new Composer();
$this->config = new Config();
$this->io = new NullIO();
$this->componentDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'component-installer-componentDir';
$this->vendorDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'component-installer-vendorDir';
$this->binDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'component-installer-binDir';
foreach (array($this->componentDir, $this->vendorDir, $this->binDir) as $dir) {
if (is_dir($dir)) {
$this->filesystem->removeDirectory($dir);
}
$this->filesystem->ensureDirectoryExists($dir);
}
$this->config->merge(array('config' => array('vendor-dir' => $this->vendorDir, 'component-dir' => $this->componentDir, 'bin-dir' => $this->binDir)));
$this->composer->setConfig($this->config);
// Set up the Installation Manager.
$this->installationManager = new InstallationManager();
$this->installationManager->addInstaller(new LibraryInstaller($this->io, $this->composer));
$this->installationManager->addInstaller(new Installer($this->io, $this->composer));
$this->composer->setInstallationManager($this->installationManager);
}
开发者ID:SylvainSimon,项目名称:Metinify,代码行数:23,代码来源:ProcessTest.php
示例13: build
public function build($rootDirectory, $optimize = false, $noDevMode = false)
{
$packages = $this->loadPackages($rootDirectory);
$evm = new EventDispatcher(new Composer(), $this->io);
$generator = new AutoloadGenerator($evm, $this->io);
$generator->setDevMode(!$noDevMode);
$installationManager = new InstallationManager();
$installationManager->addInstaller(new FiddlerInstaller());
$this->io->write('Building fiddler.json projects.');
foreach ($packages as $packageName => $config) {
if (strpos($packageName, 'vendor') === 0) {
continue;
}
$this->io->write(' [Build] <info>' . $packageName . '</info>');
$mainPackage = new Package($packageName, "@stable", "@stable");
$mainPackage->setType('fiddler');
$mainPackage->setAutoload($config['autoload']);
$mainPackage->setDevAutoload($config['autoload-dev']);
$localRepo = new FiddlerInstalledRepository();
$this->resolvePackageDependencies($localRepo, $packages, $packageName);
$composerConfig = new Config(true, $rootDirectory);
$composerConfig->merge(array('config' => array('vendor-dir' => $config['path'] . '/vendor')));
$generator->dump($composerConfig, $localRepo, $mainPackage, $installationManager, 'composer', $optimize);
$binDir = $config['path'] . '/vendor/bin';
// remove old symlinks
array_map('unlink', glob($binDir . '/*'));
foreach ($localRepo->getPackages() as $package) {
foreach ($package->getBinaries() as $binary) {
if (!is_dir($binDir)) {
mkdir($binDir, 0755, true);
}
$binFile = $binDir . '/' . basename($binary);
symlink($rootDirectory . '/' . $binary, $binFile);
}
}
}
}
开发者ID:JasLin,项目名称:fiddler,代码行数:37,代码来源:Build.php
示例14: purgePackages
/**
* @param WritableRepositoryInterface $repo repository to purge packages from
* @param Installer\InstallationManager $im manager to check whether packages are still installed
*/
protected function purgePackages(WritableRepositoryInterface $repo, Installer\InstallationManager $im)
{
foreach ($repo->getPackages() as $package) {
if (!$im->isPackageInstalled($repo, $package)) {
$repo->removePackage($package);
}
}
}
开发者ID:tommygoud,项目名称:composer,代码行数:12,代码来源:Factory.php
示例15: buildPackageMap
public function buildPackageMap(InstallationManager $installationManager, PackageInterface $mainPackage, array $packages)
{
// build package => install path map
$packageMap = array();
array_unshift($packages, $mainPackage);
foreach ($packages as $package) {
if ($package instanceof AliasPackage) {
continue;
}
if ($package === $mainPackage) {
$packageMap[] = array($mainPackage, '');
continue;
}
$packageMap[] = array($package, $installationManager->getInstallPath($package));
}
return $packageMap;
}
开发者ID:rkallensee,项目名称:composer,代码行数:17,代码来源:AutoloadGenerator.php
示例16: buildPackageMap
public function buildPackageMap(InstallationManager $installationManager, PackageInterface $mainPackage, array $packages)
{
// build package => install path map
$packageMap = array();
$packages[] = $mainPackage;
// sort packages by dependencies
usort($packages, function (PackageInterface $a, PackageInterface $b) {
foreach (array_merge($a->getRequires(), $a->getDevRequires()) as $link) {
if (in_array($link->getTarget(), $b->getNames())) {
return 1;
}
}
foreach (array_merge($b->getRequires(), $b->getDevRequires()) as $link) {
if (in_array($link->getTarget(), $a->getNames())) {
return -1;
}
}
return strcmp($a->getName(), $b->getName());
});
foreach ($packages as $package) {
if ($package instanceof AliasPackage) {
continue;
}
if ($package === $mainPackage) {
$packageMap[] = array($mainPackage, '');
continue;
}
$packageMap[] = array($package, $installationManager->getInstallPath($package));
}
return $packageMap;
}
开发者ID:rufinus,项目名称:composer,代码行数:31,代码来源:AutoloadGenerator.php
示例17: buildPackageMap
public function buildPackageMap(InstallationManager $installationManager, PackageInterface $mainPackage, array $packages)
{
// build package => install path map
$packageMap = array();
// add main package
$packageMap[] = array($mainPackage, '');
foreach ($packages as $package) {
$packageMap[] = array($package, $installationManager->getInstallPath($package));
}
return $packageMap;
}
开发者ID:natxet,项目名称:composer,代码行数:11,代码来源:AutoloadGenerator.php
示例18: 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
示例19: buildPackageMap
public function buildPackageMap(InstallationManager $installationManager, PackageInterface $mainPackage, array $packages)
{
// build package => install path map
$packageMap = array(array($mainPackage, ''));
foreach ($packages as $package) {
if ($package instanceof AliasPackage) {
continue;
}
$this->validatePackage($package);
$packageMap[] = array($package, $installationManager->getInstallPath($package));
}
return $packageMap;
}
开发者ID:aminembarki,项目名称:composer,代码行数:13,代码来源:AutoloadGenerator.php
示例20: mirrorDirectory
/**
* @param string $packageName
* @param string $sourceDirectory
* @param string $targetDirectory
*/
protected static function mirrorDirectory($packageName, $sourceDirectory, $targetDirectory)
{
$packages = static::$localRepository->findPackages($packageName, null);
foreach ($packages as $package) {
if (static::$installationManager->getInstaller($package->getType())->isInstalled(static::$localRepository, $package)) {
static::getFileSystem()->mirror(static::$installationManager->getInstallPath($package) . '/' . ltrim($sourceDirectory, '/'), $targetDirectory, null, ['copy_on_windows']);
return;
}
}
}
开发者ID:ichhabrecht,项目名称:git-checker,代码行数:15,代码来源:Installer.php
注:本文中的Composer\Installer\InstallationManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论