當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Repository\InstalledRepositoryInterface類代碼示例

本文整理匯總了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);
 }
開發者ID:itillawarra,項目名稱:cmfive,代碼行數:7,代碼來源:InstallationManager.php

示例2: uninstall

 public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
 {
     if (!$repo->hasPackage($package)) {
         throw new \InvalidArgumentException('Package is not installed: ' . $package);
     }
     $repo->removePackage($package);
 }
開發者ID:itillawarra,項目名稱:cmfive,代碼行數:7,代碼來源:NoopInstaller.php

示例3: uninstall

 /**
  * {@inheritDoc}
  */
 public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
 {
     if (!$repo->hasPackage($package)) {
         return;
     }
     $this->removeBinaries($package);
     $repo->removePackage($package);
 }
開發者ID:itscaro,項目名稱:composer-global-installer,代碼行數:11,代碼來源:GlobalInstaller.php

示例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);
 }
開發者ID:ilosada,項目名稱:chamilo-lms-icpna,代碼行數:12,代碼來源:NoopInstaller.php

示例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>'));
 }
開發者ID:ddrozdik,項目名稱:dmaps,代碼行數:9,代碼來源:Installer.php

示例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;
 }
開發者ID:modera,項目名稱:composer-symfony-web-asset-installer-plugin,代碼行數:10,代碼來源:Installer.php

示例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);
     }
 }
開發者ID:claromentis,項目名稱:installer-composer-plugin,代碼行數:15,代碼來源:BaseInstaller.php

示例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);
         }
     }
 }
開發者ID:VicDeo,項目名稱:poc,代碼行數:16,代碼來源:LibraryInstaller.php

示例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);
    }
開發者ID:Garth619,項目名稱:Femi9,代碼行數:85,代碼來源:AutoloadGenerator.php

示例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);
         }
     }
 }
開發者ID:nickelc,項目名稱:composer,代碼行數:21,代碼來源:LibraryInstaller.php

示例12: isPackageInstalled

 public function isPackageInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
 {
     return $repo->hasPackage($package);
 }
開發者ID:alancleaver,項目名稱:composer,代碼行數:4,代碼來源:InstallationManagerMock.php

示例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);
     }
 }
開發者ID:netresearch,項目名稱:composer-installers,代碼行數:19,代碼來源:CoreInstaller.php

示例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;
         }
     }
 }
開發者ID:ichhabrecht,項目名稱:git-checker,代碼行數:15,代碼來源:Installer.php


注:本文中的Composer\Repository\InstalledRepositoryInterface類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。