Exemple #1
0
 protected function loadRepositories(OutputInterface $output, array $repositories)
 {
     $output->writeln('Loading resolver repositories with package information...');
     $manager = new Manager();
     $defaultRepository = new Repository('package');
     $defaultRepository->setParams(['url' => 'https://resolver.pixelpolishers.com/packages.json']);
     $repositories[] = $defaultRepository;
     foreach ($repositories as $repositoryConfig) {
         switch ($repositoryConfig->getType()) {
             case 'package':
                 $output->writeln(sprintf('<info>Loading package repository %s</info>', $repositoryConfig->getParam('url')));
                 $repository = new Package($repositoryConfig->getParam('url'));
                 break;
             default:
                 throw new RuntimeException('Invalid repository type provided: ' . $repositoryConfig->getType());
         }
         $manager->addRepository($repository);
     }
     $output->writeln('');
     return $manager;
 }
 public function resolve($name, $constraint, $isDevelopment)
 {
     $name = strtolower($name);
     if (array_key_exists($name, $this->dependencies)) {
         return;
     }
     if (!$constraint instanceof ConstraintInterface) {
         $constraint = $this->versionParser->parseConstraints($constraint);
     }
     $package = $this->manager->findPackage($name, $constraint);
     if (!$package) {
         throw new RuntimeException(sprintf('Unable to find package "%s"', $name));
     }
     foreach ($package->getDependencies() as $dependencyName => $dependencyVersion) {
         $this->resolve($dependencyName, $dependencyVersion, false);
     }
     foreach ($package->getDevelopmentDependencies() as $dependencyName => $dependencyVersion) {
         $this->resolve($dependencyName, $dependencyVersion, true);
     }
     $package->setDevelopmentPackage($isDevelopment);
     $this->dependencies[$name] = $package;
 }