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\Common\Collections\Collection
; 
  15 use Doctrine\Common\Collections\ArrayCollection
; 
  16 use Doctrine\ORM\Event\PreUpdateEventArgs
; 
  30         private \DateTime 
$created; 
  35         private \DateTime 
$updated; 
  38          * @var \Doctrine\Common\Collections\Collection 
  40         private Collection 
$keyword_translations; 
  43          * @var \Doctrine\Common\Collections\Collection 
  45         private Collection 
$articles; 
  50         public function __construct() { 
  51                 $this->created 
= new \
DateTime('now'); 
  52                 $this->updated 
= new \
DateTime('now'); 
  53                 $this->keyword_translations 
= new ArrayCollection(); 
  54                 $this->articles 
= new ArrayCollection(); 
  62         public function getId(): ?int { 
  69          * @param \DateTime $created 
  73         public function setCreated(\DateTime 
$created): Keyword 
{ 
  74                 $this->created 
= $created; 
  84         public function getCreated(): \DateTime 
{ 
  85                 return $this->created
; 
  91          * @param \DateTime $updated 
  95         public function setUpdated(\DateTime 
$updated): Keyword 
{ 
  96                 $this->updated 
= $updated; 
 106         public function getUpdated(): \DateTime 
{ 
 107                 return $this->updated
; 
 111          * Add keywordTranslation 
 113          * @param \Rapsys\BlogBundle\Entity\KeywordTranslation $keywordTranslation 
 117         public function addKeywordTranslation(KeywordTranslation 
$keywordTranslation): Keyword 
{ 
 118                 $this->keyword_translations
[] = $keywordTranslation; 
 124          * Remove keywordTranslation 
 126          * @param \Rapsys\BlogBundle\Entity\KeywordTranslation $keywordTranslation 
 128          * @return \Doctrine\Common\Collections\Collection 
 130         public function removeKeywordTranslation(KeywordTranslation 
$keywordTranslation): Collection 
{ 
 131                 return $this->keyword_translations
->removeElement($keywordTranslation); 
 135          * Get keywordTranslations 
 137          * @return \Doctrine\Common\Collections\Collection 
 139         public function getKeywordTranslations(): Collection 
{ 
 140                 return $this->keyword_translations
; 
 146          * @param \Rapsys\BlogBundle\Entity\Article $article 
 150         public function addArticle(Article 
$article): Keyword 
{ 
 151                 $this->articles
[] = $article; 
 159          * @param \Rapsys\BlogBundle\Entity\Article $article 
 161          * @return \Doctrine\Common\Collections\Collection 
 163         public function removeArticle(Article 
$article): Collection 
{ 
 164                 return $this->articles
->removeElement($article); 
 170          * @return \Doctrine\Common\Collections\Collection 
 172         public function getArticles(): Collection 
{ 
 173                 return $this->articles
; 
 179         public function preUpdate(PreUpdateEventArgs 
$eventArgs): ?Keyword 
{ 
 180                 //Check that we have an snippet instance 
 181                 if (($entity = $eventArgs->getEntity()) instanceof Keyword
) { 
 183                         return $entity->setUpdated(new \
DateTime('now'));