Author.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <?php
  2. /*
  3. * This file is part of Packagist.
  4. *
  5. * (c) Jordi Boggiano <j.boggiano@seld.be>
  6. * Nils Adermann <naderman@naderman.de>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Packagist\WebBundle\Entity;
  12. use Doctrine\Common\Collections\ArrayCollection;
  13. use Doctrine\ORM\Mapping as ORM;
  14. /**
  15. * @ORM\Entity(repositoryClass="Packagist\WebBundle\Entity\AuthorRepository")
  16. * @ORM\Table(name="author")
  17. * @author Jordi Boggiano <j.boggiano@seld.be>
  18. */
  19. class Author
  20. {
  21. /**
  22. * @ORM\Id
  23. * @ORM\Column(type="integer")
  24. * @ORM\GeneratedValue(strategy="AUTO")
  25. */
  26. private $id;
  27. /**
  28. * Unique package name
  29. *
  30. * @ORM\Column(type="text", nullable=true)
  31. */
  32. private $name;
  33. /**
  34. * @ORM\Column(type="text", nullable=true)
  35. */
  36. private $email;
  37. /**
  38. * @ORM\Column(type="text", nullable=true)
  39. */
  40. private $homepage;
  41. /**
  42. * @ORM\Column(type="text", nullable=true)
  43. */
  44. private $role;
  45. /**
  46. * @ORM\ManyToMany(targetEntity="Packagist\WebBundle\Entity\Version", mappedBy="authors")
  47. */
  48. private $versions;
  49. /**
  50. * @ORM\ManyToOne(targetEntity="Packagist\WebBundle\Entity\User")
  51. */
  52. private $owner;
  53. /**
  54. * @ORM\Column(type="datetime")
  55. */
  56. private $createdAt;
  57. /**
  58. * @ORM\Column(type="datetime", nullable=true)
  59. */
  60. private $updatedAt;
  61. public function __construct()
  62. {
  63. $this->versions = new ArrayCollection();
  64. $this->createdAt = new \DateTime;
  65. }
  66. public function toArray()
  67. {
  68. $data = array();
  69. if ($this->getName()) {
  70. $data['name'] = $this->getName();
  71. }
  72. if ($this->getEmail()) {
  73. $data['email'] = $this->getEmail();
  74. }
  75. if ($this->getHomepage()) {
  76. $data['homepage'] = $this->getHomepage();
  77. }
  78. if ($this->getRole()) {
  79. $data['role'] = $this->getRole();
  80. }
  81. return $data;
  82. }
  83. /**
  84. * Get id
  85. *
  86. * @return string $id
  87. */
  88. public function getId()
  89. {
  90. return $this->id;
  91. }
  92. /**
  93. * Set name
  94. *
  95. * @param string $name
  96. */
  97. public function setName($name)
  98. {
  99. $this->name = $name;
  100. }
  101. /**
  102. * Get name
  103. *
  104. * @return string $name
  105. */
  106. public function getName()
  107. {
  108. return $this->name;
  109. }
  110. /**
  111. * Set createdAt
  112. *
  113. * @param \DateTime $createdAt
  114. */
  115. public function setCreatedAt($createdAt)
  116. {
  117. $this->createdAt = $createdAt;
  118. }
  119. /**
  120. * Get createdAt
  121. *
  122. * @return \DateTime $createdAt
  123. */
  124. public function getCreatedAt()
  125. {
  126. return $this->createdAt;
  127. }
  128. /**
  129. * Add versions
  130. *
  131. * @param Version $version
  132. */
  133. public function addVersion(Version $version)
  134. {
  135. $this->versions[] = $version;
  136. }
  137. /**
  138. * Get versions
  139. *
  140. * @return Version[]
  141. */
  142. public function getVersions()
  143. {
  144. return $this->versions;
  145. }
  146. /**
  147. * Set updatedAt
  148. *
  149. * @param \DateTime $updatedAt
  150. */
  151. public function setUpdatedAt(\DateTime $updatedAt)
  152. {
  153. $this->updatedAt = $updatedAt;
  154. }
  155. /**
  156. * Get updatedAt
  157. *
  158. * @return \DateTime $updatedAt
  159. */
  160. public function getUpdatedAt()
  161. {
  162. return $this->updatedAt;
  163. }
  164. /**
  165. * Set email
  166. *
  167. * @param string $email
  168. */
  169. public function setEmail($email)
  170. {
  171. $this->email = $email;
  172. }
  173. /**
  174. * Get email
  175. *
  176. * @return string
  177. */
  178. public function getEmail()
  179. {
  180. return $this->email;
  181. }
  182. /**
  183. * Set homepage
  184. *
  185. * @param string $homepage
  186. */
  187. public function setHomepage($homepage)
  188. {
  189. $this->homepage = $homepage;
  190. }
  191. /**
  192. * Get homepage
  193. *
  194. * @return string
  195. */
  196. public function getHomepage()
  197. {
  198. return $this->homepage;
  199. }
  200. /**
  201. * Set role
  202. *
  203. * @param string $role
  204. */
  205. public function setRole($role)
  206. {
  207. $this->role = $role;
  208. }
  209. /**
  210. * Get role
  211. *
  212. * @return string $role
  213. */
  214. public function getRole()
  215. {
  216. return $this->role;
  217. }
  218. /**
  219. * Set owner
  220. *
  221. * @param User $owner
  222. */
  223. public function setOwner(User $owner)
  224. {
  225. $this->owner = $owner;
  226. }
  227. /**
  228. * Get owner
  229. *
  230. * @return User
  231. */
  232. public function getOwner()
  233. {
  234. return $this->owner;
  235. }
  236. }