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; 
  38          * @var \Doctrine\Common\Collections\Collection 
  40         private Collection 
$resources; 
  45          * @param string $path The album path 
  46          * @param string $slug The album slug 
  47          * @param string $title The album title 
  49         public function __construct(private string $path, private string $slug, private string $title) { 
  51                 $this->created 
= new \
DateTime('now'); 
  52                 $this->updated 
= new \
DateTime('now'); 
  55                 $this->resources 
= new ArrayCollection(); 
  63         public function getId(): ?int { 
  74         public function setPath(string $path): Album 
{ 
  85         public function getPath(): string { 
  96         public function setSlug(string $slug): Album 
{ 
 107         public function getSlug(): string { 
 114          * @param string $title 
 118         public function setTitle(string $title): Album 
{ 
 119                 $this->title 
= $title; 
 129         public function getTitle(): string { 
 136          * @param \DateTime $created 
 140         public function setCreated(\DateTime 
$created): Album 
{ 
 141                 $this->created 
= $created; 
 151         public function getCreated(): \DateTime 
{ 
 152                 return $this->created
; 
 158          * @param \DateTime $updated 
 162         public function setUpdated(\DateTime 
$updated): Album 
{ 
 163                 $this->updated 
= $updated; 
 173         public function getUpdated(): \DateTime 
{ 
 174                 return $this->updated
; 
 180          * @param Resource $resource 
 184         public function addResource(Resource $resource): User 
{ 
 185                 $this->resources
[] = $resource; 
 193          * @param Resource $resource 
 195          * @return \Doctrine\Common\Collections\Collection 
 197         public function removeResource(Resource $resource): Collection 
{ 
 198                 return $this->resources
->removeElement($resource); 
 204          * @return \Doctrine\Common\Collections\Collection 
 206         public function getResources(): Collection 
{ 
 207                 return $this->resources
; 
 213         public function preUpdate(PreUpdateEventArgs 
$eventArgs): ?Album 
{ 
 214                 //Check that we have an snippet instance 
 215                 if (($entity = $eventArgs->getEntity()) instanceof Album
) { 
 217                         return $entity->setUpdated(new \
DateTime('now'));