src/JanusHercules/IndeedCampaignManagement/Domain/Entity/FeedItemGenerationResult.php line 20

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace JanusHercules\IndeedCampaignManagement\Domain\Entity;
  4. use App\Utility\DatabaseIdGenerator;
  5. use App\Utility\DateTimeUtility;
  6. use DateTime;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Exception;
  10. use JanusHercules\IndeedCampaignManagement\Domain\Enum\EmplifyFeedItemCategoryVariant;
  11. use JanusHercules\IndeedCampaignManagement\Domain\Enum\FeedItemGenerationStatus;
  12. use JanusHercules\IndeedCampaignManagement\Domain\Enum\NotPublishableReason;
  13. #[ORM\Entity]
  14. #[ORM\Table(name: 'icm_feed_item_generation_results')]
  15. #[ORM\Index(columns: ['recurrent_job_id', 'published_at'], name: 'recurrent_job_id_published_at_idx')]
  16. class FeedItemGenerationResult
  17. {
  18. /**
  19. * @throws Exception
  20. */
  21. public function __construct(
  22. FeedGenerationRun $feedGenerationRun,
  23. FeedItemGenerationStatus $status,
  24. ?string $campaignDefinitionId,
  25. ?string $contentSnapshotId,
  26. ?string $publishedContentSnapshotId,
  27. ?string $recurrentJobId,
  28. ?bool $canBePublished,
  29. ?NotPublishableReason $notPublishableReason,
  30. ?EmplifyFeedItemCategoryVariant $categoryVariant,
  31. ?string $errorMessage = null,
  32. ?string $movedToCampaignId = null,
  33. ?string $movedToCampaignName = null
  34. ) {
  35. $this->feedGenerationRun = $feedGenerationRun;
  36. $this->status = $status;
  37. $this->publishing_plan_entry_campaign_definition_id = $campaignDefinitionId;
  38. $this->publishing_plan_entry_content_snapshot_id = $contentSnapshotId;
  39. $this->publishing_plan_entry_published_content_snapshot_id = $publishedContentSnapshotId;
  40. $this->recurrentJobId = $recurrentJobId;
  41. $this->publishing_plan_entry_can_be_published = $canBePublished;
  42. $this->publishing_plan_entry_not_publishable_reason = $notPublishableReason;
  43. $this->publishing_plan_entry_emplify_feed_item_category_variant = $categoryVariant;
  44. $this->errorMessage = $errorMessage;
  45. $this->publishedAt = DateTimeUtility::createDateTimeUtc();
  46. $this->publishingPlanEntryMovedToCampaignId = $movedToCampaignId;
  47. $this->publishingPlanEntryMovedToCampaignName = $movedToCampaignName;
  48. }
  49. #[ORM\Id]
  50. #[ORM\GeneratedValue(strategy: 'CUSTOM')]
  51. #[ORM\CustomIdGenerator(class: DatabaseIdGenerator::class)]
  52. #[ORM\Column(type: Types::GUID, unique: true)]
  53. private ?string $id = null;
  54. public function getId(): ?string
  55. {
  56. return $this->id;
  57. }
  58. #[ORM\ManyToOne(targetEntity: CampaignItem::class, inversedBy: 'feedItemGenerationResults')]
  59. #[ORM\JoinColumn(name: 'icm_campaign_items_id', referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  60. private ?CampaignItem $campaignItem = null;
  61. public function getCampaignItem(): ?CampaignItem
  62. {
  63. return $this->campaignItem;
  64. }
  65. public function setCampaignItem(?CampaignItem $campaignItem): void
  66. {
  67. $this->campaignItem = $campaignItem;
  68. }
  69. #[ORM\ManyToOne(targetEntity: FeedGenerationRun::class)]
  70. #[ORM\JoinColumn(name: 'icm_feed_generation_runs_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')]
  71. private FeedGenerationRun $feedGenerationRun;
  72. public function getFeedGenerationRun(): FeedGenerationRun
  73. {
  74. return $this->feedGenerationRun;
  75. }
  76. #[ORM\Column(type: Types::STRING, enumType: FeedItemGenerationStatus::class)]
  77. private FeedItemGenerationStatus $status;
  78. public function getStatus(): FeedItemGenerationStatus
  79. {
  80. return $this->status;
  81. }
  82. #[ORM\Column(name: 'error_message', type: Types::TEXT, nullable: true)]
  83. private ?string $errorMessage;
  84. public function getErrorMessage(): ?string
  85. {
  86. return $this->errorMessage;
  87. }
  88. #[ORM\Column(name: 'published_at', type: Types::DATETIME_MUTABLE)]
  89. private DateTime $publishedAt;
  90. public function getPublishedAt(): DateTime
  91. {
  92. return $this->publishedAt;
  93. }
  94. #[ORM\Column(name: 'publishing_plan_entry_campaign_definition_id', type: Types::GUID, nullable: true)]
  95. private ?string $publishing_plan_entry_campaign_definition_id;
  96. public function getPublishingPlanEntryCampaignDefinitionId(): ?string
  97. {
  98. return $this->publishing_plan_entry_campaign_definition_id;
  99. }
  100. #[ORM\Column(name: 'publishing_plan_entry_content_snapshot_id', type: Types::GUID, nullable: true)]
  101. private ?string $publishing_plan_entry_content_snapshot_id;
  102. public function getPublishingPlanEntryContentSnapshotId(): ?string
  103. {
  104. return $this->publishing_plan_entry_content_snapshot_id;
  105. }
  106. #[ORM\Column(name: 'publishing_plan_entry_published_content_snapshot_id', type: Types::GUID, nullable: true)]
  107. private ?string $publishing_plan_entry_published_content_snapshot_id;
  108. public function getPublishingPlanEntryPublishedContentSnapshotId(): ?string
  109. {
  110. return $this->publishing_plan_entry_published_content_snapshot_id;
  111. }
  112. #[ORM\Column(name: 'publishing_plan_entry_can_be_published', type: Types::BOOLEAN, nullable: true)]
  113. private ?bool $publishing_plan_entry_can_be_published;
  114. public function getPublishingPlanEntryCanBePublished(): ?bool
  115. {
  116. return $this->publishing_plan_entry_can_be_published;
  117. }
  118. #[ORM\Column(name: 'publishing_plan_entry_not_publishable_reason', type: Types::STRING, nullable: true, enumType: NotPublishableReason::class)]
  119. private ?NotPublishableReason $publishing_plan_entry_not_publishable_reason;
  120. public function getPublishingPlanEntryNotPublishableReason(): ?NotPublishableReason
  121. {
  122. return $this->publishing_plan_entry_not_publishable_reason;
  123. }
  124. #[ORM\Column(name: 'publishing_plan_entry_emplify_feed_item_category_variant', type: Types::STRING, nullable: true, enumType: EmplifyFeedItemCategoryVariant::class)]
  125. private ?EmplifyFeedItemCategoryVariant $publishing_plan_entry_emplify_feed_item_category_variant;
  126. public function getPublishingPlanEntryEmplifyFeedItemCategoryVariant(): ?EmplifyFeedItemCategoryVariant
  127. {
  128. return $this->publishing_plan_entry_emplify_feed_item_category_variant;
  129. }
  130. #[ORM\Column(name: 'recurrent_job_id', type: Types::GUID, nullable: true)]
  131. private ?string $recurrentJobId = null;
  132. public function getRecurrentJobId(): ?string
  133. {
  134. return $this->recurrentJobId;
  135. }
  136. public function setRecurrentJobId(?string $recurrentJobId): void
  137. {
  138. $this->recurrentJobId = $recurrentJobId;
  139. }
  140. #[ORM\Column(name: 'publishing_plan_entry_moved_to_campaign_id', type: Types::GUID, nullable: true)]
  141. private ?string $publishingPlanEntryMovedToCampaignId = null;
  142. public function getPublishingPlanEntryMovedToCampaignId(): ?string
  143. {
  144. return $this->publishingPlanEntryMovedToCampaignId;
  145. }
  146. public function setPublishingPlanEntryMovedToCampaignId(?string $publishingPlanEntryMovedToCampaignId): void
  147. {
  148. $this->publishingPlanEntryMovedToCampaignId = $publishingPlanEntryMovedToCampaignId;
  149. }
  150. #[ORM\Column(name: 'publishing_plan_entry_moved_to_campaign_name', type: Types::STRING, nullable: true)]
  151. private ?string $publishingPlanEntryMovedToCampaignName = null;
  152. public function getPublishingPlanEntryMovedToCampaignName(): ?string
  153. {
  154. return $this->publishingPlanEntryMovedToCampaignName;
  155. }
  156. public function setPublishingPlanEntryMovedToCampaignName(?string $publishingPlanEntryMovedToCampaignName): void
  157. {
  158. $this->publishingPlanEntryMovedToCampaignName = $publishingPlanEntryMovedToCampaignName;
  159. }
  160. }