1 <?php
declare(strict_types
=1);
4 * This file is part of the Rapsys BlogBundle 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\BlogBundle\Entity
;
14 use Doctrine\ORM\Event\PreUpdateEventArgs
;
19 class UserTranslation
{
28 private string $locale;
33 private ?string $description;
38 private \DateTime
$created;
43 private \DateTime
$updated;
46 * @var \Rapsys\BlogBundle\Entity\User
53 public function __construct(User
$user, string $locale, ?string $description = null) {
55 $this->locale
= $locale;
56 $this->description
= $description;
57 $this->created
= new \
DateTime('now');
58 $this->updated
= new \
DateTime('now');
59 $this->setUser($user);
67 public function getLocale(): string {
74 * @param string $locale
76 * @return UserTranslation
78 public function setLocale(string $locale): UserTranslation
{
79 $this->locale
= $locale;
89 public function getDescription(): ?string {
90 return $this->description
;
96 * @param ?string $description
98 * @return UserTranslation
100 public function setDescription(?string $description): UserTranslation
{
101 $this->description
= $description;
111 public function getCreated(): \DateTime
{
112 return $this->created
;
118 * @param \DateTime $created
120 * @return UserTranslation
122 public function setCreated(\DateTime
$created): UserTranslation
{
123 $this->created
= $created;
133 public function getUpdated(): \DateTime
{
134 return $this->updated
;
140 * @param \DateTime $updated
142 * @return UserTranslation
144 public function setUpdated(\DateTime
$updated): UserTranslation
{
145 $this->updated
= $updated;
153 * @return \Rapsys\BlogBundle\Entity\User
155 public function getUser(): User
{
162 * @param \Rapsys\BlogBundle\Entity\User $user
164 * @return UserTranslation
166 public function setUser(User
$user): UserTranslation
{
168 $this->user_id
= $user->getId();
176 public function preUpdate(PreUpdateEventArgs
$eventArgs): ?UserTranslation
{
177 //Check that we have an snippet instance
178 if (($entity = $eventArgs->getEntity()) instanceof UserTranslation
) {
180 return $entity->setUpdated(new \
DateTime('now'));