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 KeywordTranslation
{
23 private int $keyword_id;
28 private string $locale;
33 private ?string $description;
38 private ?string $slug;
43 private ?string $title;
48 private \DateTime
$created;
53 private \DateTime
$updated;
56 * @var \Rapsys\BlogBundle\Entity\Keyword
58 private Keyword
$keyword;
63 public function __construct(Keyword
$keyword, string $locale, ?string $description = null, ?string $slug = null, ?string $title = null) {
65 $this->locale
= $locale;
66 $this->description
= $description;
68 $this->title
= $title;
69 $this->created
= new \
DateTime('now');
70 $this->updated
= new \
DateTime('now');
71 $this->setKeyword($keyword);
79 public function getLocale(): string {
86 * @param string $locale
88 * @return KeywordTranslation
90 public function setLocale(string $locale): KeywordTranslation
{
91 $this->locale
= $locale;
101 public function getDescription(): ?string {
102 return $this->description
;
108 * @param ?string $description
110 * @return KeywordTranslation
112 public function setDescription(?string $description): KeywordTranslation
{
113 $this->description
= $description;
123 public function getSlug(): ?string {
130 * @param ?string $slug
132 * @return KeywordTranslation
134 public function setSlug(?string $slug): KeywordTranslation
{
145 public function getTitle(): ?string {
152 * @param ?string $title
154 * @return KeywordTranslation
156 public function setTitle(?string $title): KeywordTranslation
{
157 $this->title
= $title;
167 public function getCreated(): \DateTime
{
168 return $this->created
;
174 * @param \DateTime $created
176 * @return KeywordTranslation
178 public function setCreated(\DateTime
$created): KeywordTranslation
{
179 $this->created
= $created;
189 public function getUpdated(): \DateTime
{
190 return $this->updated
;
196 * @param \DateTime $updated
198 * @return KeywordTranslation
200 public function setUpdated(\DateTime
$updated): KeywordTranslation
{
201 $this->updated
= $updated;
209 * @return \Rapsys\BlogBundle\Entity\Keyword
211 public function getKeyword(): Keyword
{
212 return $this->keyword
;
218 * @param \Rapsys\BlogBundle\Entity\Keyword $keyword
220 * @return KeywordTranslation
222 public function setKeyword(Keyword
$keyword): KeywordTranslation
{
223 $this->keyword
= $keyword;
224 $this->keyword_id
= $keyword->getId();
232 public function preUpdate(PreUpdateEventArgs
$eventArgs): ?KeywordTranslation
{
233 //Check that we have an snippet instance
234 if (($entity = $eventArgs->getEntity()) instanceof KeywordTranslation
) {
236 return $entity->setUpdated(new \
DateTime('now'));