示例#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;
 }
 protected function parseRepositories($data)
 {
     $repositories = [];
     foreach ($data as $element) {
         if (!array_key_exists('type', $element)) {
             continue;
         }
         $repository = new Repository($element['type']);
         unset($element['type']);
         $repository->setParams($element);
         $repositories[] = $repository;
     }
     return $repositories;
 }