]> Raphaël G. Git Repositories - blogbundle/blob - Entity/User.php
Update message
[blogbundle] / Entity / User.php
1 <?php declare(strict_types=1);
2
3 /*
4 * This file is part of the Rapsys BlogBundle package.
5 *
6 * (c) Raphaël Gertz <symfony@rapsys.eu>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Rapsys\BlogBundle\Entity;
13
14 use Doctrine\Common\Collections\Collection;
15 use Doctrine\Common\Collections\ArrayCollection;
16
17 use Rapsys\UserBundle\Entity\User as BaseUser;
18
19 class User extends BaseUser {
20 /**
21 * @var ?string
22 */
23 protected ?string $pseudonym;
24
25 /**
26 * @var ?string
27 */
28 protected ?string $slug;
29
30 /**
31 * @var \Doctrine\Common\Collections\Collection
32 */
33 private Collection $articles;
34
35 /**
36 * @var \Doctrine\Common\Collections\Collection
37 */
38 private Collection $user_translations;
39
40 /**
41 * Constructor
42 *
43 * @param string $mail The user mail
44 * @param string $password The user password
45 * @param ?Civility $civility The user civility
46 * @param ?string $forename The user forename
47 * @param ?string $surname The user surname
48 * @param bool $active The user is active
49 * @param bool $enable The user is enable
50 * @param ?string $pseudonym The user pseudonym
51 * @param ?string $slug The user slug
52 */
53 public function __construct(string $mail, string $password, ?Civility $civility = null, ?string $forename = null, ?string $surname = null, bool $active = false, bool $enable = true, ?string $pseudonym = null, ?string $slug = null) {
54 //Call parent constructor
55 parent::__construct($mail, $password, $civility, $forename, $surname, $active, $enable);
56
57 //Set defaults
58 $this->pseudonym = $pseudonym;
59 $this->slug = $slug;
60
61 //Set collections
62 $this->articles = new ArrayCollection();
63 $this->user_translations = new ArrayCollection();
64 }
65
66 /**
67 * Set pseudonym
68 *
69 * @param ?string $pseudonym
70 *
71 * @return User
72 */
73 public function setPseudonym(?string $pseudonym = null): User {
74 $this->pseudonym = $pseudonym;
75
76 return $this;
77 }
78
79 /**
80 * Get pseudonym
81 *
82 * @return ?string
83 */
84 public function getPseudonym(): ?string {
85 return $this->pseudonym;
86 }
87
88 /**
89 * Set slug
90 *
91 * @param ?string $slug
92 *
93 * @return User
94 */
95 public function setSlug(?string $slug = null): User {
96 $this->slug = $slug;
97
98 return $this;
99 }
100
101 /**
102 * Get slug
103 *
104 * @return ?string
105 */
106 public function getSlug(): ?string {
107 return $this->slug;
108 }
109
110 /**
111 * Add article
112 *
113 * @param Article $article
114 *
115 * @return User
116 */
117 public function addArticle(Article $article): User {
118 $this->articles[] = $article;
119
120 return $this;
121 }
122
123 /**
124 * Remove article
125 *
126 * @param Article $article
127 *
128 * @return \Doctrine\Common\Collections\Collection
129 */
130 public function removeArticle(Article $article): Collection {
131 return $this->articles->removeElement($article);
132 }
133
134 /**
135 * Get articles
136 *
137 * @return \Doctrine\Common\Collections\Collection
138 */
139 public function getArticles(): Collection {
140 return $this->articles;
141 }
142
143 /**
144 * Add user translation
145 *
146 * @param \Rapsys\BlogBundle\Entity\UserTranslation $userTranslation
147 *
148 * @return User
149 */
150 public function addUserTranslation(UserTranslation $userTranslation): User {
151 $this->user_translations[] = $userTranslation;
152
153 return $this;
154 }
155
156 /**
157 * Remove user translation
158 *
159 * @param \Rapsys\BlogBundle\Entity\UserTranslation $userTranslation
160 *
161 * @return \Doctrine\Common\Collections\Collection
162 */
163 public function removeUserTranslation(UserTranslation $userTranslation): Collection {
164 return $this->user_translations->removeElement($userTranslation);
165 }
166
167 /**
168 * Get user translations
169 *
170 * @return \Doctrine\Common\Collections\Collection
171 */
172 public function getUserTranslations(): Collection {
173 return $this->user_translations;
174 }
175 }