1 <?php 
declare(strict_types
=1); 
   4  * This file is part of the Rapsys UserBundle 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\Collection
; 
  15 use Doctrine\Common\Collections\ArrayCollection
; 
  16 use Doctrine\ORM\Event\PreUpdateEventArgs
; 
  18 use Rapsys\UserBundle\Entity\User
; 
  32         protected \DateTime 
$created; 
  37         protected \DateTime 
$updated; 
  40          * @var ArrayCollection 
  42         protected Collection 
$users; 
  47          * @param string $title The civility name 
  49         public function __construct(protected string $title) { 
  51                 $this->created 
= new \
DateTime('now'); 
  52                 $this->updated 
= new \
DateTime('now'); 
  53                 $this->users 
= new ArrayCollection(); 
  61         public function getId(): int { 
  68          * @param string $title 
  72         public function setTitle(string $title): Civility 
{ 
  73                 $this->title 
= $title; 
  83         public function getTitle(): ?string { 
  90          * @param \DateTime $created 
  94         public function setCreated(\DateTime 
$created): Civility 
{ 
  95                 $this->created 
= $created; 
 105         public function getCreated(): \DateTime 
{ 
 106                 return $this->created
; 
 112          * @param \DateTime $updated 
 116         public function setUpdated(\DateTime 
$updated): Civility 
{ 
 117                 $this->updated 
= $updated; 
 127         public function getUpdated(): \DateTime 
{ 
 128                 return $this->updated
; 
 138         public function addUser(User 
$user): Civility 
{ 
 139                 $this->users
[] = $user; 
 149         public function removeUser(User 
$user) { 
 150                 $this->users
->removeElement($user); 
 156          * @return ArrayCollection 
 158         public function getUsers(): ArrayCollection 
{ 
 165         public function preUpdate(PreUpdateEventArgs 
$eventArgs) { 
 166                 //Check that we have a civility instance 
 167                 if (($user = $eventArgs->getObject()) instanceof Civility
) { 
 169                         $user->setUpdated(new \
DateTime('now')); 
 174          * Returns a string representation of the title 
 178         public function __toString(): string {