1 <?php 
declare(strict_types
=1); 
   4  * This file is part of the Rapsys TreeBundle 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\TreeBundle\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; 
  40          * @param string $path The resource path 
  42         public function __construct(private Album 
$album, private User 
$user, private string $path) { 
  43                 $this->created 
= new \
DateTime('now'); 
  44                 $this->updated 
= new \
DateTime('now'); 
  52         public function getId(): ?int { 
  59          * @param \Rapsys\TreeBundle\Entity\Album $album 
  63         public function setAlbum(Album 
$album): Resource { 
  64                 $this->album 
= $album; 
  72          * @return \Rapsys\TreeBundle\Entity\Album 
  74         public function getAlbum(): Album 
{ 
  81          * @param \Rapsys\TreeBundle\Entity\User $user 
  85         public function setUser(User 
$user): Resource { 
  94          * @return \Rapsys\TreeBundle\Entity\User 
  96         public function getUser(): User 
{ 
 103          * @param string $path 
 107         public function setPath(string $path): Resource { 
 118         public function getPath(): string { 
 125          * @param \DateTime $created 
 129         public function setCreated(\DateTime 
$created): Resource { 
 130                 $this->created 
= $created; 
 140         public function getCreated(): \DateTime 
{ 
 141                 return $this->created
; 
 147          * @param \DateTime $updated 
 151         public function setUpdated(\DateTime 
$updated): Resource { 
 152                 $this->updated 
= $updated; 
 162         public function getUpdated(): \DateTime 
{ 
 163                 return $this->updated
; 
 169         public function preUpdate(PreUpdateEventArgs 
$eventArgs): ?Resource { 
 170                 //Check that we have an snippet instance 
 171                 if (($entity = $eventArgs->getEntity()) instanceof Resource) { 
 173                         return $entity->setUpdated(new \
DateTime('now'));