src/Entity/Customer.php line 21

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity;
  4. use Symfony\Component\Security\Core\User\UserInterface;
  5. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use App\Repository\CustomerRepository;
  11. /**
  12.  * Customer
  13.  *
  14.  * @ORM\Table(name="customer")
  15.  * @ORM\Entity(repositoryClass=CustomerRepository::class)
  16.  */
  17. class Customer implements UserInterfacePasswordAuthenticatedUserInterface
  18. {
  19.     public const SERIALIZATION_GROUP_LISTING 'customer_listing';
  20.     /**
  21.      * @var int
  22.      *
  23.      * @ORM\Column(name="id", type="smallint", nullable=false)
  24.      * @ORM\Id
  25.      * @ORM\GeneratedValue(strategy="IDENTITY")
  26.      * @Groups({self::SERIALIZATION_GROUP_LISTING})
  27.      */
  28.     private $id;
  29.     /**
  30.      * @var string
  31.      *
  32.      * @ORM\Column(name="name", type="string", length=100, nullable=false)
  33.      * @Groups({self::SERIALIZATION_GROUP_LISTING})
  34.      */
  35.     private $name;
  36.     /**
  37.      * @var string|null
  38.      *
  39.      * @ORM\Column(name="contact_1", type="string", length=80, nullable=true, options={"default"="NULL"})
  40.      * @Groups({self::SERIALIZATION_GROUP_LISTING})
  41.      */
  42.     private $contact1 null;
  43.     /**
  44.      * @var string|null
  45.      *
  46.      * @ORM\Column(name="email_1", type="string", length=80, nullable=true, options={"default"="NULL"})
  47.      */
  48.     private $email1 null;
  49.     /**
  50.      * @var string|null
  51.      *
  52.      * @ORM\Column(name="phone_1", type="string", length=40, nullable=true, options={"default"="NULL"})
  53.      * @Groups({self::SERIALIZATION_GROUP_LISTING})
  54.      */
  55.     private $phone1 null;
  56.     /**
  57.      * @var string|null
  58.      *
  59.      * @ORM\Column(name="contact_2", type="string", length=80, nullable=true, options={"default"="NULL"})
  60.      * @Groups({self::SERIALIZATION_GROUP_LISTING})
  61.      */
  62.     private $contact2 null;
  63.     /**
  64.      * @var string|null
  65.      *
  66.      * @ORM\Column(name="email_2", type="string", length=80, nullable=true, options={"default"="NULL"})
  67.      */
  68.     private $email2 null;
  69.     /**
  70.      * @var string|null
  71.      *
  72.      * @ORM\Column(name="phone_2", type="string", length=40, nullable=true, options={"default"="NULL"})
  73.      * @Groups({self::SERIALIZATION_GROUP_LISTING})
  74.      */
  75.     private $phone2 null;
  76.     /**
  77.      * @var string|null
  78.      *
  79.      * @ORM\Column(name="logo", type="string", length=100, nullable=true, options={"default"="NULL"})
  80.      */
  81.     private $logo null;
  82.     /**
  83.      * @var string|null
  84.      *
  85.      * @ORM\Column(name="username", type="string", length=40, nullable=true, options={"default"="NULL"})
  86.      */
  87.     private $username null;
  88.     /**
  89.      * @var string|null
  90.      *
  91.      * @ORM\Column(name="password", type="string", length=250, nullable=true, options={"default"="NULL"})
  92.      */
  93.     private $password null;
  94.     /**
  95.      * @var string|null
  96.      *
  97.      * @ORM\Column(name="path", type="string", length=20, nullable=true, options={"default"="NULL"})
  98.      */
  99.     private $path null;
  100.     /**
  101.      * @var bool
  102.      *
  103.      * @ORM\Column(name="is_active", type="boolean", nullable=false)
  104.      */
  105.     private $isActive true;
  106.     /**
  107.      * @var Collection
  108.      * 
  109.      * @ORM\OneToMany(targetEntity=CustomerExcludeCsp::class, mappedBy="customer")
  110.      */
  111.     private $excludedCsps;
  112.     private $plainPassword;
  113.     /**
  114.      * Constructor
  115.      */
  116.     public function __construct()
  117.     {
  118.         $this->excludedCsps = new ArrayCollection();
  119.     }
  120.     public function getId(): ?int
  121.     {
  122.         return $this->id;
  123.     }
  124.     public function getName(): ?string
  125.     {
  126.         return $this->name;
  127.     }
  128.     public function setName(string $name): self
  129.     {
  130.         $this->name $name;
  131.         return $this;
  132.     }
  133.     public function getContact1(): ?string
  134.     {
  135.         return $this->contact1;
  136.     }
  137.     public function setContact1(?string $contact1): self
  138.     {
  139.         $this->contact1 $contact1;
  140.         return $this;
  141.     }
  142.     public function getEmail1(): ?string
  143.     {
  144.         return $this->email1;
  145.     }
  146.     public function setEmail1(?string $email1): self
  147.     {
  148.         $this->email1 $email1;
  149.         return $this;
  150.     }
  151.     public function getPhone1(): ?string
  152.     {
  153.         return $this->phone1;
  154.     }
  155.     public function setPhone1(?string $phone1): self
  156.     {
  157.         $this->phone1 $phone1;
  158.         return $this;
  159.     }
  160.     public function getContact2(): ?string
  161.     {
  162.         return $this->contact2;
  163.     }
  164.     public function setContact2(?string $contact2): self
  165.     {
  166.         $this->contact2 $contact2;
  167.         return $this;
  168.     }
  169.     public function getEmail2(): ?string
  170.     {
  171.         return $this->email2;
  172.     }
  173.     public function setEmail2(?string $email2): self
  174.     {
  175.         $this->email2 $email2;
  176.         return $this;
  177.     }
  178.     public function getPhone2(): ?string
  179.     {
  180.         return $this->phone2;
  181.     }
  182.     public function setPhone2(?string $phone2): self
  183.     {
  184.         $this->phone2 $phone2;
  185.         return $this;
  186.     }
  187.     public function getLogo(): ?string
  188.     {
  189.         return $this->logo;
  190.     }
  191.     public function setLogo(?string $logo): self
  192.     {
  193.         $this->logo $logo;
  194.         return $this;
  195.     }
  196.     public function getUsername(): ?string
  197.     {
  198.         return $this->username;
  199.     }
  200.     public function setUsername(?string $username): self
  201.     {
  202.         $this->username $username;
  203.         return $this;
  204.     }
  205.     public function getPassword(): ?string
  206.     {
  207.         return $this->password;
  208.     }
  209.     public function setPassword(?string $password): self
  210.     {
  211.         $this->password $password;
  212.         return $this;
  213.     }
  214.     public function getPath(): ?string
  215.     {
  216.         return $this->path;
  217.     }
  218.     public function setPath(?string $path): self
  219.     {
  220.         $this->path $path;
  221.         return $this;
  222.     }
  223.     public function isIsActive(): ?bool
  224.     {
  225.         return $this->isActive;
  226.     }
  227.     public function setIsActive(bool $isActive): self
  228.     {
  229.         $this->isActive $isActive;
  230.         return $this;
  231.     }
  232.     public function getPlainPassword(): ?string
  233.     {
  234.         return $this->plainPassword;
  235.     }
  236.     
  237.     public function setPlainPassword(?string $plainPassword): self
  238.     {
  239.         $this->plainPassword $plainPassword;
  240.     
  241.         return $this;
  242.     }
  243.     /**
  244.      * @see UserInterface
  245.      */
  246.     public function getUserIdentifier(): string
  247.     {
  248.         return (string) $this->username;
  249.     }
  250.     /**
  251.      * @see UserInterface
  252.      */
  253.     public function getRoles(): array
  254.     {
  255.         return ['ROLE_CUSTOMER'];
  256.     }
  257.     /**
  258.      * @see UserInterface
  259.      */
  260.     public function eraseCredentials()
  261.     {
  262.         // If you store any temporary, sensitive data on the user, clear it here
  263.         // $this->plainPassword = null;
  264.     }
  265.     /**
  266.      * @return Collection<int, CustomerExcludeCsp>
  267.      */
  268.     public function getExcludedCsps(): Collection
  269.     {
  270.         return $this->excludedCsps;
  271.     }
  272.     public function addExcludedCsp(CustomerExcludeCsp $excludedCsp): self
  273.     {
  274.         if (!$this->excludedCsps->contains($excludedCsp)) {
  275.             $this->excludedCsps[] = $excludedCsp;
  276.             $excludedCsp->setCustomer($this);
  277.         }
  278.         return $this;
  279.     }
  280.     public function removeExcludedCsp(CustomerExcludeCsp $excludedCsp): self
  281.     {
  282.         if ($this->excludedCsps->removeElement($excludedCsp)) {
  283.             // set the owning side to null (unless already changed)
  284.             if ($excludedCsp->getCustomer() === $this) {
  285.                 $excludedCsp->setCustomer(null);
  286.             }
  287.         }
  288.         return $this;
  289.     }
  290. }