src/ProductBundle/Entity/Brand.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\ProductBundle\Entity;
  3. use App\ContentBundle\Entity\Post;
  4. use App\ProductBundle\Entity\Translation\BrandTranslation;
  5. use App\SeoBundle\Entity\Seo;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use PN\LocaleBundle\Model\LocaleTrait;
  10. use PN\LocaleBundle\Model\Translatable;
  11. use PN\ServiceBundle\Interfaces\DateTimeInterface;
  12. use PN\ServiceBundle\Model\DateTimeTrait;
  13. use PN\ServiceBundle\Model\VirtualDeleteTrait;
  14. use Symfony\Component\Validator\Constraints as Assert;
  15. /**
  16. * @ORM\HasLifecycleCallbacks
  17. * @ORM\Table("brand")
  18. * @ORM\Entity(repositoryClass="App\ProductBundle\Repository\BrandRepository")
  19. */
  20. class Brand implements Translatable, DateTimeInterface
  21. {
  22. use VirtualDeleteTrait,
  23. DateTimeTrait,
  24. LocaleTrait;
  25. /**
  26. * @ORM\Column(name="id", type="integer")
  27. * @ORM\Id
  28. * @ORM\GeneratedValue(strategy="AUTO")
  29. */
  30. private ?int $id = null;
  31. /**
  32. * @ORM\OneToOne(targetEntity="\App\SeoBundle\Entity\Seo", cascade={"persist", "remove"})
  33. */
  34. private ?Seo $seo = null;
  35. /**
  36. * @ORM\OneToOne(targetEntity="\App\ContentBundle\Entity\Post", cascade={"persist", "remove"})
  37. */
  38. private ?Post $post = null;
  39. /**
  40. * @ORM\Column(name="jp_id", type="string", length=45, nullable=true)
  41. */
  42. private ?string $jpId = null;
  43. /**
  44. * @Assert\NotBlank()
  45. * @ORM\Column(name="title", type="string", length=45)
  46. */
  47. private ?string $title = null;
  48. /**
  49. * @ORM\Column(name="publish", type="boolean")
  50. */
  51. private bool $publish = true;
  52. /**
  53. * @ORM\Column(name="featured", type="boolean")
  54. */
  55. private bool $featured = true;
  56. /**
  57. * @ORM\Column(name="tarteb", type="smallint", nullable=true, options={"default":0}))
  58. */
  59. private ?int $tarteb = 0;
  60. /**
  61. * @ORM\OneToMany(targetEntity="App\ProductBundle\Entity\Translation\BrandTranslation", mappedBy="translatable", cascade={"ALL"}, orphanRemoval=true)
  62. */
  63. private $translations;
  64. public function __construct()
  65. {
  66. $this->translations = new ArrayCollection();
  67. }
  68. public function __toString()
  69. {
  70. return $this->getTitle();
  71. }
  72. public function getTitle(): ?string
  73. {
  74. return !$this->currentTranslation ? $this->title : $this->currentTranslation->getTitle();
  75. }
  76. public function getId(): ?int
  77. {
  78. return $this->id;
  79. }
  80. public function getJpId(): ?string
  81. {
  82. return $this->jpId;
  83. }
  84. public function setJpId(string $jpId): static
  85. {
  86. $this->jpId = $jpId;
  87. return $this;
  88. }
  89. public function setTitle(string $title): static
  90. {
  91. $this->title = $title;
  92. return $this;
  93. }
  94. public function isPublish(): ?bool
  95. {
  96. return $this->publish;
  97. }
  98. public function setPublish(bool $publish): static
  99. {
  100. $this->publish = $publish;
  101. return $this;
  102. }
  103. public function isFeatured(): ?bool
  104. {
  105. return $this->featured;
  106. }
  107. public function setFeatured(bool $featured): static
  108. {
  109. $this->featured = $featured;
  110. return $this;
  111. }
  112. public function getTarteb(): ?int
  113. {
  114. return $this->tarteb;
  115. }
  116. public function setTarteb(?int $tarteb): static
  117. {
  118. $this->tarteb = $tarteb;
  119. return $this;
  120. }
  121. public function getSeo(): ?Seo
  122. {
  123. return $this->seo;
  124. }
  125. public function setSeo(?Seo $seo): static
  126. {
  127. $this->seo = $seo;
  128. return $this;
  129. }
  130. public function getPost(): ?Post
  131. {
  132. return $this->post;
  133. }
  134. public function setPost(?Post $post): static
  135. {
  136. $this->post = $post;
  137. return $this;
  138. }
  139. /**
  140. * @return Collection<int, BrandTranslation>
  141. */
  142. public function getTranslations(): Collection
  143. {
  144. return $this->translations;
  145. }
  146. public function addTranslation(BrandTranslation $translation): static
  147. {
  148. if (!$this->translations->contains($translation)) {
  149. $this->translations->add($translation);
  150. $translation->setTranslatable($this);
  151. }
  152. return $this;
  153. }
  154. public function removeTranslation(BrandTranslation $translation): static
  155. {
  156. if ($this->translations->removeElement($translation)) {
  157. // set the owning side to null (unless already changed)
  158. if ($translation->getTranslatable() === $this) {
  159. $translation->setTranslatable(null);
  160. }
  161. }
  162. return $this;
  163. }
  164. }