本文整理汇总了PHP中Composer\Repository\InstalledRepositoryInterface类的典型用法代码示例。如果您正苦于以下问题:PHP InstalledRepositoryInterface类的具体用法?PHP InstalledRepositoryInterface怎么用?PHP InstalledRepositoryInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了InstalledRepositoryInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isPackageInstalled
public function isPackageInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
{
if ($package instanceof AliasPackage) {
return $repo->hasPackage($package) && $this->isPackageInstalled($repo, $package->getAliasOf());
}
return $this->getInstaller($package->getType())->isInstalled($repo, $package);
}
示例2: uninstall
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
{
if (!$repo->hasPackage($package)) {
throw new \InvalidArgumentException('Package is not installed: ' . $package);
}
$repo->removePackage($package);
}
示例3: uninstall
/**
* {@inheritDoc}
*/
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
{
if (!$repo->hasPackage($package)) {
return;
}
$this->removeBinaries($package);
$repo->removePackage($package);
}
示例4: uninstall
/**
* {@inheritDoc}
*/
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
{
if (!$repo->hasPackage($package)) {
// TODO throw exception again here, when update is fixed and we don't have to remove+install (see #125)
return;
throw new \InvalidArgumentException('Package is not installed: ' . $package);
}
$repo->removePackage($package);
}
示例5: uninstall
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
{
if (!$repo->hasPackage($package)) {
throw new \InvalidArgumentException('Package is not installed: ' . $package);
}
$repo->removePackage($package);
$installPath = $this->getInstallPath($package);
$this->io->write(sprintf('Deleting %s - %s', $installPath, $this->filesystem->removeDirectory($installPath) ? '<comment>deleted</comment>' : '<error>not deleted</error>'));
}
示例6: isSymfonyPackagePresent
private function isSymfonyPackagePresent(InstalledRepositoryInterface $repo, PackageInterface $package)
{
foreach ($repo->getPackages() as $installedPackage) {
/* @var PackageInterface $installedPackage */
if ($installedPackage->getName() == 'symfony/symfony') {
return true;
}
}
return false;
}
示例7: updateCode
public function updateCode(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
{
if (!$repo->hasPackage($initial)) {
throw new \InvalidArgumentException('Package is not installed: ' . $initial);
}
if ($initial->getInstallationSource() == 'source' && $initial->getSourceType() == 'git' && $target->getSourceType() == 'git') {
$this->downloadManager->update($initial, $target, $this->getInstallPath($target));
} else {
$this->installCode($target);
}
$repo->removePackage($initial);
if (!$repo->hasPackage($target)) {
$repo->addPackage(clone $target);
}
}
示例8: install
/**
* {@inheritDoc}
*/
public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
{
// Debug
$this->debug = $this->isDebug($package);
// Composer stuff
$this->initializeVendorDir();
$downloadPath = $this->getInstallPath($package);
if (!is_readable($downloadPath) && $repo->hasPackage($package)) {
$this->removeBinaries($package);
}
if (!$repo->hasPackage($package)) {
$repo->addPackage(clone $package);
}
$this->downloadAndExtractFile($package);
}
开发者ID:azt3k,项目名称:non-destructive-archive-installer,代码行数:18,代码来源:NonDestructiveArchiveInstallerInstaller.php
示例9: uninstall
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
{
if (!$repo->hasPackage($package)) {
throw new \InvalidArgumentException('Package is not installed: ' . $package);
}
$this->removeCode($package);
$this->removeBinaries($package);
$repo->removePackage($package);
$downloadPath = $this->getPackageBasePath($package);
if (strpos($package->getName(), '/')) {
$packageVendorDir = dirname($downloadPath);
if (is_dir($packageVendorDir) && $this->filesystem->isDirEmpty($packageVendorDir)) {
@rmdir($packageVendorDir);
}
}
}
示例10: dump
public function dump(Config $config, InstalledRepositoryInterface $localRepo, PackageInterface $mainPackage, InstallationManager $installationManager, $targetDir, $scanPsr0Packages = false, $suffix = '')
{
if ($this->classMapAuthoritative) {
// Force scanPsr0Packages when classmap is authoritative
$scanPsr0Packages = true;
}
$filesystem = new Filesystem();
$filesystem->ensureDirectoryExists($config->get('vendor-dir'));
$cwd = getcwd();
$basePath = $filesystem->normalizePath($cwd);
$vendorPath = $filesystem->normalizePath(realpath($config->get('vendor-dir')));
$targetDir = $vendorPath . '/' . $targetDir;
$filesystem->ensureDirectoryExists($targetDir);
$useGlobalIncludePath = (bool) $config->get('use-include-path');
$prependAutoloader = $config->get('prepend-autoloader') === false ? 'false' : 'true';
$classMapAuthoritative = $config->get('classmap-authoritative');
$vendorPathCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true);
$vendorPathToTargetDirCode = $filesystem->findShortestPathCode($vendorPath, realpath($targetDir), true);
$appBaseDirCode = $filesystem->findShortestPathCode($vendorPath, $basePath, true);
$appBaseDirCode = str_replace('__DIR__', '$vendorDir', $appBaseDirCode);
// add 5.2 compat
$vendorPathCode = str_replace('__DIR__', 'dirname(__FILE__)', $vendorPathCode);
$vendorPathToTargetDirCode = str_replace('__DIR__', 'dirname(__FILE__)', $vendorPathToTargetDirCode);
$packageMap = $this->buildPackageMap($installationManager, $mainPackage, $localRepo->getCanonicalPackages());
$autoloads = $this->parseAutoloads($packageMap, $mainPackage);
// add custom psr-0 autoloading if the root package has a target dir
$targetDirLoader = null;
$mainAutoload = $mainPackage->getAutoload();
if ($mainPackage->getTargetDir() && !empty($mainAutoload['psr-0'])) {
$levels = count(explode('/', $filesystem->normalizePath($mainPackage->getTargetDir())));
$prefixes = implode(', ', array_map(function ($prefix) {
return var_export($prefix, true);
}, array_keys($mainAutoload['psr-0'])));
$baseDirFromTargetDirCode = $filesystem->findShortestPathCode($targetDir, $basePath, true);
$targetDirLoader = <<<EOF
\tpublic static function autoload(\$class) {
\t\t\$dir = {$baseDirFromTargetDirCode}.'/';
\t\t\$prefixes = array({$prefixes});
\t\tforeach (\$prefixes as \$prefix) {
\t\t\tif (0 !== strpos(\$class, \$prefix)) {
\t\t\t\tcontinue;
\t\t\t}
\t\t\t\$path = explode(DIRECTORY_SEPARATOR, self::getClassPath(\$class));
\t\t\t\$path = \$dir.implode('/', array_slice(\$path, {$levels}));
\t\t\tif (!\$path = self::resolveIncludePath(\$path)) {
\t\t\t\treturn false;
\t\t\t}
\t\t\trequire \$path;
\t\t\treturn true;
\t\t}
\t}
EOF;
}
$filesCode = "";
$autoloads['files'] = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($autoloads['files']));
foreach ($autoloads['files'] as $functionFile) {
// don't include file if it is using PHP 5.3+ syntax
// https://bitbucket.org/xrstf/composer-php52/issue/4
if ($this->isPHP53($functionFile)) {
$filesCode .= '// require ' . $this->getPathCode($filesystem, $basePath, $vendorPath, $functionFile) . "; // disabled because of PHP 5.3 syntax\n";
} else {
$filesCode .= ' require ' . $this->getPathCode($filesystem, $basePath, $vendorPath, $functionFile) . ";\n";
}
}
if (!$suffix) {
$suffix = md5(uniqid('', true));
}
$includePathFile = $this->getIncludePathsFile($packageMap, $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode);
file_put_contents($vendorPath . '/autoload_52.php', $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix));
file_put_contents($targetDir . '/autoload_real_52.php', $this->getAutoloadRealFile(true, (bool) $includePathFile, $targetDirLoader, $filesCode, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader));
// use stream_copy_to_stream instead of copy
// to work around https://bugs.php.net/bug.php?id=64634
$sourceLoader = fopen(__DIR__ . '/ClassLoader.php', 'r');
$targetLoader = fopen($targetDir . '/ClassLoader52.php', 'w+');
stream_copy_to_stream($sourceLoader, $targetLoader);
fclose($sourceLoader);
fclose($targetLoader);
unset($sourceLoader, $targetLoader);
}
示例11: uninstall
/**
* {@inheritDoc}
*/
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
{
if (!$repo->hasPackage($package)) {
// TODO throw exception again here, when update is fixed and we don't have to remove+install (see #125)
return;
throw new \InvalidArgumentException('Package is not installed: ' . $package);
}
$downloadPath = $this->getInstallPath($package);
$this->removeCode($package);
$this->removeBinaries($package);
$repo->removePackage($package);
if (strpos($package->getName(), '/')) {
$packageVendorDir = dirname($downloadPath);
if (is_dir($packageVendorDir) && !glob($packageVendorDir . '/*')) {
@rmdir($packageVendorDir);
}
}
}
示例12: isPackageInstalled
public function isPackageInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
{
return $repo->hasPackage($package);
}
示例13: update
/**
* Updates a package
*
* @param \Composer\Repository\InstalledRepositoryInterface $repo
* @param \Composer\Package\PackageInterface $initial
* @param \Composer\Package\PackageInterface $target
* @throws \InvalidArgumentException
*/
public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
{
if (!$repo->hasPackage($initial)) {
throw new CoreInstaller\PackageNotInstalledException($initial);
}
$this->getDriver()->update($initial, $target);
$repo->removePackage($initial);
if (!$repo->hasPackage($target)) {
$repo->addPackage(clone $target);
}
}
示例14: update
/**
* @test
*/
public function update()
{
$initial = $this->createPackageMock();
$target = $this->createPackageMock();
$this->installer->expects($this->once())->method('update')->with($this->repository, $initial, $target);
$this->repository->expects($this->once())->method('hasPackage')->with($initial)->willReturn(true);
$this->createSolver()->update($this->repository, $initial, $target);
}
开发者ID:letudiant,项目名称:composer-shared-package-plugin,代码行数:11,代码来源:SharedPackageInstallerSolverSharedTest.php
示例15: 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;
}
}
}