src/Entity/User.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Nucleos\UserBundle\Model\User as BaseUser;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. /**
  7.  * @ORM\Entity(
  8.  *     repositoryClass="App\Repository\UserRepository"
  9.  * )
  10.  * @ORM\Table(
  11.  *     name="user",
  12.  *     options={"collate"="utf8_swedish_ci"}
  13.  * )
  14.  * @ORM\HasLifecycleCallbacks
  15.  */
  16. class User extends BaseUser implements EntityInterface
  17. {
  18.     /**
  19.      * @ORM\Id
  20.      * @ORM\Column(
  21.      *     type="integer"
  22.      * )
  23.      * @ORM\GeneratedValue(
  24.      *     strategy="AUTO"
  25.      * )
  26.      *
  27.      * @var ?int
  28.      */
  29.     protected ?int $id null;
  30.     /**
  31.      * @ORM\Column(
  32.      *     name="first_name",
  33.      *     type="string",
  34.      *     length=100
  35.      * )
  36.      *
  37.      * @var string
  38.      */
  39.     protected string $firstName;
  40.     /**
  41.      * @ORM\Column(
  42.      *     name="last_name",
  43.      *     type="string",
  44.      *     length=100
  45.      * )
  46.      *
  47.      * @var string
  48.      */
  49.     protected string $lastName;
  50.     /**
  51.      * @ORM\Column(
  52.      *     name="offer_signature",
  53.      *     type="string",
  54.      *     length=500,
  55.      *     nullable=true
  56.      * )
  57.      *
  58.      * @var ?string
  59.      */
  60.     protected ?string $offerSignature null;
  61.     /**
  62.      * Plain password. Used for model validation. Must not be persisted.
  63.      *
  64.      * @Assert\Regex(
  65.      *     pattern="/^(?=.*[a-zåäö])(?=.*[A-ZÅÄÖ])(?=.*[^A-ZÅÄÖa-zåäö]).{8,}$/u",
  66.      *     message="user.password.invalid"
  67.      * )
  68.      *
  69.      * @var ?string
  70.      */
  71.     protected ?string $plainPassword null;
  72.     /**
  73.      * @ORM\Column(
  74.      *     name="sales_case_list_filter",
  75.      *     type="json",
  76.      *     nullable=true
  77.      * )
  78.      *
  79.      * @var ?array
  80.      */
  81.     protected ?array $salesCaseListFilter null;
  82.     /**
  83.      * @return string
  84.      */
  85.     public function __toString(): string
  86.     {
  87.         return $this->getName() . ' (' $this->getEmail() . ')';
  88.     }
  89.     /**
  90.      * @return ?int
  91.      */
  92.     public function getId(): ?int
  93.     {
  94.         return $this->id;
  95.     }
  96.     /**
  97.      * @return string
  98.      */
  99.     public function getFirstName(): string
  100.     {
  101.         return $this->firstName;
  102.     }
  103.     /**
  104.      * @return string
  105.      */
  106.     public function getLastName(): string
  107.     {
  108.         return $this->lastName;
  109.     }
  110.     /**
  111.      * Get full name of user
  112.      *
  113.      * @return string
  114.      */
  115.     public function getName(): string
  116.     {
  117.         return $this->firstName ' ' $this->lastName;
  118.     }
  119.     /**
  120.      * @return ?string
  121.      */
  122.     public function getOfferSignature(): ?string
  123.     {
  124.         return $this->offerSignature;
  125.     }
  126.     /**
  127.      * @return ?array
  128.      */
  129.     public function getSalesCaseListFilter(): ?array
  130.     {
  131.         return $this->salesCaseListFilter;
  132.     }
  133.     /**
  134.      * @param string $email
  135.      * @return void
  136.      */
  137.     public function setEmail(string $email): void
  138.     {
  139.         parent::setEmail($email);
  140.         $this->setUsername($email);
  141.     }
  142.     /**
  143.      * @param string $firstName
  144.      */
  145.     public function setFirstName(string $firstName): void
  146.     {
  147.         $this->firstName $firstName;
  148.     }
  149.     /**
  150.      * @param string $lastName
  151.      */
  152.     public function setLastName(string $lastName): void
  153.     {
  154.         $this->lastName $lastName;
  155.     }
  156.     /**
  157.      * @param ?string $offerSignature
  158.      */
  159.     public function setOfferSignature(?string $offerSignature): void
  160.     {
  161.         $this->offerSignature $offerSignature;
  162.     }
  163.     /**
  164.      * @param ?array $salesCaseListFilter
  165.      */
  166.     public function setSalesCaseListFilter(?array $salesCaseListFilter): void
  167.     {
  168.         $this->salesCaseListFilter $salesCaseListFilter;
  169.     }
  170.     /**
  171.      * @ORM\PrePersist
  172.      * @ORM\PreUpdate
  173.      */
  174.     public function updateUsername(): void
  175.     {
  176.         $this->username $this->email;
  177.     }
  178. }