<?php
namespace App\Entity;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Put;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiFilter;
use App\Repository\FormRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
#[ApiResource(operations: [new Get(), new Put(security: 'is_granted(\'ROLE_SUPER_ADMIN\')', securityMessage: 'Accès Interdit'), new Patch(security: 'is_granted(\'ROLE_SUPER_ADMIN\')', securityMessage: 'Accès Interdit'), new Delete(security: 'is_granted(\'ROLE_SUPER_ADMIN\')', securityMessage: 'Accès Interdit'), new GetCollection(), new Post(normalizationContext: ['groups' => ['get']], security: 'is_granted(\'ROLE_SUPER_ADMIN\')', securityMessage: 'Accès Interdit')])]
#[ORM\Entity(repositoryClass: FormRepository::class)]
class Form
{
#[ORM\Id]
#[Groups('get')]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private ?int $id = null;
#[Groups('get')]
#[ORM\Column(type: 'string', length: 255)]
private ?string $title = null;
#[Groups('get')]
#[ORM\Column(type: 'boolean', nullable: true)]
private ?bool $isActive = null;
#[Groups('get')]
#[ORM\OneToMany(mappedBy: 'form', targetEntity: Answer::class, orphanRemoval: true)]
private Collection $answers;
#[Groups('get')]
#[ORM\ManyToOne(targetEntity: Animal::class)]
#[ORM\JoinColumn(nullable: true)]
private ?Animal $animal = null;
#[Groups('get')]
#[ORM\Column(type: 'text', nullable: false)]
private ?string $description = null;
#[Groups('get')]
#[ORM\Column(type: 'boolean', nullable: true)]
private ?bool $isAnimal = null;
#[Groups('get')]
#[ORM\ManyToOne(targetEntity: Entity::class, inversedBy: 'formAccesses')]
#[ORM\JoinColumn(nullable: true)]
private mixed $entity;
#[Groups('get')]
#[ORM\ManyToMany(targetEntity: Profile::class, inversedBy: 'formAccesses')]
private Collection $profiles;
#[Groups('get')]
#[ORM\Column(type: 'text', nullable: true)]
private ?string $jsonForm = null;
#[Groups('get')]
#[ORM\OneToMany(mappedBy: 'form', targetEntity: Field::class, cascade: ['persist'], orphanRemoval: true)]
private Collection $fields;
#[Groups('get')]
#[ORM\Column(type: 'date')]
private \DateTime $publicationDate;
#[Groups('get')]
#[ORM\Column(type: 'boolean')]
private bool $isGeolocated = false;
#[Groups('get')]
#[ORM\Column(type: 'boolean')]
private bool $isShape = false;
#[Groups('get')]
#[ORM\Column(type: 'boolean', options: ['default' => true])]
private ?bool $isPublic = true;
#[Groups('get')]
#[ORM\Column(type: 'boolean')]
private bool $gotMedia = false;
#[Groups('get')]
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $mediaExplanation = null;
#[Groups('get')]
#[ORM\Column(type: 'boolean', nullable: true)]
private ?bool $isBooking = false;
#[Groups('get')]
#[ORM\Column(type: 'integer', nullable: true)]
private ?int $numberBooking = null;
#[Groups('get')]
#[ORM\Column(type: 'date', nullable: true)]
private ?\DateTimeInterface $bookingDate = null;
#[Groups('get')]
#[ORM\OneToOne(inversedBy: 'formPdf', targetEntity: Media::class, cascade: ['persist', 'remove'])]
private ?Media $pdf = null;
#[Groups('get')]
#[ORM\OneToMany(mappedBy: 'form', targetEntity: Media::class, orphanRemoval: true)]
private Collection $pictures;
#[ORM\ManyToOne(targetEntity: Category::class, inversedBy: 'forms')]
private ?Category $category = null;
#[Groups('get')]
#[ORM\Column(type: 'boolean', nullable: true)]
private ?bool $bookingNameDisplay = null;
#[Groups('get')]
#[ORM\Column(type: 'boolean', options: ['default' => false])]
private ?bool $bookingSpace = null;
#[Groups('get')]
#[ORM\Column(type: 'boolean', options: ['default' => false])]
private ?bool $isSigned;
#[ORM\Column]
#[Groups('get')]
private ?bool $isObject = false;
#[ORM\Column]
#[Groups('get')]
private ?bool $isLinkedToObject = false;
#[ORM\ManyToOne(cascade: ['persist','remove'], inversedBy: 'forms')]
#[ORM\JoinColumn(onDelete: 'SET NULL')]
private ?MapObjectType $mapObjectType = null;
#[ORM\Column(nullable: true)]
private ?bool $edit = null;
#[ORM\Column(type: 'boolean', options: ['default' => false])]
#[Groups('get')]
private ?bool $isPolyline = false;
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
private ?\DateTimeInterface $publicationEnd = null;
public function __construct()
{
$this->answers = new ArrayCollection();
$this->profiles = new ArrayCollection();
$this->fields = new ArrayCollection();
$this->publicationDate = new \DateTime();
$this->pictures = new ArrayCollection();
}
public function getId() : ?int
{
return $this->id;
}
public function setId(?int $id) : Form
{
$this->id = $id;
return $this;
}
public function getTitle() : ?string
{
return $this->title;
}
public function setTitle(string $title) : self
{
$this->title = $title;
return $this;
}
public function getIsActive() : ?bool
{
return $this->isActive;
}
public function setIsActive(bool $isActive) : self
{
$this->isActive = $isActive;
return $this;
}
/**
* @return Collection|Answer[]
*/
public function getAnswers() : Collection
{
return $this->answers;
}
public function addAnswer(Answer $answer) : self
{
if (!$this->answers->contains($answer)) {
$this->answers[] = $answer;
$answer->setForm($this);
}
return $this;
}
public function removeAnswer(Answer $answer) : self
{
if ($this->answers->removeElement($answer)) {
// set the owning side to null (unless already changed)
if ($answer->getForm() === $this) {
$answer->setForm(null);
}
}
return $this;
}
public function getAnimal() : ?Animal
{
return $this->animal;
}
public function setAnimal(?Animal $animal) : self
{
$this->animal = $animal;
return $this;
}
public function getDescription() : ?string
{
return $this->description;
}
public function setDescription(?string $description) : self
{
$this->description = $description;
return $this;
}
public function getIsAnimal() : ?bool
{
return $this->isAnimal;
}
public function setIsAnimal(?bool $isAnimal) : self
{
$this->isAnimal = $isAnimal;
return $this;
}
/**
* @return mixed
*/
public function getEntity() : ?Entity
{
return $this->entity;
}
public function setEntity(mixed $entity) : Form
{
$this->entity = $entity;
return $this;
}
/**
* @return mixed
*/
public function getProfiles() : Collection
{
return $this->profiles;
}
public function addProfile(Profile $profile) : self
{
if (!$this->profiles->contains($profile)) {
$this->profiles[] = $profile;
$profile->addForm($this);
}
return $this;
}
public function removeProfile(Profile $profile) : self
{
if ($this->profiles->removeElement($profile)) {
$profile->removeForm($this);
}
return $this;
}
public function removeAllProfiles() : self
{
foreach ($this->profiles as $profile) {
$profile->removeForm($this);
}
return $this;
}
public function getJsonForm() : ?string
{
return $this->jsonForm;
}
public function setJsonForm(?string $jsonForm) : self
{
$this->jsonForm = $jsonForm;
return $this;
}
/**
* @return Collection|Field[]
*/
public function getFields() : Collection
{
return $this->fields;
}
public function addField(Field $field) : self
{
if (!$this->fields->contains($field)) {
$this->fields[] = $field;
$field->setForm($this);
}
return $this;
}
public function removeField(Field $field) : self
{
if ($this->fields->removeElement($field)) {
// set the owning side to null (unless already changed)
if ($field->getForm() === $this) {
$field->setForm(null);
}
}
return $this;
}
public function getPublicationDate() : ?\DateTimeInterface
{
return $this->publicationDate;
}
public function setPublicationDate(\DateTimeInterface $publicationDate) : self
{
$this->publicationDate = $publicationDate;
return $this;
}
public function getIsGeolocated() : ?bool
{
return $this->isGeolocated;
}
public function setIsGeolocated(bool $isGeolocated) : self
{
$this->isGeolocated = $isGeolocated;
return $this;
}
public function getIsShape() : ?bool
{
return $this->isShape;
}
public function setIsShape(bool $isShape) : self
{
$this->isShape = $isShape;
return $this;
}
public function __toString() : string
{
return (string) $this->id;
}
public function getIsPublic() : ?bool
{
return $this->isPublic;
}
public function setIsPublic(bool $isPublic) : self
{
$this->isPublic = $isPublic;
return $this;
}
public function getGotMedia() : ?bool
{
return $this->gotMedia;
}
public function setGotMedia(bool $gotMedia) : self
{
$this->gotMedia = $gotMedia;
return $this;
}
public function getMediaExplanation() : ?string
{
return $this->mediaExplanation;
}
public function setMediaExplanation(?string $mediaExplanation) : self
{
$this->mediaExplanation = $mediaExplanation;
return $this;
}
public function getIsBooking() : ?bool
{
return $this->isBooking;
}
public function setIsBooking(?bool $isBooking) : self
{
$this->isBooking = $isBooking;
return $this;
}
public function getNumberBooking() : ?int
{
return $this->numberBooking;
}
public function setNumberBooking(?int $numberBooking) : self
{
$this->numberBooking = $numberBooking;
return $this;
}
public function getBookingDate() : ?\DateTimeInterface
{
return $this->bookingDate;
}
public function setBookingDate(?\DateTimeInterface $bookingDate) : self
{
$this->bookingDate = $bookingDate;
return $this;
}
public function getCategory() : ?Category
{
return $this->category;
}
public function setCategory(?Category $category) : self
{
$this->category = $category;
return $this;
}
public function getPdf() : ?Media
{
return $this->pdf;
}
public function setPdf(?Media $pdf) : self
{
$this->pdf = $pdf;
return $this;
}
/**
* @return Collection|Media[]
*/
public function getPictures() : Collection
{
return $this->pictures;
}
public function addPicture(Media $picture) : self
{
if (!$this->pictures->contains($picture)) {
$this->pictures[] = $picture;
$picture->setForm($this);
}
return $this;
}
public function removePicture(Media $picture) : self
{
if ($this->pictures->removeElement($picture)) {
// set the owning side to null (unless already changed)
if ($picture->getForm() === $this) {
$picture->setForm(null);
}
}
return $this;
}
public function getBookingNameDisplay() : ?bool
{
return $this->bookingNameDisplay;
}
public function setBookingNameDisplay(?bool $bookingNameDisplay) : self
{
$this->bookingNameDisplay = $bookingNameDisplay;
return $this;
}
public function getBookingSpace() : ?bool
{
return $this->bookingSpace;
}
public function setBookingSpace(bool $bookingSpace) : self
{
$this->bookingSpace = $bookingSpace;
return $this;
}
public function getIsSigned(): ?bool
{
return $this->isSigned;
}
public function setIsSigned(bool $isSigned): self
{
$this->isSigned = $isSigned;
return $this;
}
public function getIsObject(): ?bool
{
return $this->isObject;
}
public function setIsObject(bool $isObject): self
{
$this->isObject = $isObject;
return $this;
}
public function getMapObjectType(): ?MapObjectType
{
return $this->mapObjectType;
}
public function setMapObjectType(?MapObjectType $mapObjectType): self
{
$this->mapObjectType = $mapObjectType;
return $this;
}
public function getIsLinkedToObject(): ?bool
{
return $this->isLinkedToObject;
}
public function setIsLinkedToObject(?bool $isLinkedToObject): self
{
$this->isLinkedToObject = $isLinkedToObject;
return $this;
}
public function isEdit(): ?bool
{
return $this->edit;
}
public function setEdit(?bool $edit): self
{
$this->edit = $edit;
return $this;
}
public function getIsPolyline(): ?bool
{
return $this->isPolyline;
}
public function setIsPolyline(?bool $isPolyline): self
{
$this->isPolyline = $isPolyline;
return $this;
}
public function getPublicationEnd(): ?\DateTimeInterface
{
return $this->publicationEnd;
}
public function setPublicationEnd(?\DateTimeInterface $publicationEnd): self
{
$this->publicationEnd = $publicationEnd;
return $this;
}
}