• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Repository\RepositoryInterface类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Composer\Repository\RepositoryInterface的典型用法代码示例。如果您正苦于以下问题:PHP RepositoryInterface类的具体用法?PHP RepositoryInterface怎么用?PHP RepositoryInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了RepositoryInterface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: loadRepository

 public function loadRepository(RepositoryInterface $repo)
 {
     foreach ($repo->getPackages() as $package) {
         if ($package instanceof AliasPackage) {
             continue;
         }
         if ('composer-plugin' === $package->getType()) {
             $requiresComposer = null;
             foreach ($package->getRequires() as $link) {
                 if ($link->getTarget() == 'composer-plugin-api') {
                     $requiresComposer = $link->getConstraint();
                 }
             }
             if (!$requiresComposer) {
                 throw new \RuntimeException("Plugin " . $package->getName() . " is missing a require statement for a version of the composer-plugin-api package.");
             }
             if (!$requiresComposer->matches(new VersionConstraint('==', $this->versionParser->normalize(PluginInterface::PLUGIN_API_VERSION)))) {
                 $this->io->writeError("<warning>The plugin " . $package->getName() . " requires a version of composer-plugin-api that does not match your composer installation. You may need to run composer update with the '--no-plugins' option.</warning>");
             }
             $this->registerPackage($package);
         }
         if ('composer-installer' === $package->getType()) {
             $this->registerPackage($package);
         }
     }
 }
开发者ID:VicDeo,项目名称:poc,代码行数:26,代码来源:PluginManager.php


示例2: update

 /**
  * Update a project
  *
  * @param \Packagist\WebBundle\Entity\Package $package
  * @param RepositoryInterface $repository the repository instance used to update from
  * @param int $flags a few of the constants of this class
  * @param \DateTime $start
  */
 public function update(Package $package, RepositoryInterface $repository, $flags = 0, \DateTime $start = null)
 {
     $blacklist = '{^symfony/symfony (2.0.[456]|dev-charset|dev-console)}i';
     if (null === $start) {
         $start = new \DateTime();
     }
     $pruneDate = clone $start;
     $pruneDate->modify('-8days');
     $versions = $repository->getPackages();
     $em = $this->doctrine->getManager();
     if ($repository->hadInvalidBranches()) {
         throw new InvalidRepositoryException('Some branches contained invalid data and were discarded, it is advised to review the log and fix any issues present in branches');
     }
     usort($versions, function ($a, $b) {
         $aVersion = $a->getVersion();
         $bVersion = $b->getVersion();
         if ($aVersion === '9999999-dev' || 'dev-' === substr($aVersion, 0, 4)) {
             $aVersion = 'dev';
         }
         if ($bVersion === '9999999-dev' || 'dev-' === substr($bVersion, 0, 4)) {
             $bVersion = 'dev';
         }
         if ($aVersion === $bVersion) {
             return $a->getReleaseDate() > $b->getReleaseDate() ? 1 : -1;
         }
         return version_compare($a->getVersion(), $b->getVersion());
     });
     $versionRepository = $this->doctrine->getRepository('PackagistWebBundle:Version');
     if ($flags & self::DELETE_BEFORE) {
         foreach ($package->getVersions() as $version) {
             $versionRepository->remove($version);
         }
         $em->flush();
         $em->refresh($package);
     }
     foreach ($versions as $version) {
         if ($version instanceof AliasPackage) {
             continue;
         }
         if (preg_match($blacklist, $version->getName() . ' ' . $version->getPrettyVersion())) {
             continue;
         }
         $this->updateInformation($package, $version, $flags);
         $em->flush();
     }
     // remove outdated versions
     foreach ($package->getVersions() as $version) {
         if ($version->getUpdatedAt() < $pruneDate) {
             $versionRepository->remove($version);
         }
     }
     $package->setUpdatedAt(new \DateTime());
     $package->setCrawledAt(new \DateTime());
     $em->flush();
 }
开发者ID:rdohms,项目名称:packagist,代码行数:63,代码来源:Updater.php


示例3: addRepository

 /**
  * Adds a repository and its packages to this package pool
  *
  * @param RepositoryInterface $repo A package repository
  */
 public function addRepository(RepositoryInterface $repo)
 {
     $this->repositories[] = $repo;
     foreach ($repo->getPackages() as $package) {
         $package->setId(count($this->packages) + 1);
         $this->packages[] = $package;
         foreach ($package->getNames() as $name) {
             $this->packageByName[$name][] = $package;
         }
     }
 }
