src/Entity/ActionType.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ActionTypeRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Blameable\Traits\BlameableEntity;
  8. use Gedmo\Timestampable\Traits\TimestampableEntity;
  9. #[ORM\Entity(repositoryClassActionTypeRepository::class)]
  10. class ActionType extends BaseKeyValue
  11. {
  12.     use BlameableEntity//Hook blameable behaviour. Updates createdBy, updatedBy fields
  13.     use TimestampableEntity//Hook timestampable behaviour. Updates createdAt, updatedAt fields 
  14.     
  15.     const PRODUCT_VIEW 'PRODUCT_VIEW';
  16.     const PRODUCT_BOUGHT 'PRODUCT_BOUGHT';
  17.     #[ORM\Id]
  18.     #[ORM\GeneratedValue(strategy"IDENTITY")]
  19.     #[ORM\Column]
  20.     private ?int $id null;
  21.     #[ORM\OneToMany(mappedBy'actionType'targetEntityAction::class)]
  22.     private Collection $actions;
  23.     public function __construct()
  24.     {
  25.         $this->actions = new ArrayCollection();
  26.     }
  27.     public function getId(): ?int
  28.     {
  29.         return $this->id;
  30.     }
  31.     /**
  32.      * @return Collection<int, Action>
  33.      */
  34.     public function getActions(): Collection
  35.     {
  36.         return $this->actions;
  37.     }
  38.     public function addAction(Action $action): self
  39.     {
  40.         if (!$this->actions->contains($action)) {
  41.             $this->actions->add($action);
  42.             $action->setActionType($this);
  43.         }
  44.         return $this;
  45.     }
  46.     public function removeAction(Action $action): self
  47.     {
  48.         if ($this->actions->removeElement($action)) {
  49.             // set the owning side to null (unless already changed)
  50.             if ($action->getActionType() === $this) {
  51.                 $action->setActionType(null);
  52.             }
  53.         }
  54.         return $this;
  55.     }
  56. }