src/Entity/PointTransactionType.php line 19

Open in your IDE?
  1. <?php
  2.     namespace App\Entity;
  3.     use App\Repository\PointTransactionTypeRepository;
  4.     use Doctrine\Common\Collections\ArrayCollection;
  5.     use Doctrine\Common\Collections\Collection;
  6.     use Doctrine\ORM\Mapping as ORM;
  7.     use JMS\Serializer\Annotation as Serializer;
  8.     use JMS\Serializer\Annotation\Expose;
  9.     use JMS\Serializer\Annotation\Groups;
  10.     use Symfony\Component\Validator\Constraints as Assert;
  11.     /**
  12.      * @ORM\Entity(repositoryClass=PointTransactionTypeRepository::class)
  13.      *
  14.      * @Serializer\ExclusionPolicy("ALL")
  15.      */
  16.     class PointTransactionType
  17.     {
  18.         public const ORDER        'order';
  19.         public const FIDELITY     'fidelity';
  20.         public const SPONSORSHIP  'sponsorship';
  21.         public const EXCEPTIONAL  'exceptional';
  22.         public const ORDER_CREDIT 'order_credit';
  23.         public const VIRTUAL      'virtual';
  24.         /**
  25.          * @ORM\Id
  26.          * @ORM\GeneratedValue
  27.          * @ORM\Column(type="integer")
  28.          *
  29.          * @Expose
  30.          * @Groups ({"point_transaction_type"})
  31.          */
  32.         private ?int $id NULL;
  33.         /**
  34.          * Slug
  35.          *
  36.          * @ORM\Column(type="string", length=15, unique=true)
  37.          *
  38.          * @Assert\NotBlank
  39.          *
  40.          * @Expose
  41.          * @Groups ({"point_transaction_type"})
  42.          */
  43.         private ?string $slug NULL;
  44.         /**
  45.          * Nom
  46.          *
  47.          * @ORM\Column(type="string", length=255)
  48.          *
  49.          * @Assert\NotBlank
  50.          *
  51.          * @Expose
  52.          * @Groups ({"point_transaction_type"})
  53.          */
  54.         private ?string $name NULL;
  55.         /**
  56.          * Description
  57.          *
  58.          * @ORM\Column(type="string", length=255, nullable=true)
  59.          *
  60.          * @Expose
  61.          * @Groups ({"point_transaction_type"})
  62.          */
  63.         private ?string $description NULL;
  64.         /**
  65.          * Par défaut
  66.          *
  67.          * @ORM\Column(type="boolean", options={"default": false})
  68.          *
  69.          * @Expose
  70.          * @Groups ({"point_transaction_type"})
  71.          */
  72.         private bool $isDefault FALSE;
  73.         /**
  74.          * Pour les challenges
  75.          *
  76.          * @ORM\Column(type="boolean", options={"default": false})
  77.          *
  78.          * @Expose
  79.          * @Groups({"point_transaction_type"})
  80.          */
  81.         private bool $challenge FALSE;
  82.         /**
  83.          * Liste des transactions rattachées
  84.          *
  85.          * @ORM\OneToMany(targetEntity=PointTransaction::class, mappedBy="transactionType")
  86.          */
  87.         private Collection $pointTransactions;
  88.         public function __construct()
  89.         {
  90.             $this->pointTransactions = new ArrayCollection();
  91.         }
  92.         public function getId(): ?int
  93.         {
  94.             return $this->id;
  95.         }
  96.         public function getSlug(): ?string
  97.         {
  98.             return $this->slug;
  99.         }
  100.         public function setSlug(string $slug): self
  101.         {
  102.             $this->slug $slug;
  103.             return $this;
  104.         }
  105.         public function getName(): ?string
  106.         {
  107.             return $this->name;
  108.         }
  109.         public function setName(string $name): self
  110.         {
  111.             $this->name $name;
  112.             return $this;
  113.         }
  114.         public function getDescription(): ?string
  115.         {
  116.             return $this->description;
  117.         }
  118.         public function setDescription(?string $description): self
  119.         {
  120.             $this->description $description;
  121.             return $this;
  122.         }
  123.         public function getIsDefault(): bool
  124.         {
  125.             return $this->isDefault;
  126.         }
  127.         public function setIsDefault(bool $isDefault): self
  128.         {
  129.             $this->isDefault $isDefault;
  130.             return $this;
  131.         }
  132.         public function getChallenge(): bool
  133.         {
  134.             return $this->challenge;
  135.         }
  136.         public function setChallenge(bool $challenge): self
  137.         {
  138.             $this->challenge $challenge;
  139.             return $this;
  140.         }
  141.         /**
  142.          * @return Collection|PointTransaction[]
  143.          */
  144.         public function getPointTransactions(): Collection
  145.         {
  146.             return $this->pointTransactions;
  147.         }
  148.         public function addPointTransaction(PointTransaction $pointTransaction): self
  149.         {
  150.             if (!$this->pointTransactions->contains($pointTransaction)) {
  151.                 $this->pointTransactions[] = $pointTransaction;
  152.                 $pointTransaction->setTransactionType($this);
  153.             }
  154.             return $this;
  155.         }
  156.         public function removePointTransaction(PointTransaction $pointTransaction): self
  157.         {
  158.             if ($this->pointTransactions->removeElement($pointTransaction)) {
  159.                 // set the owning side to null (unless already changed)
  160.                 if ($pointTransaction->getTransactionType() === $this) {
  161.                     $pointTransaction->setTransactionType(NULL);
  162.                 }
  163.             }
  164.             return $this;
  165.         }
  166.     }