src/Entity/System/Config.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity\System;
  3. use Symfony\Component\Validator\Constraints AS Constraints;
  4. use Symfony\Component\Validator\Constraints AS Assert;
  5. use Doctrine\ORM\Mapping AS ORM;
  6. use Ramsey\Uuid\Uuid;
  7. /**
  8. * @ORM\Entity(repositoryClass="App\Repository\System\ConfigRepository")
  9. * @ORM\Table(name="system_config")
  10. */
  11. class Config
  12. {
  13. /**
  14. * @ORM\Id
  15. * @ORM\GeneratedValue(strategy="AUTO")
  16. * @ORM\Column(type="integer")
  17. */
  18. private $id;
  19. /**
  20. * @ORM\Column(type="uuid")
  21. * @Assert\Uuid
  22. */
  23. protected $uuid;
  24. /**
  25. * @var \DateTime
  26. *
  27. * @ORM\Column(type="datetime", nullable=false)
  28. */
  29. private $created;
  30. /**
  31. * @var \DateTime
  32. *
  33. * @ORM\Column(type="datetime", nullable=false)
  34. */
  35. private $modified;
  36. /**
  37. * @ORM\Column(name="`key`", type="string", length=60, nullable=false)
  38. */
  39. private $key;
  40. /**
  41. * @ORM\Column(type="text", nullable=true)
  42. */
  43. private $value;
  44. public function __construct($data = array())
  45. {
  46. // UUID
  47. if(!$this->getUuid())
  48. {
  49. $uuid = Uuid::uuid1();
  50. $this->setUuid($uuid->toString());
  51. }
  52. // Set some defaults
  53. $this->setCreated(new \DateTime());
  54. $this->setModified(new \DateTime());
  55. // Pre-set data
  56. foreach($data AS $k => $v)
  57. {
  58. // Valid?
  59. $methodName = 'set' . ucfirst($k);
  60. if(method_exists($this, $methodName))
  61. $this->$methodName($v);
  62. }
  63. }
  64. public function getId()
  65. {
  66. return $this->id;
  67. }
  68. public function setUuid($uuid)
  69. {
  70. $this->uuid = $uuid;
  71. return $this;
  72. }
  73. public function getUuid()
  74. {
  75. return $this->uuid;
  76. }
  77. public function setCreated(\DateTime $created)
  78. {
  79. $this->created = $created;
  80. }
  81. public function getCreated()
  82. {
  83. return $this->created;
  84. }
  85. public function setModified(\DateTime $modified)
  86. {
  87. $this->modified = $modified;
  88. }
  89. public function getModified()
  90. {
  91. return $this->modified;
  92. }
  93. public function getKey()
  94. {
  95. return $this->key;
  96. }
  97. public function setKey(string $key)
  98. {
  99. $this->key = $key;
  100. }
  101. public function getValue()
  102. {
  103. return $this->value;
  104. }
  105. public function setValue($value)
  106. {
  107. $this->value = $value;
  108. }
  109. }