<?php
namespace App\Entity;
use App\Repository\ActionTypeRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Blameable\Traits\BlameableEntity;
use Gedmo\Timestampable\Traits\TimestampableEntity;
#[ORM\Entity(repositoryClass: ActionTypeRepository::class)]
class ActionType extends BaseKeyValue
{
use BlameableEntity; //Hook blameable behaviour. Updates createdBy, updatedBy fields
use TimestampableEntity; //Hook timestampable behaviour. Updates createdAt, updatedAt fields
const PRODUCT_VIEW = 'PRODUCT_VIEW';
const PRODUCT_BOUGHT = 'PRODUCT_BOUGHT';
#[ORM\Id]
#[ORM\GeneratedValue(strategy: "IDENTITY")]
#[ORM\Column]
private ?int $id = null;
#[ORM\OneToMany(mappedBy: 'actionType', targetEntity: Action::class)]
private Collection $actions;
public function __construct()
{
$this->actions = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
/**
* @return Collection<int, Action>
*/
public function getActions(): Collection
{
return $this->actions;
}
public function addAction(Action $action): self
{
if (!$this->actions->contains($action)) {
$this->actions->add($action);
$action->setActionType($this);
}
return $this;
}
public function removeAction(Action $action): self
{
if ($this->actions->removeElement($action)) {
// set the owning side to null (unless already changed)
if ($action->getActionType() === $this) {
$action->setActionType(null);
}
}
return $this;
}
}