当前位置: 首页>>代码示例>>PHP>>正文


PHP InstallationManager::getInstaller方法代码示例

本文整理汇总了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;
         }
     }
 }
开发者ID:ichhabrecht,项目名称:git-checker,代码行数:15,代码来源:Installer.php

示例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');
 }
开发者ID:norbe,项目名称:composer,代码行数:12,代码来源:InstallationManagerTest.php

示例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);
 }
开发者ID:mbolli,项目名称:drupal-tangler,代码行数:25,代码来源:Mapper.php

示例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;
     }
 }
开发者ID:balbuf,项目名称:composer-wp,代码行数:33,代码来源:InstallationManager.php

示例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;
     }
 }
开发者ID:socialengine,项目名称:composer-symlinker,代码行数:14,代码来源:LocalInstaller.php

示例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'));
 }
开发者ID:neon64,项目名称:composer,代码行数:18,代码来源:InstallationManagerTest.php

示例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);
 }
开发者ID:davidbarratt,项目名称:drupal-tangler,代码行数:17,代码来源:Mapper.php


注:本文中的Composer\Installer\InstallationManager::getInstaller方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。