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 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\BlogBundle\Entity\User $user
63 public function setUser(User
$user): Resource {
72 * @return \Rapsys\BlogBundle\Entity\User
74 public function getUser(): User
{
85 public function setPath(string $path): Resource {
96 public function getPath(): string {
103 * @param \DateTime $created
107 public function setCreated(\DateTime
$created): Resource {
108 $this->created
= $created;
118 public function getCreated(): \DateTime
{
119 return $this->created
;
125 * @param \DateTime $updated
129 public function setUpdated(\DateTime
$updated): Resource {
130 $this->updated
= $updated;
140 public function getUpdated(): \DateTime
{
141 return $this->updated
;
147 public function preUpdate(PreUpdateEventArgs
$eventArgs): ?Resource {
148 //Check that we have an snippet instance
149 if (($entity = $eventArgs->getEntity()) instanceof Resource) {
151 return $entity->setUpdated(new \
DateTime('now'));