1 <?php
declare(strict_types
=1);
4 * This file is part of the Rapsys PackBundle package.
6 * (c) Raphaël Gertz <symfony@rapsys.eu>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Rapsys\UserBundle\Entity
;
14 use Doctrine\Common\Collections\ArrayCollection
;
15 use Doctrine\ORM\Event\PreUpdateEventArgs
;
17 use Rapsys\UserBundle\Entity\User
;
44 * @var ArrayCollection
51 * @param string $title The civility name
53 public function __construct(string $title) {
54 $this->title
= $title;
55 $this->users
= new ArrayCollection();
63 public function getId(): int {
70 * @param string $title
74 public function setTitle(string $title): Civility
{
75 $this->title
= $title;
85 public function getTitle(): ?string {
92 * @param \DateTime $created
96 public function setCreated(\DateTime
$created): Civility
{
97 $this->created
= $created;
107 public function getCreated(): \DateTime
{
108 return $this->created
;
114 * @param \DateTime $updated
118 public function setUpdated(\DateTime
$updated): Civility
{
119 $this->updated
= $updated;
129 public function getUpdated(): \DateTime
{
130 return $this->updated
;
140 public function addUser(User
$user): Civility
{
141 $this->users
[] = $user;
151 public function removeUser(User
$user) {
152 $this->users
->removeElement($user);
158 * @return ArrayCollection
160 public function getUsers(): ArrayCollection
{
167 public function preUpdate(PreUpdateEventArgs
$eventArgs) {
168 //Check that we have a civility instance
169 if (($user = $eventArgs->getEntity()) instanceof Civility
) {
171 $user->setUpdated(new \
DateTime('now'));
176 * Returns a string representation of the title
180 public function __toString(): string {