<?php
declare(strict_types=1);
namespace App\Infrastructure\Doctrine\Entity;
use App\Domain\Common\Entity\IzOrderClient;
use App\Domain\Common\Entity\UserAgent;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Infrastructure\Doctrine\Repository\DoctrineUserAgentRepository")
*/
class DoctrineUserAgent extends DoctrineBaseUser implements UserAgent
{
/**
* @ORM\Column(type="string", length=191)
*/
private string $name = '';
/**
* @ORM\Column(type="string", length=191)
*/
private string $country = '';
/**
* @var Collection<int, IzOrderClient>
*
* @ORM\OneToMany(targetEntity="App\Infrastructure\Doctrine\Entity\DoctrineIzOrderClient", mappedBy="agent")
*/
private iterable $clients;
public function __construct()
{
$this->clients = new ArrayCollection();
}
public function __toString(): string
{
return $this->getCodeClient().' - '.$this->getName();
}
public function getName(): string
{
return $this->name;
}
public function setName(string $name): void
{
$this->name = $name;
}
public function getCountry(): string
{
return $this->country;
}
public function setCountry(string $country): void
{
$this->country = $country;
}
/**
* {@inheritDoc}
*/
public function getClients(): iterable
{
return $this->clients;
}
public function addClient(IzOrderClient $client): void
{
if (!$this->clients->contains($client)) {
$this->clients[] = $client;
$client->setAgent($this);
}
}
public function removeClient(IzOrderClient $client): void
{
// set the owning side to null (unless already changed)
if ($this->clients->removeElement($client) && $client->getAgent() === $this) {
$client->setAgent(null);
}
}
public function getRoles(): array
{
return ['ROLE_AGENT'];
}
}