Author.php 4.5 KB

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