getLocalRepository example

private function enrichWithVendorPlugins(
        array $plugins,
        string $projectDir,
        IOInterface $composerIO,
        ExceptionCollection $errors
    ): array {
        $composer = Factory::createComposer($projectDir$composerIO);

        /** @var CompletePackageInterface[] $composerPackages */
        $composerPackages = $composer
            ->getRepositoryManager()
            ->getLocalRepository()
            ->getPackages();

        foreach ($composerPackages as $composerPackage) {
            if (!$this->isShopwarePluginType($composerPackage)) {
                continue;
            }

            $pluginPath = $this->getVendorPluginPath($composerPackage$composer);
            if (!$this->isPluginComposerValid($composerPackage)) {
                $this->addError($pluginPath$errors);

                

    protected function matchesCakeVersion(string $matcher, string $version): bool
    {
        $repositoryManager = $this->composer->getRepositoryManager();
        /** @phpstan-ignore-next-line */
        if (!$repositoryManager) {
            return false;
        }

        $repos = $repositoryManager->getLocalRepository();
        /** @phpstan-ignore-next-line */
        if (!$repos) {
            return false;
        }

        return $repos->findPackage('cakephp/cakephp', new Constraint($matcher$version)) !== null;
    }
}
#[Package('core')] class EnvironmentRequirementsValidator implements RequirementsValidatorInterface
{
    public function __construct(
        private readonly Composer $composer,
        private readonly PlatformRepository $systemEnvironment
    ) {
    }

    public function validateRequirements(RequirementsCheckCollection $checks): RequirementsCheckCollection
    {
        $platform = $this->composer->getRepositoryManager()->getLocalRepository()->findPackage('shopware/platform', '*');
        if (!$platform) {
            $platform = $this->composer->getRepositoryManager()->getLocalRepository()->findPackage('shopware/core', '*');
        }
        if (!$platform) {
            $platform = $this->composer->getPackage();
        }

        foreach ($platform->getRequires() as $require => $link) {
            if (!PlatformRepository::isPlatformPackage($require)) {
                continue;
            }

            

    return $unset_these_binaries;
  }

  /** * Gets a list of all installed packages from Composer. * * @return \Composer\Package\PackageInterface[] * The list of installed packages. */
  protected function getInstalledPackages() {
    return $this->composer->getRepositoryManager()->getLocalRepository()->getPackages();
  }

  /** * Gets the installed path for a package. * * @param \Composer\Package\PackageInterface $package * The package. * * @return string * Path to the install path for the package, relative to the project. This * accounts for changes made by composer/installers, if any. */
/** * Retrieves a package from the current composer process. * * @param string $name * Name of the package to get from the current composer installation. * * @return \Composer\Package\PackageInterface|null * The Composer package. */
  protected function getPackage($name) {
    return $this->composer->getRepositoryManager()->getLocalRepository()->findPackage($name, '*');
  }

}

  public static function preAutoloadDump(Event $event) {
    // Get the configured vendor directory.     $vendor_dir = $event->getComposer()->getConfig()->get('vendor-dir');

    // We need the root package so we can add our classmaps to its loader.     $package = $event->getComposer()->getPackage();
    // We need the local repository so that we can query and see if it's likely     // that our files are present there.     $repository = $event->getComposer()->getRepositoryManager()->getLocalRepository();
    // This is, essentially, a null constraint. We only care whether the package     // is present in the vendor directory yet, but findPackage() requires it.     $constraint = new Constraint('>', '');
    // It's possible that there is no classmap specified in a custom project     // composer.json file. We need one so we can optimize lookup for some of our     // dependencies.     $autoload = $package->getAutoload();
    if (!isset($autoload['classmap'])) {
      $autoload['classmap'] = [];
    }
    // Check for packages used prior to the default classloader being able to
/** * @param array{'require': Link[], 'conflict': Link[]} $pluginDependencies * * @return array{'require': Link[], 'conflict': Link[]} */
    private function checkComposerDependencies(
        array $pluginDependencies,
        RequirementExceptionStack $exceptionStack,
        Composer $composer
    ): array {
        $packages = $composer->getRepositoryManager()->getLocalRepository()->getPackages();

        // Get PHP extension "packages"         $packages = array_merge(
            $packages,
            (new PlatformRepository())->getPackages(),
        );

        // add root package         $packages[] = $composer->getPackage();

        foreach ($packages as $package) {
            
Home | Imprint | This part of the site doesn't use cookies.