src/Infrastructure/Doctrine/Entity/DoctrineUserAgent.php line 16

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Infrastructure\Doctrine\Entity;
  4. use App\Domain\Common\Entity\IzOrderClient;
  5. use App\Domain\Common\Entity\UserAgent;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. /**
  10.  * @ORM\Entity(repositoryClass="App\Infrastructure\Doctrine\Repository\DoctrineUserAgentRepository")
  11.  */
  12. class DoctrineUserAgent extends DoctrineBaseUser implements UserAgent
  13. {
  14.     /**
  15.      * @ORM\Column(type="string", length=191)
  16.      */
  17.     private string $name '';
  18.     /**
  19.      * @ORM\Column(type="string", length=191)
  20.      */
  21.     private string $country '';
  22.     /**
  23.      * @var Collection<int, IzOrderClient>
  24.      *
  25.      * @ORM\OneToMany(targetEntity="App\Infrastructure\Doctrine\Entity\DoctrineIzOrderClient", mappedBy="agent")
  26.      */
  27.     private iterable $clients;
  28.     public function __construct()
  29.     {
  30.         $this->clients = new ArrayCollection();
  31.     }
  32.     public function __toString(): string
  33.     {
  34.         return $this->getCodeClient().' - '.$this->getName();
  35.     }
  36.     public function getName(): string
  37.     {
  38.         return $this->name;
  39.     }
  40.     public function setName(string $name): void
  41.     {
  42.         $this->name $name;
  43.     }
  44.     public function getCountry(): string
  45.     {
  46.         return $this->country;
  47.     }
  48.     public function setCountry(string $country): void
  49.     {
  50.         $this->country $country;
  51.     }
  52.     /**
  53.      * {@inheritDoc}
  54.      */
  55.     public function getClients(): iterable
  56.     {
  57.         return $this->clients;
  58.     }
  59.     public function addClient(IzOrderClient $client): void
  60.     {
  61.         if (!$this->clients->contains($client)) {
  62.             $this->clients[] = $client;
  63.             $client->setAgent($this);
  64.         }
  65.     }
  66.     public function removeClient(IzOrderClient $client): void
  67.     {
  68.         // set the owning side to null (unless already changed)
  69.         if ($this->clients->removeElement($client) && $client->getAgent() === $this) {
  70.             $client->setAgent(null);
  71.         }
  72.     }
  73.     public function getRoles(): array
  74.     {
  75.         return ['ROLE_AGENT'];
  76.     }
  77. }