<?php namespace App\Entity; use App\Repository\PointTransactionTypeRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use JMS\Serializer\Annotation as Serializer; use JMS\Serializer\Annotation\Expose; use JMS\Serializer\Annotation\Groups; use Symfony\Component\Validator\Constraints as Assert; /** * @ORM\Entity(repositoryClass=PointTransactionTypeRepository::class) * * @Serializer\ExclusionPolicy("ALL") */ class PointTransactionType { public const ORDER = 'order'; public const FIDELITY = 'fidelity'; public const SPONSORSHIP = 'sponsorship'; public const EXCEPTIONAL = 'exceptional'; public const PAYMENT = 'payment'; public const ORDER_CREDIT = 'order_credit'; public const VIRTUAL = 'virtual'; public const PURCHASE_KO = 'purchase_ko'; public const EXPIRATION = 'expiration'; /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") * * @Expose * @Groups ({"point_transaction_type"}) */ private ?int $id = NULL; /** * Slug * * @ORM\Column(type="string", length=15, unique=true) * * @Assert\NotBlank * * @Expose * @Groups ({"point_transaction_type"}) */ private ?string $slug = NULL; /** * Nom * * @ORM\Column(type="string", length=255) * * @Assert\NotBlank * * @Expose * @Groups ({"point_transaction_type"}) */ private ?string $name = NULL; /** * Description * * @ORM\Column(type="string", length=255, nullable=true) * * @Expose * @Groups ({"point_transaction_type"}) */ private ?string $description = NULL; /** * Par défaut * * @ORM\Column(type="boolean", options={"default": false}) * * @Expose * @Groups ({"point_transaction_type"}) */ private bool $isDefault = FALSE; /** * Pour les challenges * * @ORM\Column(type="boolean", options={"default": false}) * * @Expose * @Groups({"point_transaction_type"}) */ private bool $challenge = FALSE; /** * Liste des transactions rattachées * * @ORM\OneToMany(targetEntity=PointTransaction::class, mappedBy="transactionType") */ private Collection $pointTransactions; public function __construct() { $this->pointTransactions = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getSlug(): ?string { return $this->slug; } public function setSlug(string $slug): self { $this->slug = $slug; return $this; } public function getName(): ?string { return $this->name; } public function setName(string $name): self { $this->name = $name; return $this; } public function getDescription(): ?string { return $this->description; } public function setDescription(?string $description): self { $this->description = $description; return $this; } public function getIsDefault(): bool { return $this->isDefault; } public function setIsDefault(bool $isDefault): self { $this->isDefault = $isDefault; return $this; } public function getChallenge(): bool { return $this->challenge; } public function setChallenge(bool $challenge): self { $this->challenge = $challenge; return $this; } /** * @return Collection|PointTransaction[] */ public function getPointTransactions(): Collection { return $this->pointTransactions; } public function addPointTransaction(PointTransaction $pointTransaction): self { if (!$this->pointTransactions->contains($pointTransaction)) { $this->pointTransactions[] = $pointTransaction; $pointTransaction->setTransactionType($this); } return $this; } public function removePointTransaction(PointTransaction $pointTransaction): self { if ($this->pointTransactions->removeElement($pointTransaction)) { // set the owning side to null (unless already changed) if ($pointTransaction->getTransactionType() === $this) { $pointTransaction->setTransactionType(NULL); } } return $this; } }