api/src/User/Entity/Review.php
<?php
/**
* Copyright (c) 2020, MOBICOOP. All rights reserved.
* This project is dual licensed under AGPL and proprietary licence.
***************************
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <gnu.org/licenses>.
***************************
* Licence MOBICOOP described in the file
* LICENSE
**************************/
namespace App\User\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\MaxDepth;
/**
* A Review made by a User on another User
*
* @ORM\Entity
* @ORM\HasLifecycleCallbacks
*
* @author Maxime Bardot <maxime.bardot@mobicoop.org>
*/
class Review
{
/**
* @var int $id The id of this Review.
*
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @var User The User who left this Review
*
* @ORM\ManyToOne(targetEntity="App\User\Entity\User")
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
* @MaxDepth(1)
*/
private $reviewer;
/**
* @var User The User targeted by this Review
*
* @ORM\ManyToOne(targetEntity="App\User\Entity\User")
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
* @MaxDepth(1)
*/
private $reviewed;
/**
* @var string The content text of the review
*
* @ORM\Column(type="text")
*/
private $content;
/**
* @var \DateTimeInterface Creation date.
*
* @ORM\Column(type="datetime", nullable=true)
*/
private $createdDate;
/**
* @var \DateTimeInterface Updated date.
*
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedDate;
public function getId(): int
{
return $this->id;
}
public function setId(int $id): self
{
$this->id = $id;
return $this;
}
public function getReviewer(): ?User
{
return $this->reviewer;
}
public function setReviewer(?User $reviewer): self
{
$this->reviewer = $reviewer;
return $this;
}
public function getReviewed(): ?User
{
return $this->reviewed;
}
public function setReviewed(?User $reviewed): self
{
$this->reviewed = $reviewed;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(?string $content): self
{
$this->content = $content;
return $this;
}
public function getCreatedDate(): ?\DateTimeInterface
{
return $this->createdDate;
}
public function setCreatedDate(\DateTimeInterface $createdDate): self
{
$this->createdDate = $createdDate;
return $this;
}
public function getUpdatedDate(): ?\DateTimeInterface
{
return $this->updatedDate;
}
public function setUpdatedDate(\DateTimeInterface $updatedDate): self
{
$this->updatedDate = $updatedDate;
return $this;
}
// DOCTRINE EVENTS
/**
* Creation date.
*
* @ORM\PrePersist
*/
public function setAutoCreatedDate()
{
$this->setCreatedDate(new \Datetime());
}
/**
* Update date.
*
* @ORM\PreUpdate
*/
public function setAutoUpdatedDate()
{
$this->setUpdatedDate(new \Datetime());
}
}