src/Entity/Association.php line 19
<?php
namespace App\Entity;
use App\Entity\Participation\Asso;
use App\Entity\Traits\TimestampableTrait;
use App\Repository\AssociationRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Entity\File as EmbeddedFile;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: AssociationRepository::class)]
#[Vich\Uploadable]
class Association
{
use TimestampableTrait;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\Embedded(class: EmbeddedFile::class)]
private ?EmbeddedFile $image = null;
#[Vich\UploadableField(mapping: 'asso_image', fileNameProperty: 'image.name', size: 'image.size', mimeType: 'image.mimeType', originalName: 'image.originalName', dimensions: 'image.dimensions')]
#[Assert\File(
maxSize: '15M',
mimeTypes: ['image/jpeg', 'image/png'],
maxSizeMessage: 'Le fichier ne doit pas dépasser {{ size }}',
mimeTypesMessage: 'Veuillez mettre une image(jpeg ou png)',
)]
private ?File $imageFile = null;
#[ORM\Column(type: Types::TEXT)]
private ?string $description = null;
#[ORM\Column(length: 5)]
private ?string $pal = null;
#[ORM\OneToMany(mappedBy: 'association', targetEntity: Asso::class, orphanRemoval: true)]
private Collection $participations;
public function __construct()
{
$this->image = new EmbeddedFile();
$this->participations = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getImage(): ?EmbeddedFile
{
return $this->image;
}
public function setImage(?EmbeddedFile $image): Association
{
$this->image = $image;
return $this;
}
public function getImageFile(): ?File
{
return $this->imageFile;
}
public function setImageFile(?File $image = null): self
{
$this->imageFile = $image;
if (null !== $image) {
$this->updatedAt = new \DateTimeImmutable();
}
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(string $description): self
{
$this->description = $description;
return $this;
}
public function getPal(): ?string
{
return $this->pal;
}
public function setPal(string $pal): self
{
$this->pal = $pal;
return $this;
}
/**
* @return Collection<int, Asso>
*/
public function getParticipations(): Collection
{
return $this->participations;
}
public function addParticipation(Asso $participation): self
{
if (!$this->participations->contains($participation)) {
$this->participations->add($participation);
$participation->setAssociation($this);
}
return $this;
}
public function removeParticipation(Asso $participation): self
{
if ($this->participations->removeElement($participation)) {
// set the owning side to null (unless already changed)
if ($participation->getAssociation() === $this) {
$participation->setAssociation(null);
}
}
return $this;
}
}