<?php
namespace App\Entity\Addon;
use App\Entity\Addon\Trait\TokenTrait;
use App\Entity\BaseEntity;
use App\Repository\Addon\ApiTokenRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ApiTokenRepository::class)]
class ApiToken extends BaseEntity
{
use TokenTrait;
#[ORM\OneToOne(mappedBy: 'apiToken', targetEntity: Installation::class)]
private ?Installation $installation = null;
public function getInstallation(): ?Installation
{
return $this->installation;
}
public function setInstallation(?Installation $installation): self
{
// unset the owning side of the relation if necessary
if ($installation === null && $this->installation !== null) {
$this->installation->setApiToken(null);
}
// set the owning side of the relation if necessary
if ($installation !== null && $installation->getApiToken() !== $this) {
$installation->setApiToken($this);
}
$this->installation = $installation;
return $this;
}
}