src/JanusHercules/FeedManagementChangeLog/Domain/Entity/FeedManagementChangeLogEntry.php line 15

Open in your IDE?
  1. <?php
  2. namespace JanusHercules\FeedManagementChangeLog\Domain\Entity;
  3. use App\Utility\DatabaseIdGenerator;
  4. use App\Utility\DateTimeUtility;
  5. use DateTime;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Exception;
  9. use JanusHercules\FeedManagementChangeLog\Infrastructure\Enum\FeedManagementChangeLogEntryType;
  10. #[ORM\Entity]
  11. #[ORM\Table(name: 'feed_management_change_log_entries')]
  12. class FeedManagementChangeLogEntry
  13. {
  14. /**
  15. * @throws Exception
  16. */
  17. public function __construct(
  18. string $creatingUserEmail,
  19. FeedManagementChangeLogEntryType $type,
  20. ?string $customerInternalId,
  21. ?string $oldValue,
  22. ?string $newValue
  23. ) {
  24. $this->creatingUserEmail = $creatingUserEmail;
  25. $this->customerInternalId = $customerInternalId;
  26. $this->type = $type;
  27. $this->oldValue = $oldValue;
  28. $this->newValue = $newValue;
  29. $this->createdAt = DateTimeUtility::createDateTimeCet();
  30. }
  31. #[ORM\Id]
  32. #[ORM\GeneratedValue(strategy: 'CUSTOM')]
  33. #[ORM\CustomIdGenerator(class: DatabaseIdGenerator::class)]
  34. #[ORM\Column(
  35. type : Types::GUID,
  36. unique: true
  37. )]
  38. private ?string $id = null;
  39. public function getId(): ?string
  40. {
  41. return $this->id;
  42. }
  43. #[ORM\Column(
  44. type : Types::STRING,
  45. nullable: false
  46. )]
  47. private string $creatingUserEmail;
  48. public function getCreatingUserEmail(): string
  49. {
  50. return $this->creatingUserEmail;
  51. }
  52. #[ORM\Column(
  53. type : Types::STRING,
  54. nullable: true
  55. )]
  56. private ?string $customerInternalId;
  57. public function getCustomerInternalId(): ?string
  58. {
  59. return $this->customerInternalId;
  60. }
  61. #[ORM\Column(
  62. type : Types::STRING,
  63. nullable: false,
  64. enumType: FeedManagementChangeLogEntryType::class
  65. )]
  66. private FeedManagementChangeLogEntryType $type;
  67. public function getType(): FeedManagementChangeLogEntryType
  68. {
  69. return $this->type;
  70. }
  71. #[ORM\Column(
  72. type : Types::STRING,
  73. nullable: true
  74. )]
  75. private ?string $oldValue;
  76. public function getOldValue(): ?string
  77. {
  78. return $this->oldValue;
  79. }
  80. #[ORM\Column(
  81. type : Types::STRING,
  82. nullable: true
  83. )]
  84. private ?string $newValue;
  85. public function getNewValue(): ?string
  86. {
  87. return $this->newValue;
  88. }
  89. #[ORM\Column(
  90. type : Types::DATETIME_MUTABLE,
  91. nullable: false
  92. )]
  93. private DateTime $createdAt;
  94. public function setCreatedAt(DateTime $createdAt): void
  95. {
  96. $this->createdAt = $createdAt;
  97. }
  98. public function getCreatedAt(): DateTime
  99. {
  100. return $this->createdAt;
  101. }
  102. }