Esempio n. 1
0
 public function dump(PackageInterface $package)
 {
     $keys = array('binaries' => 'bin', 'type', 'extra', 'installationSource' => 'installation-source', 'autoload', 'devAutoload' => 'autoload-dev', 'notificationUrl' => 'notification-url', 'includePaths' => 'include-path');
     $data = array();
     $data['name'] = $package->getPrettyName();
     $data['version'] = $package->getPrettyVersion();
     $data['version_normalized'] = $package->getVersion();
     if ($package->getTargetDir()) {
         $data['target-dir'] = $package->getTargetDir();
     }
     if ($package->getSourceType()) {
         $data['source']['type'] = $package->getSourceType();
         $data['source']['url'] = $package->getSourceUrl();
         $data['source']['reference'] = $package->getSourceReference();
         if ($mirrors = $package->getSourceMirrors()) {
             $data['source']['mirrors'] = $mirrors;
         }
     }
     if ($package->getDistType()) {
         $data['dist']['type'] = $package->getDistType();
         $data['dist']['url'] = $package->getDistUrl();
         $data['dist']['reference'] = $package->getDistReference();
         $data['dist']['shasum'] = $package->getDistSha1Checksum();
         if ($mirrors = $package->getDistMirrors()) {
             $data['dist']['mirrors'] = $mirrors;
         }
     }
     if ($package->getArchiveExcludes()) {
         $data['archive']['exclude'] = $package->getArchiveExcludes();
     }
     foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
         if ($links = $package->{'get' . ucfirst($opts['method'])}()) {
             foreach ($links as $link) {
                 $data[$type][$link->getTarget()] = $link->getPrettyConstraint();
             }
             ksort($data[$type]);
         }
     }
     if ($packages = $package->getSuggests()) {
         ksort($packages);
         $data['suggest'] = $packages;
     }
     if ($package->getReleaseDate()) {
         $data['time'] = $package->getReleaseDate()->format('Y-m-d H:i:s');
     }
     $data = $this->dumpValues($package, $keys, $data);
     if ($package instanceof CompletePackageInterface) {
         $keys = array('scripts', 'license', 'authors', 'description', 'homepage', 'keywords', 'repositories', 'support');
         $data = $this->dumpValues($package, $keys, $data);
         if (isset($data['keywords']) && is_array($data['keywords'])) {
             sort($data['keywords']);
         }
     }
     if ($package instanceof RootPackageInterface) {
         $minimumStability = $package->getMinimumStability();
         if ($minimumStability) {
             $data['minimum-stability'] = $minimumStability;
         }
     }
     if (count($package->getTransportOptions()) > 0) {
         $data['transport-options'] = $package->getTransportOptions();
     }
     return $data;
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public function getDistMirrors()
 {
     return $this->package->getDistMirrors();
 }
Esempio n. 3
0
 private static function getUrlFromPackage(Package\PackageInterface $package)
 {
     $url = $package->getDistUrl();
     if (!$url) {
         return false;
     }
     if ($package->getDistMirrors()) {
         $url = current($package->getDistUrls());
     }
     if (!parse_url($url, PHP_URL_HOST)) {
         return false;
     }
     return $url;
 }
Esempio n. 4
0
 public function getDistMirrors()
 {
     return $this->aliasOf->getDistMirrors();
 }