vendor/bluue/sales-bundle/src/Entity/OrderState.php line 46

Open in your IDE?
  1. <?php
  2. /**
  3.  * @author Quentin CHATELAIN (contact@scaledev.fr)
  4.  * @copyright 2021 - ScaleDEV SAS, 12 RUE CHARLES MORET, 10120 ST ANDRE LES VERGERS
  5.  * @license commercial
  6.  */
  7. declare(strict_types=1);
  8. namespace Bluue\SalesBundle\Entity;
  9. use App\DoctrineExtensions\IsActiveEntity;
  10. use App\DoctrineExtensions\IsDefaultEntity;
  11. use App\DoctrineExtensions\ArchivedEntity;
  12. use Bluue\SalesBundle\EventListener\OrderStateListener;
  13. use Doctrine\Common\Collections\ArrayCollection;
  14. use Doctrine\Common\Collections\Collection;
  15. use Doctrine\ORM\Mapping as ORM;
  16. use Symfony\Component\Uid\Uuid;
  17. use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
  18. use Gedmo\Mapping\Annotation as Gedmo;
  19. use Bluue\SalesBundle\Repository\OrderStateRepository;
  20. use App\DoctrineExtensions\Timestampable\Traits\UserTimestampableEntity;
  21. use App\DoctrineExtensions\SoftDeleteable\Traits\UserSoftDeleteableEntity;
  22. /**
  23.  * @ORM\Entity(repositoryClass=OrderStateRepository::class)
  24.  * @ORM\Table(name="sales_bundle__order_state", indexes={
  25.  *  @ORM\Index(name="color", columns={"color"}),
  26.  *  @ORM\Index(name="text_color", columns={"text_color"}),
  27.  *  @ORM\Index(name="name", columns={"name"}),
  28.  *  @ORM\Index(name="delivered", columns={"delivered"}),
  29.  *  @ORM\Index(name="invoiced", columns={"invoiced"}),
  30.  *  @ORM\Index(name="archived", columns={"archived"}),
  31.  *  @ORM\Index(name="is_active", columns={"is_active"}),
  32.  *  @ORM\Index(name="is_default", columns={"is_default"}),
  33.  *  @ORM\Index(name="deleted_at", columns={"deleted_at"}),
  34.  *  @ORM\Index(name="created_at", columns={"created_at"}),
  35.  *  @ORM\Index(name="updated_at", columns={"updated_at"})
  36.  * })
  37.  * @Gedmo\TranslationEntity(class="Bluue\SalesBundle\Entity\OrderStateTranslation")
  38.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=false)
  39.  * @ORM\EntityListeners({OrderStateListener::class})
  40.  */
  41. class OrderState
  42. {
  43.     use UserTimestampableEntity;
  44.     use UserSoftDeleteableEntity;
  45.     use IsActiveEntity;
  46.     use IsDefaultEntity;
  47.     use ArchivedEntity;
  48.     /**
  49.      * @ORM\Id
  50.      * @ORM\Column(type="uuid")
  51.      * @ORM\GeneratedValue(strategy="CUSTOM")
  52.      * @ORM\CustomIdGenerator(class=UuidGenerator::class)
  53.      */
  54.     private ?Uuid $id null;
  55.     /**
  56.      * @Gedmo\Translatable
  57.      * @ORM\Column(type="string", length=64)
  58.      */
  59.     private ?string $name null;
  60.     /**
  61.      * @ORM\Column(type="string", length=7)
  62.      */
  63.     private ?string $color null;
  64.     /**
  65.      * @ORM\Column(type="string", length=7)
  66.      */
  67.     private ?string $text_color null;
  68.     /**
  69.      * @ORM\Column(type="boolean")
  70.      */
  71.     private bool $delivered false;
  72.     /**
  73.      * @ORM\Column(type="boolean")
  74.      */
  75.     private bool $invoiced false;
  76.     /**
  77.      * @ORM\Column(type="boolean")
  78.      */
  79.     private bool $canceled false;
  80.     /**
  81.      * @ORM\OneToMany(
  82.      *   targetEntity="OrderStateTranslation",
  83.      *   mappedBy="object",
  84.      *   cascade={"persist", "remove"},
  85.      *   fetch="EXTRA_LAZY"
  86.      * )
  87.      */
  88.     private Collection $translations;
  89.     public function __construct()
  90.     {
  91.         $this->translations = new ArrayCollection();
  92.     }
  93.     /**
  94.      * @return Uuid|null
  95.      */
  96.     public function getId(): ?Uuid
  97.     {
  98.         return $this->id;
  99.     }
  100.     /**
  101.      * @return string|null
  102.      */
  103.     public function getName(): ?string
  104.     {
  105.         return $this->name;
  106.     }
  107.     /**
  108.      * @param string|null $name
  109.      * @return OrderState
  110.      */
  111.     public function setName(?string $name): self
  112.     {
  113.         $this->name $name;
  114.         return $this;
  115.     }
  116.     /**
  117.      * @return string|null
  118.      */
  119.     public function getColor(): ?string
  120.     {
  121.         return $this->color;
  122.     }
  123.     /**
  124.      * @param string|null $color
  125.      * @return OrderState
  126.      */
  127.     public function setColor(?string $color): self
  128.     {
  129.         $this->color $color;
  130.         return $this;
  131.     }
  132.     /**
  133.      * @return string|null
  134.      */
  135.     public function getTextColor(): ?string
  136.     {
  137.         return $this->text_color;
  138.     }
  139.     /**
  140.      * @param string|null $text_color
  141.      * @return OrderState
  142.      */
  143.     public function setTextColor(?string $text_color): self
  144.     {
  145.         $this->text_color $text_color;
  146.         return $this;
  147.     }
  148.     /**
  149.      * @return bool
  150.      */
  151.     public function isDelivered(): bool
  152.     {
  153.         return $this->delivered;
  154.     }
  155.     /**
  156.      * @param bool $delivered
  157.      * @return OrderState
  158.      */
  159.     public function setDelivered(bool $delivered): self
  160.     {
  161.         $this->delivered $delivered;
  162.         return $this;
  163.     }
  164.     /**
  165.      * @return bool
  166.      */
  167.     public function isInvoiced(): bool
  168.     {
  169.         return $this->invoiced;
  170.     }
  171.     /**
  172.      * @param bool $invoiced
  173.      * @return OrderState
  174.      */
  175.     public function setInvoiced(bool $invoiced): self
  176.     {
  177.         $this->invoiced $invoiced;
  178.         return $this;
  179.     }
  180.     /**
  181.      * @return bool
  182.      */
  183.     public function isCanceled(): bool
  184.     {
  185.         return $this->canceled;
  186.     }
  187.     /**
  188.      * @param bool $canceled
  189.      * @return OrderState
  190.      */
  191.     public function setCanceled(bool $canceled): self
  192.     {
  193.         $this->canceled $canceled;
  194.         return $this;
  195.     }
  196.     /**
  197.      * @return Collection|OrderStateTranslation[]
  198.      */
  199.     public function getTranslations(): Collection
  200.     {
  201.         return $this->translations;
  202.     }
  203.     /**
  204.      * @param OrderStateTranslation $t
  205.      * @return OrderState
  206.      */
  207.     public function addTranslation(OrderStateTranslation $t): self
  208.     {
  209.         if (!$this->translations->contains($t)) {
  210.             $this->translations[] = $t;
  211.             $t->setObject($this);
  212.         }
  213.         return $this;
  214.     }
  215. }