Beispiel #1
0
 static function filterPackage(CompletePackage $package)
 {
     // strip out "tags", slashes, and spaces
     $version = preg_replace('/tags|[\\/ ]/', '', $package->getSourceReference());
     // trunk does not have a dist version
     if ($version !== 'trunk') {
         // set the dist info
         $package->setDistType('zip');
         // if there is a version identifier, prepend with a period
         $version = "-{$version}";
         // set the dist url
         $package->setDistUrl('https://wordpress.org/wordpress' . urlencode($version) . '.zip');
     }
     // set some additional meta info
     // this is inconsequential to the solver, but it gets stored in composer.lock
     // and appears when running `composer show vendor/package`
     $package->setDescription('WordPress is web software you can use to create a beautiful website, blog, or app.');
     $package->setSupport(['forum' => 'https://wordpress.org/support/', 'source' => 'https://core.trac.wordpress.org/browser/' . $package->getSourceReference(), 'docs' => 'https://codex.wordpress.org/Main_Page']);
     $package->setHomepage('https://wordpress.org/');
 }
 /**
  * Filter the package to add dist and other meta information.
  */
 function filterPackage(CompletePackage $package)
 {
     list($vendor, $shortName) = explode('/', $package->getName());
     // try to get the plugin info - may return an array or null/false
     try {
         $info = $this->getPluginInfo($shortName);
     } catch (RuntimeException $e) {
         if ($io->isVerbose()) {
             $io->writeError($e->getMessage());
         }
         // this allows us to try again for this plugin
         return;
     }
     if ($info) {
         // set the dist info
         $package->setDistType('zip');
         // strip out "tags", "trunk", slashes, and spaces
         $version = preg_replace('/tags|trunk|[\\/ ]/', '', $package->getSourceReference());
         // if there is a version identifier, prepend with a period
         $version = $version ? ".{$version}" : '';
         // set the dist url
         $package->setDistUrl('https://downloads.wordpress.org/plugin/' . urlencode($shortName . $version) . '.zip');
         // set some additional meta info
         // this is inconsequential to the solver, but it gets stored in composer.lock
         // and appears when running `composer show vendor/package`
         if (isset($info['short_description'])) {
             $package->setDescription($info['short_description']);
         }
         if (!empty($info['contributors'])) {
             $authors = [];
             foreach ($info['contributors'] as $name => $homepage) {
                 $authors[] = ['name' => $name, 'homepage' => $homepage];
             }
             $package->setAuthors($authors);
         }
         if (!empty($info['tags'])) {
             $package->setKeywords($info['tags']);
         }
         // URL-ready slug
         $pluginSlug = urlencode($shortName);
         $package->setSupport(['forum' => "https://wordpress.org/support/plugin/{$pluginSlug}/", 'source' => "http://plugins.trac.wordpress.org/browser/{$pluginSlug}/", 'docs' => "https://wordpress.org/plugins/{$pluginSlug}/"]);
         $package->setHomepage("https://wordpress.org/plugins/{$pluginSlug}/");
     } else {
         // null means the package is no longer active
         $package->setAbandoned(true);
     }
 }