add route for comment + track update/creation of entities

This commit is contained in:
2021-05-13 17:25:24 +02:00
parent 05798688d0
commit 3e85529468
9 changed files with 229 additions and 4 deletions

View File

@@ -26,17 +26,25 @@ use Chill\PersonBundle\Repository\AccompanyingPeriod\CommentRepository;
use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
/**
* @ORM\Entity(repositoryClass=CommentRepository::class)
* @ORM\Table(name="chill_person_accompanying_period_comment")
* @DiscriminatorMap(typeProperty="type", mapping={
* "accompanying_period_comment"=Comment::class
* })
*/
class Comment
class Comment implements TrackCreationInterface, TrackUpdateInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"read"})
*/
private $id;
@@ -51,27 +59,32 @@ class Comment
/**
* @ORM\ManyToOne(targetEntity=User::class)
* @ORM\JoinColumn(nullable=false)
* @Groups({"read"})
*/
private $creator;
/**
* @ORM\Column(type="datetime")
* @Groups({"read"})
*/
private $createdAt;
/**
* @ORM\Column(type="datetime")
* @Groups({"read"})
*/
private $updatedAt;
/**
* @ORM\ManyToOne(targetEntity=User::class)
* @ORM\JoinColumn(nullable=false)
* @Groups({"read"})
*/
private $updatedBy;
/**
* @ORM\Column(type="text")
* @Groups({"read", "write"})
*/
private $content;
@@ -104,6 +117,11 @@ class Comment
return $this;
}
public function setCreatedBy(User $user): self
{
return $this->setCreator($user);
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
@@ -133,7 +151,7 @@ class Comment
return $this->updatedBy;
}
public function setUpdatedBy(?User $updatedBy): self
public function setUpdatedBy(User $updatedBy): self
{
$this->updatedBy = $updatedBy;