<?php
namespace App\Entity;
use App\Entity\Account\Advertiser;
use App\Repository\BulkQueueItemRepository;
use Carbon\CarbonImmutable;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Table(name: 'bulk_queue')]
#[ORM\Entity(repositoryClass: BulkQueueItemRepository::class)]
#[ORM\InheritanceType('SINGLE_TABLE')]
#[ORM\DiscriminatorColumn(name: 'entity_type', type: 'string', length: 12)]
#[ORM\DiscriminatorMap(['profile' => Profile\BulkQueueItem::class, 'saloon' => Saloon\BulkQueueItem::class, 'support_msg' => Support\BulkQueueItem::class
])]
abstract class BulkQueueItem
{
#[ORM\Id]
#[ORM\Column(name: 'id', type: 'smallint')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
protected int $id;
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', nullable: true)]
#[ORM\ManyToOne(targetEntity: Advertiser::class)]
protected ?Advertiser $owner;
#[ORM\Column(name: '`action`', type: 'string')]
protected string $action;
#[ORM\Column(name: 'entities', type: 'json')]
protected array $entities;
#[ORM\Column(name: 'date', type: 'datetime_immutable')]
protected $date;
#[ORM\Column(name: 'process_date', type: 'datetime_immutable', nullable: true)]
protected ?\DateTimeInterface $processDate = null;
#[ORM\Column(name: 'is_handled', type: 'boolean', options: ['default' => 0])]
protected bool $isHandled = false;
public function __construct(?Advertiser $owner, string $action, array $ids)
{
$this->owner = $owner;
$this->action = $action;
$this->entities = $ids;
$this->date = CarbonImmutable::now();
}
public function getId(): int
{
return $this->id;
}
public function getAction(): string
{
return $this->action;
}
public function getOwner(): ?Advertiser
{
return $this->owner;
}
public function getEntities(): array
{
return $this->entities;
}
public function isHandled(): bool
{
return $this->isHandled;
}
public function setIsHandled(bool $value): void
{
$this->isHandled = $value;
}
public function getProcessDate(): ?\DateTimeInterface
{
return $this->processDate;
}
public function setProcessDate(?\DateTimeInterface $processDate): void
{
$this->processDate = $processDate;
}
}