src/CMSBundle/Entity/SiteSetting.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\CMSBundle\Entity;
  3. use App\CMSBundle\Enum\SiteSettingTypeEnum;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use PN\ServiceBundle\Interfaces\DateTimeInterface;
  6. use PN\ServiceBundle\Model\DateTimeTrait;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. /**
  9. * @ORM\HasLifecycleCallbacks
  10. * @ORM\Table(name="site_setting")
  11. * @ORM\Entity(repositoryClass="App\CMSBundle\Repository\SiteSettingRepository")
  12. * @UniqueEntity(
  13. * fields={"constantName"},
  14. * errorPath="constantName",
  15. * message="This constantName is already exist."
  16. * )
  17. */
  18. class SiteSetting implements DateTimeInterface
  19. {
  20. use DateTimeTrait;
  21. const WEBSITE_HEAD_TAGS = "website-head-tags";
  22. const GOOGLE_TAG_MANAGER_ID = "google-tag-manager-id";
  23. const FACEBOOK_CHAT_PAGE_ID = "facebook-chat-page-id";
  24. const FACEBOOK_PIXEL_ID = "facebook-pixel-id";
  25. const WEBSITE_FAVICON = "website-favicon";
  26. /**
  27. * @ORM\Column(name="id", type="integer")
  28. * @ORM\Id
  29. * @ORM\GeneratedValue(strategy="AUTO")
  30. */
  31. private int $id;
  32. /**
  33. * @ORM\Column(name="constant_name", type="string", unique=true)
  34. */
  35. private ?string $constantName = null;
  36. /**
  37. * @ORM\Column(name="title", type="string")
  38. */
  39. private ?string $title = null;
  40. /**
  41. * @ORM\Column(name="type", enumType=SiteSettingTypeEnum::class, type="string", length=255)
  42. */
  43. private ?SiteSettingTypeEnum $type = null;
  44. /**
  45. * @ORM\Column(name="manage_by_super_admin_only", type="boolean")
  46. */
  47. private bool $manageBySuperAdminOnly = false;
  48. /**
  49. * @ORM\Column(name="value", type="text", nullable=true)
  50. */
  51. private ?string $value = null;
  52. public function getTypeName(): ?string
  53. {
  54. return $this->getType()?->name();
  55. }
  56. public function getType(): ?SiteSettingTypeEnum
  57. {
  58. return $this->type;
  59. }
  60. public function setType(SiteSettingTypeEnum $type): self
  61. {
  62. $this->type = $type;
  63. return $this;
  64. }
  65. public function getValue(): string|bool|null
  66. {
  67. if ($this->getType() == SiteSettingTypeEnum::BOOLEAN) {
  68. if ($this->value == "0") {
  69. return false;
  70. }
  71. return true;
  72. }
  73. return $this->value;
  74. }
  75. public function getId(): ?int
  76. {
  77. return $this->id;
  78. }
  79. public function getConstantName(): ?string
  80. {
  81. return $this->constantName;
  82. }
  83. public function setConstantName(string $constantName): static
  84. {
  85. $this->constantName = $constantName;
  86. return $this;
  87. }
  88. public function getTitle(): ?string
  89. {
  90. return $this->title;
  91. }
  92. public function setTitle(string $title): static
  93. {
  94. $this->title = $title;
  95. return $this;
  96. }
  97. public function isManageBySuperAdminOnly(): ?bool
  98. {
  99. return $this->manageBySuperAdminOnly;
  100. }
  101. public function setManageBySuperAdminOnly(bool $manageBySuperAdminOnly): static
  102. {
  103. $this->manageBySuperAdminOnly = $manageBySuperAdminOnly;
  104. return $this;
  105. }
  106. public function setValue(?string $value): static
  107. {
  108. $this->value = $value;
  109. return $this;
  110. }
  111. }