/**
  * {@inheritDoc}
  */
 protected function initialize()
 {
     $this->packages = array();
     $this->packageName = isset($this->repoConfig['name']) ? Util::cleanPackageName($this->repoConfig['name']) : null;
     $driver = $this->initDriver();
     $this->initLoader();
     $this->initRootIdentifier($driver);
     $this->initRegistryVersions();
     $this->initTags($driver);
     $this->initBranches($driver);
     $driver->cleanup();
     if (!$this->getPackages()) {
         throw new InvalidRepositoryException('No valid ' . $this->assetType->getFilename() . ' was found in any branch or tag of ' . $this->url . ', could not load a package from it.');
     }
 }
Example #2
0
 /**
  * Adds asset vcs repositories.
  *
  * @param RepositoryManager $rm
  * @param array             $repositories
  * @param Pool|null         $pool
  *
  * @throws \UnexpectedValueException When config of repository is not an array
  * @throws \UnexpectedValueException When the config of repository has not a type defined
  * @throws \UnexpectedValueException When the config of repository has an invalid type
  */
 protected function addRepositories(RepositoryManager $rm, array $repositories, Pool $pool = null)
 {
     foreach ($repositories as $index => $repo) {
         $this->validateRepositories($index, $repo);
         if ('package' === $repo['type']) {
             $name = $repo['package']['name'];
         } else {
             $name = is_int($index) ? preg_replace('{^https?://}i', '', $repo['url']) : $index;
             $name = isset($repo['name']) ? $repo['name'] : $name;
             $repo['vcs-package-filter'] = $this->packageFilter;
         }
         Util::addRepository($this->io, $rm, $this->repos, $name, $repo, $pool);
     }
 }
 /**
  * Searchs if the registry has a package with the same name exists with a
  * different camelcase.
  *
  * @param Pool               $pool
  * @param string             $name
  * @param TransportException $ex
  */
 protected function fallbackWathProvides(Pool $pool, $name, TransportException $ex)
 {
     $providers = array();
     if (404 === $ex->getCode() && !$this->fallbackProviders) {
         $this->fallbackProviders = true;
         $repoName = Util::convertAliasName($name);
         $results = $this->search($repoName);
         foreach ($results as $item) {
             if ($name === strtolower($item['name'])) {
                 $providers = $this->whatProvides($pool, $item['name']);
                 break;
             }
         }
     }
     $this->fallbackProviders = false;
     $this->providers[$name] = $providers;
 }
 /**
  * Create and put the array repository with the asset configs.
  *
  * @param array  $packageConfigs The configs of assets package versions
  * @param string $name           The asset package name
  * @param Pool   $pool           The pool
  */
 protected function putArrayRepositoryConfig(array $packageConfigs, $name, Pool $pool)
 {
     $packages = $this->createArrayRepositoryConfig($packageConfigs);
     $repo = new ArrayRepository($packages);
     Util::addRepositoryInstance($this->io, $this->rm, $this->repos, $name, $repo, $pool);
     $this->providers[$name] = array();
 }
Example #5
0
 /**
  * @dataProvider getPackageNames
  *
  * @param string $name
  * @param string $validName
  */
 public function testConvertAliasName($name, $validName)
 {
     $this->assertSame($validName, Util::convertAliasName($name));
 }
 /**
  * Create the repository config.
  *
  * @param RepositoryManager $rm        The repository manager
  * @param VcsPackageFilter  $filter    The vcs package filter
  * @param array             $extra     The composer extra
  * @param string            $assetType The asset type
  *
  * @return array
  */
 public static function createRepositoryConfig(RepositoryManager $rm, VcsPackageFilter $filter, array $extra, $assetType)
 {
     $opts = Util::getArrayValue($extra, 'asset-registry-options', array());
     return array('repository-manager' => $rm, 'vcs-package-filter' => $filter, 'asset-options' => static::createAssetOptions($opts, $assetType), 'vcs-driver-options' => Util::getArrayValue($extra, 'asset-vcs-driver-options', array()));
 }