Sin descripción

SettingEntity.php 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace MailPoet\Entities;
  3. if (!defined('ABSPATH')) exit;
  4. use MailPoet\Doctrine\EntityTraits\AutoincrementedIdTrait;
  5. use MailPoet\Doctrine\EntityTraits\CreatedAtTrait;
  6. use MailPoet\Doctrine\EntityTraits\UpdatedAtTrait;
  7. use MailPoet\Util\Helpers;
  8. use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
  9. use MailPoetVendor\Symfony\Component\Validator\Constraints as Assert;
  10. /**
  11. * @ORM\Entity()
  12. * @ORM\Table(name="settings")
  13. */
  14. class SettingEntity {
  15. use AutoincrementedIdTrait;
  16. use CreatedAtTrait;
  17. use UpdatedAtTrait;
  18. /**
  19. * @ORM\Column(type="string")
  20. * @Assert\NotBlank()
  21. * @var string
  22. */
  23. private $name;
  24. /**
  25. * @ORM\Column(type="text", nullable=true)
  26. * @var string|null
  27. */
  28. private $value;
  29. /** @return string */
  30. public function getName() {
  31. return $this->name;
  32. }
  33. /** @param string $name */
  34. public function setName($name) {
  35. $this->name = $name;
  36. }
  37. /** @return mixed */
  38. public function getValue() {
  39. return $this->value !== null && is_serialized($this->value) ? unserialize($this->value) : $this->value;
  40. }
  41. /** @param mixed $value */
  42. public function setValue($value) {
  43. $value = Helpers::recursiveTrim($value);
  44. if (is_array($value)) {
  45. $value = serialize($value);
  46. }
  47. $this->value = $value;
  48. }
  49. }