add Moderation.php (#14)

Co-authored-by: bastien <bastien.ollier1@gmail.com>
Co-authored-by: clfreville2 <clement.freville2@etu.uca.fr>
Reviewed-on: https://codefirst.iut.uca.fr/git/clement.freville2/herbarium/pulls/14
Reviewed-by: Clément FRÉVILLE <clement.freville2@etu.uca.fr>
This commit is contained in:
Bastien OLLIER
2024-06-13 08:08:46 +02:00
parent 6a6a135891
commit ccb2b541ea
9 changed files with 128 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GetCollection;
use App\Repository\PostRepository;
use App\Validator\ImageSafety;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
@@ -64,6 +65,7 @@ class Post
#[Vich\UploadableField(mapping: 'posts', fileNameProperty: 'image')]
#[Assert\Image]
#[ImageSafety]
private ?File $imageFile = null;
#[ORM\Column(type: Types::TEXT)]
@@ -184,6 +186,9 @@ class Post
public function setImageFile(?File $imageFile): static
{
$this->imageFile = $imageFile;
if ($imageFile !== null) {
$this->updatedAt = new \DateTimeImmutable();
}
return $this;
}