src/Entity/TextTemplate.php line 31

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\TextTemplateRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6. * @ORM\Table(
  7. * name="text_template",
  8. * uniqueConstraints={
  9. *
  10. * @ORM\UniqueConstraint(
  11. * name="text_template_unique",
  12. * columns={"name", "tenant_id"}
  13. * )
  14. * },
  15. * indexes={
  16. *
  17. * @ORM\Index(
  18. * name="text_template_name_idx",
  19. * columns={"name"}
  20. * )
  21. * }
  22. * )
  23. *
  24. * @ORM\Entity(repositoryClass=TextTemplateRepository::class)
  25. *
  26. * @ORM\HasLifecycleCallbacks()
  27. */
  28. class TextTemplate {
  29. use MetaTrait;
  30. /**
  31. * @ORM\Id
  32. *
  33. * @ORM\GeneratedValue
  34. *
  35. * @ORM\Column(type="integer")
  36. */
  37. private $id;
  38. /**
  39. * @ORM\Column(type="string", length=255)
  40. */
  41. private $name;
  42. /**
  43. * @ORM\ManyToOne(targetEntity=Tenant::class, inversedBy="textTemplates")
  44. *
  45. * @ORM\JoinColumn(nullable=false)
  46. */
  47. private $tenant;
  48. /**
  49. * @ORM\Column(type="text")
  50. */
  51. private $text;
  52. public function __toString() {
  53. return "{$this->getTenant()->getName()} - {$this->getName()}";
  54. }
  55. public function getId(): ?int {
  56. return $this->id;
  57. }
  58. public function getName(): ?string {
  59. return $this->name;
  60. }
  61. public function setName(string $name): self {
  62. $this->name = $name;
  63. return $this;
  64. }
  65. public function getTenant(): ?Tenant {
  66. return $this->tenant;
  67. }
  68. public function setTenant(?Tenant $tenant): self {
  69. $this->tenant = $tenant;
  70. return $this;
  71. }
  72. public function getText(): ?string {
  73. return $this->text;
  74. }
  75. public function setText(string $text): self {
  76. $this->text = $text;
  77. return $this;
  78. }
  79. /**
  80. * @ORM\PrePersist
  81. */
  82. public function setDefaults(): self {
  83. return $this
  84. ->setCreatedAt(new \DateTime())
  85. ;
  86. }
  87. /**
  88. * @ORM\PreUpdate
  89. */
  90. public function setModified(): self {
  91. return $this
  92. ->setModifiedAt(new \DateTime())
  93. ;
  94. }
  95. }