本文整理汇总了PHP中Composer\Installer\InstallationManager::getInstaller方法的典型用法代码示例。如果您正苦于以下问题:PHP InstallationManager::getInstaller方法的具体用法?PHP InstallationManager::getInstaller怎么用?PHP InstallationManager::getInstaller使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\Installer\InstallationManager
的用法示例。
在下文中一共展示了InstallationManager::getInstaller方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
}
}
示例2: testAddGetInstaller
public function testAddGetInstaller()
{
$installer = $this->createInstallerMock();
$installer->expects($this->exactly(2))->method('supports')->will($this->returnCallback(function ($arg) {
return $arg === 'vendor';
}));
$manager = new InstallationManager('vendor');
$manager->addInstaller($installer);
$this->assertSame($installer, $manager->getInstaller('vendor'));
$this->setExpectedException('InvalidArgumentException');
$manager->getInstaller('unregistered');
}
示例3: 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);
}
示例4: getInstaller
function getInstaller($packageType)
{
// if we don't support this type at all, move along to the rest of the installers
if (!$this->wpInstaller->supports($packageType)) {
$this->io->write("Composer-WP installer does not support {$packageType}", true, IOInterface::DEBUG);
return parent::getInstaller($packageType);
}
// if we explicitly support this type, return the WP installer
if ($this->wpInstaller->prioritySupports($packageType)) {
$this->io->write("Composer-WP installer explicitly supports {$packageType}", true, IOInterface::DEBUG);
return $this->wpInstaller;
}
// otherwise, check to see if there is another installer that supports this type before we claim it
try {
// this may throw an InvalidArgumentException if no installer is found, but
// LibraryInstaller is a floozie and will take any package it can get its hands on
$installer = parent::getInstaller($packageType);
$class = get_class($installer);
// is the selected installer just the default one?
if ($class === 'Composer\\Installer\\LibraryInstaller') {
throw new \InvalidArgumentException();
}
$this->io->write("Composer-WP installer supports {$packageType} but gives priority to {$class}", true, IOInterface::DEBUG);
// set the path to false so we do not try again
$this->wpInstaller->setPath($packageType, false);
return $installer;
} catch (\InvalidArgumentException $e) {
$this->io->write("Composer-WP installer claims support for {$packageType}", true, IOInterface::DEBUG);
// no custom installer, let's take charge!
$this->wpInstaller->setPath($packageType);
return $this->wpInstaller;
}
}
示例5: supports
/**
* {@inheritDoc}
*
* @param string $packageType
* @return bool
*/
public function supports($packageType)
{
try {
return $this->installManager->getInstaller($packageType) instanceof InstallerInterface;
} catch (\InvalidArgumentException $e) {
return false;
}
}
示例6: testAddRemoveInstaller
public function testAddRemoveInstaller()
{
$installer = $this->createInstallerMock();
$installer->expects($this->exactly(2))->method('supports')->will($this->returnCallback(function ($arg) {
return $arg === 'vendor';
}));
$installer2 = $this->createInstallerMock();
$installer2->expects($this->exactly(1))->method('supports')->will($this->returnCallback(function ($arg) {
return $arg === 'vendor';
}));
$manager = new InstallationManager();
$manager->addInstaller($installer);
$this->assertSame($installer, $manager->getInstaller('vendor'));
$manager->addInstaller($installer2);
$this->assertSame($installer2, $manager->getInstaller('vendor'));
$manager->removeInstaller($installer2);
$this->assertSame($installer, $manager->getInstaller('vendor'));
}
示例7: 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);
}