Przeglądaj źródła

Add role key to author information

Michael Cullum 13 lat temu
rodzic
commit
ba3c1a540d

+ 26 - 1
src/Packagist/WebBundle/Entity/Author.php

@@ -48,6 +48,11 @@ class Author
      */
     private $homepage;
 
+    /**
+     * @ORM\Column(type="text", nullable=true)
+     */
+    private $role;
+
     /**
      * @ORM\ManyToMany(targetEntity="Packagist\WebBundle\Entity\Version", mappedBy="authors")
      */
@@ -213,6 +218,26 @@ class Author
         return $this->homepage;
     }
 
+    /**
+     * Set role
+     *
+     * @param string $role
+     */
+    public function setRole($role)
+    {
+        $this->role = $role;
+    }
+
+    /**
+     * Get role
+     *
+     * @return string $role
+     */
+    public function getRole()
+    {
+        return $this->role;
+    }
+
     /**
      * Set owner
      *
@@ -232,4 +257,4 @@ class Author
     {
         return $this->owner;
     }
-}
+}

+ 5 - 1
src/Packagist/WebBundle/Package/Updater.php

@@ -233,6 +233,10 @@ class Updater
                     ));
                 }
 
+                if (!empty($authorData['role'])) {
+                    $author = $authorRepository->findOneByRole($authorData['role']);
+                }
+
                 if (!$author && !empty($authorData['name'])) {
                     $author = $authorRepository->findOneByNameAndPackage($authorData['name'], $package);
                 }
@@ -242,7 +246,7 @@ class Updater
                     $em->persist($author);
                 }
 
-                foreach (array('email', 'name', 'homepage') as $field) {
+                foreach (array('email', 'name', 'homepage', 'role') as $field) {
                     if (isset($authorData[$field])) {
                         $author->{'set'.$field}($authorData[$field]);
                     }

+ 2 - 1
src/Packagist/WebBundle/Resources/views/About/about.html.twig

@@ -41,7 +41,8 @@ acme/email
         {
             "name": "Jordi Boggiano",
             "email": "j.boggiano@seld.be",
-            "homepage": "http://seld.be"
+            "homepage": "http://seld.be",
+            "role": "Developer"
         }
     ],
     "require": {