Преглед на файлове

Add type and extra support for composer.json

Jordi Boggiano преди 14 години
родител
ревизия
6184497b08

+ 11 - 0
src/Packagist/WebBundle/Command/UpdatePackagesCommand.php

@@ -123,6 +123,17 @@ EOF
         $version->setSource(array('type' => $repository->getType(), 'url' => $repository->getUrl()));
         $version->setDist($repository->getDist($identifier));
 
+        if (isset($data['type'])) {
+            $version->setType($data['type']);
+            if ($data['type'] && $data['type'] !== $package->getType()) {
+                $package->setType($data['type']);
+            }
+        }
+
+        if (isset($data['extra']) && is_array($data['extra'])) {
+            $version->setExtra($data['extra']);
+        }
+
         if (isset($data['keywords'])) {
             foreach ($data['keywords'] as $keyword) {
                 $version->addTags(Tag::getByName($em, $keyword, true));

+ 27 - 1
src/Packagist/WebBundle/Entity/Package.php

@@ -39,10 +39,15 @@ class Package
     /**
      * Unique package name
      *
-     * @ORM\Column
+     * @ORM\Column()
      */
     private $name;
 
+    /**
+     * @ORM\Column(nullable="true")
+     */
+    private $type;
+
     /**
      * @ORM\Column(type="text", nullable="true")
      */
@@ -104,6 +109,7 @@ class Package
             'dist-tags' => array(),
             'maintainers' => $maintainers,
             'versions' => $versions,
+            'type' => $this->type,
         );
         return json_encode($data);
     }
@@ -318,4 +324,24 @@ class Package
     {
         return $this->maintainers;
     }
+
+    /**
+     * Set type
+     *
+     * @param text $type
+     */
+    public function setType($type)
+    {
+        $this->type = $type;
+    }
+
+    /**
+     * Get type
+     *
+     * @return string
+     */
+    public function getType()
+    {
+        return $this->type;
+    }
 }

+ 20 - 0
src/Packagist/WebBundle/Entity/User.php

@@ -89,4 +89,24 @@ class User extends BaseUser
     {
         return $this->authors;
     }
+
+    /**
+     * Set createdAt
+     *
+     * @param datetime $createdAt
+     */
+    public function setCreatedAt($createdAt)
+    {
+        $this->createdAt = $createdAt;
+    }
+
+    /**
+     * Get createdAt
+     *
+     * @return datetime 
+     */
+    public function getCreatedAt()
+    {
+        return $this->createdAt;
+    }
 }

+ 52 - 0
src/Packagist/WebBundle/Entity/Version.php

@@ -43,6 +43,16 @@ class Version
      */
     private $description;
 
+    /**
+     * @ORM\Column(nullable="true")
+     */
+    private $type;
+
+    /**
+     * @ORM\Column(type="array", nullable="true")
+     */
+    private $extra = array();
+
     /**
      * @ORM\ManyToMany(targetEntity="Packagist\WebBundle\Entity\Tag", inversedBy="versions")
      * @ORM\JoinTable(name="version_tag",
@@ -149,6 +159,8 @@ class Version
             'source' => $this->getSource(),
             'time' => $this->releasedAt ? $this->releasedAt->format('Y-m-d\TH:i:sP') : null,
             'dist' => $this->getDist(),
+            'type' => $this->type,
+            'extra' => $this->extra,
         );
     }
 
@@ -490,4 +502,44 @@ class Version
     {
         return $this->requirements;
     }
+
+    /**
+     * Set type
+     *
+     * @param string $type
+     */
+    public function setType($type)
+    {
+        $this->type = $type;
+    }
+
+    /**
+     * Get type
+     *
+     * @return string
+     */
+    public function getType()
+    {
+        return $this->type;
+    }
+
+    /**
+     * Set extra
+     *
+     * @param array $extra
+     */
+    public function setExtra($extra)
+    {
+        $this->extra = $extra;
+    }
+
+    /**
+     * Get extra
+     *
+     * @return array
+     */
+    public function getExtra()
+    {
+        return $this->extra;
+    }
 }