开发者ID:nlegoff,项目名称:composer,代码行数:16,代码来源:Pool.php


示例4: filterRequiredPackages

 private function filterRequiredPackages(RepositoryInterface $repo, PackageInterface $package, $bucket = array())
 {
     $requires = array_keys($package->getRequires());
     $packageListNames = array_keys($bucket);
     $packages = array_filter($repo->getPackages(), function ($package) use($requires, $packageListNames) {
         return in_array($package->getName(), $requires) && !in_array($package->getName(), $packageListNames);
     });
     $bucket = $this->appendPackages($packages, $bucket);
     foreach ($packages as $package) {
         $bucket = $this->filterRequiredPackages($repo, $package, $bucket);
     }
     return $bucket;
 }
开发者ID:VicDeo,项目名称:poc,代码行数:13,代码来源:LicensesCommand.php


示例5: setUp

 public function setUp()
 {
     $this->composerMock = $this->getMockBuilder(Composer::class)->disableOriginalConstructor()->getMock();
     $this->lockerMock = $this->getMockBuilder(Locker::class)->disableOriginalConstructor()->getMock();
     $this->lockerRepositoryMock = $this->getMockForAbstractClass(\Composer\Repository\RepositoryInterface::class);
     $this->packageMock = $this->getMockForAbstractClass(\Composer\Package\CompletePackageInterface::class);
     $this->lockerMock->method('getLockedRepository')->willReturn($this->lockerRepositoryMock);
     $this->packageMock->method('getType')->willReturn('metapackage');
     $this->packageMock->method('getPrettyName')->willReturn('magento/product-test-package-name');
     $this->packageMock->method('getName')->willReturn('magento/product-test-package-name');
     $this->packageMock->method('getPrettyVersion')->willReturn('123.456.789');
     $this->lockerRepositoryMock->method('getPackages')->willReturn([$this->packageMock]);
     $objectManager = new ObjectManager($this);
     $this->composerInformation = $objectManager->getObject(\Magento\Framework\Composer\ComposerInformation::class, ['composer' => $this->composerMock, 'locker' => $this->lockerMock]);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:15,代码来源:ComposerInformationTest.php


示例6: addRepository

 /**
  * Adds a repository and its packages to this package pool
  *
  * @param RepositoryInterface $repo        A package repository
  * @param array               $rootAliases
  */
 public function addRepository(RepositoryInterface $repo, $rootAliases = array())
 {
     if ($repo instanceof CompositeRepository) {
         $repos = $repo->getRepositories();
     } else {
         $repos = array($repo);
     }
     foreach ($repos as $repo) {
         $this->repositories[] = $repo;
         $exempt = $repo instanceof PlatformRepository || $repo instanceof InstalledRepositoryInterface;
         if ($repo instanceof ComposerRepository && $repo->hasProviders()) {
             $this->providerRepos[] = $repo;
             $repo->setRootAliases($rootAliases);
             $repo->resetPackageIds();
         } else {
             foreach ($repo->getPackages() as $package) {
                 $names = $package->getNames();
                 $stability = $package->getStability();
                 if ($exempt || $this->isPackageAcceptable($names, $stability)) {
                     $package->setId($this->id++);
                     $this->packages[] = $package;
                     $this->packageByExactName[$package->getName()][$package->id] = $package;
                     foreach ($names as $provided) {
                         $this->packageByName[$provided][] = $package;
                     }
                     // handle root package aliases
                     $name = $package->getName();
                     if (isset($rootAliases[$name][$package->getVersion()])) {
                         $alias = $rootAliases[$name][$package->getVersion()];
                         if ($package instanceof AliasPackage) {
                             $package = $package->getAliasOf();
                         }
                         $aliasPackage = new AliasPackage($package, $alias['alias_normalized'], $alias['alias']);
                         $aliasPackage->setRootPackageAlias(true);
                         $aliasPackage->setId($this->id++);
                         $package->getRepository()->addPackage($aliasPackage);
                         $this->packages[] = $aliasPackage;
                         $this->packageByExactName[$aliasPackage->getName()][$aliasPackage->id] = $aliasPackage;
                         foreach ($aliasPackage->getNames() as $name) {
                             $this->packageByName[$name][] = $aliasPackage;
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:zqcloveping,项目名称:pagekit,代码行数:53,代码来源:Pool.php


示例7: output

 /**
  * Output suggested packages.
  * Do not list the ones already installed if installed repository provided.
  *
  * @param  RepositoryInterface       $installedRepo Installed packages
  * @return SuggestedPackagesReporter
  */
 public function output(RepositoryInterface $installedRepo = null)
 {
     $suggestedPackages = $this->getPackages();
     $installedPackages = array();
     if (null !== $installedRepo && !empty($suggestedPackages)) {
         foreach ($installedRepo->getPackages() as $package) {
             $installedPackages = array_merge($installedPackages, $package->getNames());
         }
     }
     foreach ($suggestedPackages as $suggestion) {
         if (in_array($suggestion['target'], $installedPackages)) {
             continue;
         }
         $this->io->writeError(sprintf('%s suggests installing %s (%s)', $suggestion['source'], $suggestion['target'], $suggestion['reason']));
     }
     return $this;
 }
开发者ID:neon64,项目名称:composer,代码行数:24,代码来源:SuggestedPackagesReporter.php


示例8: addRepository

 public function addRepository(RepositoryInterface $repository)
 {
     if ($repository instanceof self) {
         foreach ($repository->getRepositories() as $repo) {
             $this->addRepository($repo);
         }
     } else {
         $this->repositories[] = $repository;
     }
 }
开发者ID:itillawarra,项目名称:cmfive,代码行数:10,代码来源:CompositeRepository.php


示例9: collectData

 public function collectData(RepositoryInterface $repo)
 {
     $puzzleData = [];
     foreach ($repo->getPackages() as $package) {
         /** @var Package $package */
         $extra = $package->getExtra();
         if (!empty($extra["downsider-puzzle-di"]) && is_array($extra["downsider-puzzle-di"])) {
             foreach ($extra["downsider-puzzle-di"] as $key => $config) {
                 if ($key == (string) (int) $key) {
                     continue;
                 }
                 if (!array_key_exists($key, $puzzleData)) {
                     $puzzleData[$key] = array();
                 }
                 $puzzleConfig = ["name" => $package->getName(), "path" => $this->installationManager->getInstallPath($package) . "/" . $config["path"]];
                 if (!empty($config["alias"])) {
                     $puzzleConfig["alias"] = $config["alias"];
                 }
                 $puzzleData[$key][] = $puzzleConfig;
             }
         }
     }
     return $puzzleData;
 }
开发者ID:downsider,项目名称:puzzle-di,代码行数:24,代码来源:PuzzleDataCollector.php


示例10: addRepository

 /**
  * Adds a repository and its packages to this package pool
  *
  * @param RepositoryInterface $repo A package repository
  */
 public function addRepository(RepositoryInterface $repo)
 {
     if ($repo instanceof CompositeRepository) {
         $repos = $repo->getRepositories();
     } else {
         $repos = array($repo);
     }
     $id = count($this->packages) + 1;
     foreach ($repos as $repo) {
         $this->repositories[] = $repo;
         $exempt = $repo instanceof PlatformRepository || $repo instanceof InstalledRepositoryInterface;
         foreach ($repo->getPackages() as $package) {
             $name = $package->getName();
             $stability = $package->getStability();
             if ($exempt || !isset($this->stabilityFlags[$name]) && isset($this->acceptableStabilities[$stability]) || isset($this->stabilityFlags[$name]) && BasePackage::$stabilities[$stability] <= $this->stabilityFlags[$name]) {
                 $package->setId($id++);
                 $this->packages[] = $package;
                 foreach ($package->getNames() as $name) {
                     $this->packageByName[$name][] = $package;
                 }
             }
         }
     }
 }
开发者ID:nickl-,项目名称:composer,代码行数:29,代码来源:Pool.php


示例11: dump

    public function dump(Config $config, RepositoryInterface $localRepo, PackageInterface $mainPackage, InstallationManager $installationManager, $targetDir, $scanPsr0Packages = false, $suffix = '')
    {
        $filesystem = new Filesystem();
        $filesystem->ensureDirectoryExists($config->get('vendor-dir'));
        $vendorPath = strtr(realpath($config->get('vendor-dir')), '\\', '/');
        $targetDir = $vendorPath . '/' . $targetDir;
        $filesystem->ensureDirectoryExists($targetDir);
        $relVendorPath = $filesystem->findShortestPath(getcwd(), $vendorPath, true);
        $vendorPathCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true);
        $vendorPathToTargetDirCode = $filesystem->findShortestPathCode($vendorPath, realpath($targetDir), true);
        $appBaseDirCode = $filesystem->findShortestPathCode($vendorPath, getcwd(), true);
        $appBaseDirCode = str_replace('__DIR__', '$vendorDir', $appBaseDirCode);
        $namespacesFile = <<<EOF
<?php

// autoload_namespaces.php generated by Composer

\$vendorDir = {$vendorPathCode};
\$baseDir = {$appBaseDirCode};

return array(

EOF;
        $packageMap = $this->buildPackageMap($installationManager, $mainPackage, $localRepo->getPackages());
        $autoloads = $this->parseAutoloads($packageMap);
        foreach ($autoloads['psr-0'] as $namespace => $paths) {
            $exportedPaths = array();
            foreach ($paths as $path) {
                $exportedPaths[] = $this->getPathCode($filesystem, $relVendorPath, $vendorPath, $path);
            }
            $exportedPrefix = var_export($namespace, true);
            $namespacesFile .= "    {$exportedPrefix} => ";
            if (count($exportedPaths) > 1) {
                $namespacesFile .= "array(" . implode(', ', $exportedPaths) . "),\n";
            } else {
                $namespacesFile .= $exportedPaths[0] . ",\n";
            }
        }
        $namespacesFile .= ");\n";
        $classmapFile = <<<EOF
<?php

// autoload_classmap.php generated by Composer

\$vendorDir = {$vendorPathCode};
\$baseDir = {$appBaseDirCode};

return array(

EOF;
        // 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('/', trim(strtr($mainPackage->getTargetDir(), '\\', '/'), '/')));
            $prefixes = implode(', ', array_map(function ($prefix) {
                return var_export($prefix, true);
            }, array_keys($mainAutoload['psr-0'])));
            $baseDirFromTargetDirCode = $filesystem->findShortestPathCode($targetDir, getcwd(), true);
            $targetDirLoader = <<<EOF

    public static function autoload(\$class)
    {
        \$dir = {$baseDirFromTargetDirCode} . '/';
        \$prefixes = array({$prefixes});
        foreach (\$prefixes as \$prefix) {
            if (0 !== strpos(\$class, \$prefix)) {
                continue;
            }
            \$path = \$dir . implode('/', array_slice(explode('\\\\', \$class), {$levels})).'.php';
            if (!\$path = stream_resolve_include_path(\$path)) {
                return false;
            }
            require \$path;

            return true;
        }
    }

EOF;
        }
        // flatten array
        $classMap = array();
        $autoloads['classmap'] = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($autoloads['classmap']));
        if ($scanPsr0Packages) {
            foreach ($autoloads['psr-0'] as $namespace => $paths) {
                foreach ($paths as $dir) {
                    $dir = $this->getPath($filesystem, $relVendorPath, $vendorPath, $dir);
                    $whitelist = sprintf('{%s/%s.+(?<!(?<!/)Test\\.php)$}', preg_quote(rtrim($dir, '/')), strpos($namespace, '_') === false ? preg_quote(strtr($namespace, '\\', '/')) : '');
                    foreach (ClassMapGenerator::createMap($dir, $whitelist) as $class => $path) {
                        if ('' === $namespace || 0 === strpos($class, $namespace)) {
                            $path = '/' . $filesystem->findShortestPath(getcwd(), $path, true);
                            if (!isset($classMap[$class])) {
                                $classMap[$class] = '$baseDir . ' . var_export($path, true) . ",\n";
                            }
                        }
                    }
                }
            }
        }
//.........这里部分代码省略.........
开发者ID:rufinus,项目名称:composer,代码行数:101,代码来源:AutoloadGenerator.php


示例12: markAliasUninstalled

 /**
  * Executes markAlias operation.
  *
  * @param RepositoryInterface           $repo      repository in which to check
  * @param MarkAliasUninstalledOperation $operation operation instance
  */
 public function markAliasUninstalled(RepositoryInterface $repo, MarkAliasUninstalledOperation $operation)
 {
     $package = $operation->getPackage();
     $repo->removePackage($package);
 }
开发者ID:nickelc,项目名称:composer,代码行数:11,代码来源:InstallationManager.php


示例13: printVersions

 /**
  * prints all available versions of this package and highlights the installed one if any
  */
 protected function printVersions(InputInterface $input, OutputInterface $output, PackageInterface $package, RepositoryInterface $installedRepo, RepositoryInterface $repos)
 {
     if ($input->getArgument('version')) {
         $output->writeln('<info>version</info>  : ' . $package->getPrettyVersion());
         return;
     }
     $versions = array();
     foreach ($repos->findPackages($package->getName()) as $version) {
         $versions[$version->getPrettyVersion()] = $version->getVersion();
     }
     uasort($versions, 'version_compare');
     $versions = implode(', ', array_keys(array_reverse($versions)));
     // highlight installed version
     if ($installedRepo->hasPackage($package)) {
         $versions = str_replace($package->getPrettyVersion(), '<info>* ' . $package->getPrettyVersion() . '</info>', $versions);
     }
     $output->writeln('<info>versions</info> : ' . $versions);
 }
开发者ID:nicodmf,项目名称:composer,代码行数:21,代码来源:ShowCommand.php


示例14: mapFromRepo

 protected function mapFromRepo(RepositoryInterface $repo)
 {
     $map = array();
     foreach ($repo->getPackages() as $package) {
         $map[$package->getId()] = true;
     }
     return $map;
 }
开发者ID:natxet,项目名称:composer,代码行数:8,代码来源:DefaultPolicyTest.php


示例15: calculateDependencyMap

 /**
  * Build dependency graph of installed packages.
  *
  * @param RepositoryInterface $repository
  *
  * @return array
  */
 protected function calculateDependencyMap(RepositoryInterface $repository, $inverted = false)
 {
     $dependencyMap = array();
     /** @var \Composer\Package\PackageInterface $package */
     foreach ($repository->getPackages() as $package) {
         $this->fillDependencyMap($package, $dependencyMap, $inverted);
     }
     return $dependencyMap;
 }
开发者ID:contao-community-alliance,项目名称:composer-client,代码行数:16,代码来源:AbstractController.php


示例16: printVersions

 /**
  * prints all available versions of this package and highlights the installed one if any
  */
 protected function printVersions(InputInterface $input, OutputInterface $output, CompletePackageInterface $package, array $versions, RepositoryInterface $installedRepo, RepositoryInterface $repos)
 {
     uasort($versions, 'version_compare');
     $versions = array_keys(array_reverse($versions));
     // highlight installed version
     if ($installedRepo->hasPackage($package)) {
         $installedVersion = $package->getPrettyVersion();
         $key = array_search($installedVersion, $versions);
         if (false !== $key) {
             $versions[$key] = '<info>* ' . $installedVersion . '</info>';
         }
     }
     $versions = implode(', ', $versions);
     $output->writeln('<info>versions</info> : ' . $versions);
 }
开发者ID:aminembarki,项目名称:composer,代码行数:18,代码来源:ShowCommand.php


示例17: getCurrentPackages

 /**
  * Loads the most "current" list of packages that are installed meaning from lock ideally or from installed repo as fallback
  * @param  RepositoryInterface $installedRepo
  * @return array
  */
 private function getCurrentPackages($installedRepo)
 {
     if ($this->locker->isLocked()) {
         try {
             return $this->locker->getLockedRepository(true)->getPackages();
         } catch (\RuntimeException $e) {
             // fetch only non-dev packages from lock if doing a dev update fails due to a previously incomplete lock file
             return $this->locker->getLockedRepository()->getPackages();
         }
     }
     return $installedRepo->getPackages();
 }
开发者ID:Rudloff,项目名称:composer,代码行数:17,代码来源:Installer.php


示例18: dump

    public function dump(RepositoryInterface $localRepo, PackageInterface $mainPackage, InstallationManager $installationManager, $targetDir, $bcLinks = false)
    {
        $filesystem = new Filesystem();
        $filesystem->ensureDirectoryExists($installationManager->getVendorPath());
        $filesystem->ensureDirectoryExists($targetDir);
        $vendorPath = strtr(realpath($installationManager->getVendorPath()), '\\', '/');
        $relVendorPath = $filesystem->findShortestPath(getcwd(), $vendorPath, true);
        $vendorPathCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true);
        $vendorPathToTargetDirCode = $filesystem->findShortestPathCode($vendorPath, realpath($targetDir), true);
        $appBaseDirCode = $filesystem->findShortestPathCode($vendorPath, getcwd(), true);
        $appBaseDirCode = str_replace('__DIR__', '$vendorDir', $appBaseDirCode);
        $namespacesFile = <<<EOF
<?php

// autoload_namespace.php generated by Composer

\$vendorDir = {$vendorPathCode};
\$baseDir = {$appBaseDirCode};

return array(

EOF;
        $packageMap = $this->buildPackageMap($installationManager, $mainPackage, $localRepo->getPackages());
        $autoloads = $this->parseAutoloads($packageMap);
        foreach ($autoloads['psr-0'] as $namespace => $paths) {
            $exportedPaths = array();
            foreach ($paths as $path) {
                $exportedPaths[] = $this->getPathCode($filesystem, $relVendorPath, $vendorPath, $path);
            }
            $exportedPrefix = var_export($namespace, true);
            $namespacesFile .= "    {$exportedPrefix} => ";
            if (count($exportedPaths) > 1) {
                $namespacesFile .= "array(" . implode(', ', $exportedPaths) . "),\n";
            } else {
                $namespacesFile .= $exportedPaths[0] . ",\n";
            }
        }
        $namespacesFile .= ");\n";
        $classmapFile = <<<EOF
<?php

// autoload_classmap.php generated by Composer

\$vendorDir = {$vendorPathCode};
\$baseDir = {$appBaseDirCode};

return array(

EOF;
        // add custom psr-0 autoloading if the root package has a target dir
        $targetDirLoader = null;
        $mainAutoload = $mainPackage->getAutoload();
        if ($mainPackage->getTargetDir() && $mainAutoload['psr-0']) {
            $levels = count(explode('/', trim(strtr($mainPackage->getTargetDir(), '\\', '/'), '/')));
            $prefixes = implode(', ', array_map(function ($prefix) {
                return var_export($prefix, true);
            }, array_keys($mainAutoload['psr-0'])));
            $baseDirFromVendorDirCode = $filesystem->findShortestPathCode($vendorPath, getcwd(), true);
            $targetDirLoader = <<<EOF
    spl_autoload_register(function(\$class) {
        \$dir = {$baseDirFromVendorDirCode} . '/';
        \$prefixes = array({$prefixes});
        foreach (\$prefixes as \$prefix) {
            if (0 !== strpos(\$class, \$prefix)) {
                continue;
            }
            \$path = \$dir . implode('/', array_slice(explode('\\\\', \$class), {$levels})).'.php';
            if (!stream_resolve_include_path(\$path)) {
                return false;
            }
            require_once \$path;

            return true;
        }
    });


EOF;
        }
        // flatten array
        $autoloads['classmap'] = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($autoloads['classmap']));
        foreach ($autoloads['classmap'] as $dir) {
            foreach (ClassMapGenerator::createMap($dir) as $class => $path) {
                $path = '/' . $filesystem->findShortestPath(getcwd(), $path, true);
                $classmapFile .= '    ' . var_export($class, true) . ' => $baseDir . ' . var_export($path, true) . ",\n";
            }
        }
        $classmapFile .= ");\n";
        file_put_contents($targetDir . '/autoload_namespaces.php', $namespacesFile);
        file_put_contents($targetDir . '/autoload_classmap.php', $classmapFile);
        if ($includePathFile = $this->getIncludePathsFile($packageMap, $filesystem, $relVendorPath, $vendorPath, $vendorPathCode, $appBaseDirCode)) {
            file_put_contents($targetDir . '/include_paths.php', $includePathFile);
        }
        file_put_contents($vendorPath . '/autoload.php', $this->getAutoloadFile($vendorPathToTargetDirCode, true, true, (bool) $includePathFile, $targetDirLoader));
        copy(__DIR__ . '/ClassLoader.php', $targetDir . '/ClassLoader.php');
        // TODO BC feature, remove after June 15th
        if ($bcLinks) {
            $filesystem->ensureDirectoryExists($vendorPath . '/.composer');
            $deprecated = "// Deprecated file, use the one in root of vendor dir\n" . "trigger_error(__FILE__.' is deprecated, please use vendor/autoload.php or vendor/composer/autoload_* instead'.PHP_EOL.'See https://groups.google.com/forum/#!msg/composer-dev/fWIs3KocwoA/nU3aLko9LhQJ for details', E_USER_DEPRECATED);\n";
            file_put_contents($vendorPath . '/.composer/autoload_namespaces.php', "<?php\n{$deprecated}\nreturn include dirname(__DIR__).'/composer/autoload_namespaces.php';\n");
//.........这里部分代码省略.........
开发者ID:nicodmf,项目名称:composer,代码行数:101,代码来源:AutoloadGenerator.php


示例19: uninstall

 public function uninstall(RepositoryInterface $repo, UninstallOperation $operation)
 {
     $this->uninstalled[] = $operation->getPackage();
     $this->trace[] = (string) $operation;
     $repo->removePackage($operation->getPackage());
 }
开发者ID:alancleaver,项目名称:composer,代码行数:6,代码来源:InstallationManagerMock.php


示例20: dump

    public function dump(RepositoryInterface $localRepo, PackageInterface $mainPackage, InstallationManager $installationManager, $targetDir)
    {
        $autoloadFile = <<<'EOF'
<?php

// autoload.php generated by Composer
if (!class_exists('Composer\\Autoload\\ClassLoader', false)) {
    require __DIR__.'/ClassLoader.php';
}

$__composer_autoload_init = function() {
    $loader = new \Composer\Autoload\ClassLoader();

    $map = require __DIR__.'/autoload_namespaces.php';

    foreach ($map as $namespace => $path) {
        $loader->add($namespace, $path);
    }

    $loader->register();

    return $loader;
};

return $__composer_autoload_init();
EOF;
        $filesystem = new Filesystem();
        $vendorPath = strtr(realpath($installationManager->getVendorPath()), '\\', '/');
        $relVendorPath = $filesystem->findShortestPath(getcwd(), $vendorPath);
        $vendorDirCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true);
        $namespacesFile = <<<EOF
<?php

// autoload_namespace.php generated by Composer

\$vendorDir = {$vendorDirCode};

return array(

EOF;
        $packageMap = $this->buildPackageMap($installationManager, $mainPackage, $localRepo->getPackages());
        $autoloads = $this->parseAutoloads($packageMap);
        $appBaseDir = $filesystem->findShortestPathCode($vendorPath, getcwd(), true);
        $appBaseDir = str_replace('__DIR__', '$vendorDir', $appBaseDir);
        if (isset($autoloads['psr-0'])) {
            foreach ($autoloads['psr-0'] as $namespace => $paths) {
                $exportedPaths = array();
                foreach ($paths as $path) {
                    $path = strtr($path, '\\', '/');
                    $baseDir = '';
                    if (!$filesystem->isAbsolutePath($path)) {
                        // vendor dir == working dir
                        if (preg_match('{^(\\./?)?$}', $relVendorPath)) {
                            $path = '/' . $path;
                            $baseDir = '$vendorDir . ';
                        } elseif (strpos($path, $relVendorPath) === 0) {
                            // path starts with vendor dir
                            $path = substr($path, strlen($relVendorPath));
                            $baseDir = '$vendorDir . ';
                        } else {
                            $path = '/' . $path;
                            $baseDir = $appBaseDir . ' . ';
                        }
                    } elseif (strpos($path, $vendorPath) === 0) {
                        $path = substr($path, strlen($vendorPath));
                        $baseDir = '$vendorDir . ';
                    }
                    $exportedPaths[] = $baseDir . var_export($path, true);
                }
                $exportedPrefix = var_export($namespace, true);
                $namespacesFile .= "    {$exportedPrefix} => ";
                if (count($exportedPaths) > 1) {
                    $namespacesFile .= "array(" . implode(', ', $exportedPaths) . "),\n";
                } else {
                    $namespacesFile .= $exportedPaths[0] . ",\n";
                }
            }
        }
        $namespacesFile .= ");\n";
        file_put_contents($targetDir . '/autoload.php', $autoloadFile);
        file_put_contents($targetDir . '/autoload_namespaces.php', $namespacesFile);
        copy(__DIR__ . '/ClassLoader.php', $targetDir . '/ClassLoader.php');
    }
开发者ID:natxet,项目名称:composer,代码行数:83,代码来源:AutoloadGenerator.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Repository\RepositoryManager类代码示例发布时间:2022-05-23
下一篇:
PHP Repository\InstalledRepositoryInterface类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap