<?php
/**
* @author Quentin CHATELAIN (contact@scaledev.fr)
* @copyright 2021 - ScaleDEV SAS, 12 RUE CHARLES MORET, 10120 ST ANDRE LES VERGERS
* @license commercial
*/
declare(strict_types=1);
namespace Bluue\SalesBundle\Entity;
use App\DoctrineExtensions\IsActiveEntity;
use App\DoctrineExtensions\IsDefaultEntity;
use App\DoctrineExtensions\ArchivedEntity;
use Bluue\SalesBundle\EventListener\OrderStateListener;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid;
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
use Gedmo\Mapping\Annotation as Gedmo;
use Bluue\SalesBundle\Repository\OrderStateRepository;
use App\DoctrineExtensions\Timestampable\Traits\UserTimestampableEntity;
use App\DoctrineExtensions\SoftDeleteable\Traits\UserSoftDeleteableEntity;
/**
* @ORM\Entity(repositoryClass=OrderStateRepository::class)
* @ORM\Table(name="sales_bundle__order_state", indexes={
* @ORM\Index(name="color", columns={"color"}),
* @ORM\Index(name="text_color", columns={"text_color"}),
* @ORM\Index(name="name", columns={"name"}),
* @ORM\Index(name="delivered", columns={"delivered"}),
* @ORM\Index(name="invoiced", columns={"invoiced"}),
* @ORM\Index(name="archived", columns={"archived"}),
* @ORM\Index(name="is_active", columns={"is_active"}),
* @ORM\Index(name="is_default", columns={"is_default"}),
* @ORM\Index(name="deleted_at", columns={"deleted_at"}),
* @ORM\Index(name="created_at", columns={"created_at"}),
* @ORM\Index(name="updated_at", columns={"updated_at"})
* })
* @Gedmo\TranslationEntity(class="Bluue\SalesBundle\Entity\OrderStateTranslation")
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=false)
* @ORM\EntityListeners({OrderStateListener::class})
*/
class OrderState
{
use UserTimestampableEntity;
use UserSoftDeleteableEntity;
use IsActiveEntity;
use IsDefaultEntity;
use ArchivedEntity;
/**
* @ORM\Id
* @ORM\Column(type="uuid")
* @ORM\GeneratedValue(strategy="CUSTOM")
* @ORM\CustomIdGenerator(class=UuidGenerator::class)
*/
private ?Uuid $id = null;
/**
* @Gedmo\Translatable
* @ORM\Column(type="string", length=64)
*/
private ?string $name = null;
/**
* @ORM\Column(type="string", length=7)
*/
private ?string $color = null;
/**
* @ORM\Column(type="string", length=7)
*/
private ?string $text_color = null;
/**
* @ORM\Column(type="boolean")
*/
private bool $delivered = false;
/**
* @ORM\Column(type="boolean")
*/
private bool $invoiced = false;
/**
* @ORM\Column(type="boolean")
*/
private bool $canceled = false;
/**
* @ORM\OneToMany(
* targetEntity="OrderStateTranslation",
* mappedBy="object",
* cascade={"persist", "remove"},
* fetch="EXTRA_LAZY"
* )
*/
private Collection $translations;
public function __construct()
{
$this->translations = new ArrayCollection();
}
/**
* @return Uuid|null
*/
public function getId(): ?Uuid
{
return $this->id;
}
/**
* @return string|null
*/
public function getName(): ?string
{
return $this->name;
}
/**
* @param string|null $name
* @return OrderState
*/
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return string|null
*/
public function getColor(): ?string
{
return $this->color;
}
/**
* @param string|null $color
* @return OrderState
*/
public function setColor(?string $color): self
{
$this->color = $color;
return $this;
}
/**
* @return string|null
*/
public function getTextColor(): ?string
{
return $this->text_color;
}
/**
* @param string|null $text_color
* @return OrderState
*/
public function setTextColor(?string $text_color): self
{
$this->text_color = $text_color;
return $this;
}
/**
* @return bool
*/
public function isDelivered(): bool
{
return $this->delivered;
}
/**
* @param bool $delivered
* @return OrderState
*/
public function setDelivered(bool $delivered): self
{
$this->delivered = $delivered;
return $this;
}
/**
* @return bool
*/
public function isInvoiced(): bool
{
return $this->invoiced;
}
/**
* @param bool $invoiced
* @return OrderState
*/
public function setInvoiced(bool $invoiced): self
{
$this->invoiced = $invoiced;
return $this;
}
/**
* @return bool
*/
public function isCanceled(): bool
{
return $this->canceled;
}
/**
* @param bool $canceled
* @return OrderState
*/
public function setCanceled(bool $canceled): self
{
$this->canceled = $canceled;
return $this;
}
/**
* @return Collection|OrderStateTranslation[]
*/
public function getTranslations(): Collection
{
return $this->translations;
}
/**
* @param OrderStateTranslation $t
* @return OrderState
*/
public function addTranslation(OrderStateTranslation $t): self
{
if (!$this->translations->contains($t)) {
$this->translations[] = $t;
$t->setObject($this);
}
return $this;
}
}