Przeglądaj źródła

Add extra and type info to packages

Jordi Boggiano 14 lat temu
rodzic
commit
ba9f12a517

+ 17 - 0
src/Composer/Package/MemoryPackage.php

@@ -28,6 +28,7 @@ class MemoryPackage extends BasePackage
     protected $releaseType;
     protected $version;
     protected $license;
+    protected $extra = array();
 
     protected $requires = array();
     protected $conflicts = array();
@@ -67,6 +68,22 @@ class MemoryPackage extends BasePackage
         return $this->type ?: 'library';
     }
 
+    /**
+     * @param array $extra
+     */
+    public function setExtra(array $extra)
+    {
+        $this->extra = $extra;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public function getExtra()
+    {
+        return $this->extra;
+    }
+
     /**
      * @param string $type
      */

+ 15 - 8
src/Composer/Package/PackageInterface.php

@@ -38,17 +38,17 @@ interface PackageInterface
     function getNames();
 
     /**
-    * Allows the solver to set an id for this package to refer to it.
-    *
-    * @param int $id
-    */
+     * Allows the solver to set an id for this package to refer to it.
+     *
+     * @param int $id
+     */
     function setId($id);
 
     /**
-    * Retrieves the package's id set through setId
-    *
-    * @return int The previously set package id
-    */
+     * Retrieves the package's id set through setId
+     *
+     * @return int The previously set package id
+     */
     function getId();
 
     /**
@@ -68,6 +68,13 @@ interface PackageInterface
      */
     function getType();
 
+    /**
+     * Returns the package extra data
+     *
+     * @return array The package extra data
+     */
+    function getExtra();
+
     /**
      * Returns the repository type of this package, e.g. git, svn
      *

+ 8 - 0
src/Composer/Repository/ComposerRepository.php

@@ -55,6 +55,14 @@ class ComposerRepository extends ArrayRepository
             $package->setDistUrl($rev['dist']['url']);
             $package->setDistSha1Checksum($rev['dist']['shasum']);
 
+            if (isset($rev['type'])) {
+                $package->setType($rev['type']);
+            }
+
+            if (isset($rev['extra'])) {
+                $package->setExtra($rev['extra']);
+            }
+
             if (isset($rev['license'])) {
                 $package->setLicense($rev['license']);
             }