src/Entity/Template.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\TemplateRepository;
  4. use App\Translation\AutoTranslatableTrait;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
  9. #[ORM\Entity(repositoryClassTemplateRepository::class)]
  10. class Template implements TranslatableInterface
  11. {
  12.     use AutoTranslatableTrait;
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column(type'integer')]
  16.     private $id;
  17.     #[ORM\Column(type'string'length50)]
  18.     private $type;
  19.     #[ORM\Column(type'string'length100)]
  20.     private $name;
  21.     #[ORM\Column(type'text'nullabletrue)]
  22.     private $description;
  23.     #[ORM\ManyToOne(targetEntityUser::class, inversedBy'templates')]
  24.     #[ORM\JoinColumn(nullablefalse)]
  25.     private $created_by_user;
  26.     #[ORM\Column(type'boolean')]
  27.     private $created_by_fryd;
  28.     #[ORM\Column(type'json')]
  29.     private $data = [];
  30.     #[ORM\Column(type'json'nullabletrue)]
  31.     private $metadata = [];
  32.     #[ORM\Column(type'datetime')]
  33.     private $created_at;
  34.     #[ORM\Column(type'datetime'nullabletrue)]
  35.     private $updated_at;
  36.     #[ORM\OneToMany(targetEntityFavoriteTemplate::class, mappedBy'template'orphanRemovaltrue)]
  37.     private $favoriteTemplates;
  38.     #[ORM\OneToMany(targetEntityTemplateUsage::class, mappedBy'template'orphanRemovaltrue)]
  39.     private $templateUsages;
  40.     #[ORM\OneToMany(targetEntityTemplateTranslation::class, mappedBy'translatable'orphanRemovaltrue)]
  41.     private $templateTranslation;
  42.     #[ORM\Column(type'boolean'nullabletrue)]
  43.     private $recommended_by_fryd;
  44.     #[ORM\Column(type'string'length255nullabletrue)]
  45.     private $dynamic_link;
  46.     public function __construct()
  47.     {
  48.         $this->favoriteTemplates = new ArrayCollection();
  49.         $this->created_at = new \DateTime();
  50.         $this->templateUsages = new ArrayCollection();
  51.     }
  52.     public function getId(): ?int
  53.     {
  54.         return $this->id;
  55.     }
  56.     public function getType(): ?string
  57.     {
  58.         return $this->type;
  59.     }
  60.     public function setType(string $type): self
  61.     {
  62.         $this->type $type;
  63.         return $this;
  64.     }
  65.     public function getName($skipTranslation false): ?string
  66.     {
  67.         if($skipTranslation || $this->shouldNotBeTranslated()) {
  68.             return $this->name;
  69.         }
  70.         $translated $this->translate()->getName();
  71.         return !empty($translated) ? $translated $this->name;
  72.     }
  73.     public function setName(string $name): self
  74.     {
  75.         $this->name $name;
  76.         return $this;
  77.     }
  78.     public function getDescription($skipTranslation=false): ?string
  79.     {
  80.         if($skipTranslation || $this->shouldNotBeTranslated()) {
  81.             return $this->description;
  82.         }
  83.         $translated $this->translate()->getDescription();
  84.         return !empty($translated) ? $translated $this->description;
  85.     }
  86.     public function setDescription(?string $description): self
  87.     {
  88.         $this->description $description;
  89.         return $this;
  90.     }
  91.     public function getCreatedByUser(): ?User
  92.     {
  93.         return $this->created_by_user;
  94.     }
  95.     public function setCreatedByUser(?User $created_by_user): self
  96.     {
  97.         $this->created_by_user $created_by_user;
  98.         return $this;
  99.     }
  100.     public function getCreatedByFryd(): ?bool
  101.     {
  102.         return $this->created_by_fryd;
  103.     }
  104.     public function setCreatedByFryd(bool $created_by_fryd): self
  105.     {
  106.         $this->created_by_fryd $created_by_fryd;
  107.         return $this;
  108.     }
  109.     public function getData(): ?array
  110.     {
  111.         return $this->data;
  112.     }
  113.     public function setData(array $data): self
  114.     {
  115.         $this->data $data;
  116.         return $this;
  117.     }
  118.     public function getMetadata(): ?array
  119.     {
  120.         return $this->metadata;
  121.     }
  122.     public function setMetadata(?array $metadata): self
  123.     {
  124.         $this->metadata $metadata;
  125.         return $this;
  126.     }
  127.     public function getCreatedAt(): ?\DateTimeInterface
  128.     {
  129.         return $this->created_at;
  130.     }
  131.     public function setCreatedAt(\DateTimeInterface $created_at): self
  132.     {
  133.         $this->created_at $created_at;
  134.         return $this;
  135.     }
  136.     public function getUpdatedAt(): ?\DateTimeInterface
  137.     {
  138.         return $this->updated_at;
  139.     }
  140.     public function setUpdatedAt(?\DateTimeInterface $updated_at): self
  141.     {
  142.         $this->updated_at $updated_at;
  143.         return $this;
  144.     }
  145.     /**
  146.      * @return Collection<int, FavoriteTemplate>
  147.      */
  148.     public function getFavoriteTemplates(): Collection
  149.     {
  150.         return $this->favoriteTemplates;
  151.     }
  152.     public function addFavoriteTemplate(FavoriteTemplate $favoriteTemplate): self
  153.     {
  154.         if (!$this->favoriteTemplates->contains($favoriteTemplate)) {
  155.             $this->favoriteTemplates[] = $favoriteTemplate;
  156.             $favoriteTemplate->setTemplate($this);
  157.         }
  158.         return $this;
  159.     }
  160.     public function removeFavoriteTemplate(FavoriteTemplate $favoriteTemplate): self
  161.     {
  162.         if ($this->favoriteTemplates->removeElement($favoriteTemplate)) {
  163.             // set the owning side to null (unless already changed)
  164.             if ($favoriteTemplate->getTemplate() === $this) {
  165.                 $favoriteTemplate->setTemplate(null);
  166.             }
  167.         }
  168.         return $this;
  169.     }
  170.     /**
  171.      * @return Collection<int, TemplateUsage>
  172.      */
  173.     public function getTemplateUsages(): Collection
  174.     {
  175.         return $this->templateUsages;
  176.     }
  177.     public function addTemplateUsage(TemplateUsage $templateUsage): self
  178.     {
  179.         if (!$this->templateUsages->contains($templateUsage)) {
  180.             $this->templateUsages[] = $templateUsage;
  181.             $templateUsage->setTemplate($this);
  182.         }
  183.         return $this;
  184.     }
  185.     public function removeTemplateUsage(TemplateUsage $templateUsage): self
  186.     {
  187.         if ($this->templateUsages->removeElement($templateUsage)) {
  188.             // set the owning side to null (unless already changed)
  189.             if ($templateUsage->getTemplate() === $this) {
  190.                 $templateUsage->setTemplate(null);
  191.             }
  192.         }
  193.         return $this;
  194.     }
  195.     public function getRecommendedByFryd(): ?bool
  196.     {
  197.         return $this->recommended_by_fryd;
  198.     }
  199.     public function setRecommendedByFryd(?bool $recommended_by_fryd): self
  200.     {
  201.         $this->recommended_by_fryd $recommended_by_fryd;
  202.         return $this;
  203.     }
  204.     public function getDynamicLink(): ?string
  205.     {
  206.         return $this->dynamic_link;
  207.     }
  208.     public function setDynamicLink(?string $dynamic_link): self
  209.     {
  210.         $this->dynamic_link $dynamic_link;
  211.         return $this;
  212.     }
  213. }