src/Entity/AbstractCollaborator.php line 95

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Reference\PersonTypeReference;
  4. use App\Traits\TimeStampTrait;
  5. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  6. use Symfony\Component\Security\Core\User\UserInterface;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. use Symfony\Component\Serializer\Annotation\SerializedName;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use ApiPlatform\Core\Annotation\ApiResource;
  11. use ApiPlatform\Core\Annotation\ApiFilter;
  12. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  13. use App\ApiPlatform\Filter\RoleSearchFilter;
  14. use App\Entity\Reference\ReferenceCollaboratorStatus;
  15. use App\Entity\Reference\ReferencePersonMaritalStatus;
  16. use App\Repository\AbstractCollaboratorRepository;
  17. use App\Filter\FullNameSearchFilter;
  18. use DateTimeInterface;
  19. use Doctrine\ORM\Mapping as ORM;
  20. use App\ApiPlatform\Filter\CurrentUserFilter;
  21. use App\Filter\DirectoryListFilter;
  22. use App\Controller\Admin\UpdatePasswordController;
  23. use App\Filter\CustomMainPhoneFilter;
  24. use App\Filter\ReferenceStateFilter;
  25. /**
  26.  * @ApiResource(
  27.  *     security= "is_granted('ROLE_AGENT') or is_granted('ROLE_MANAGER')",
  28.  *     normalizationContext={"groups"={"abstract-collaborator:read","directory:collaborator:search"},
  29.  *     "swagger_definition_name"="Read"},
  30.  *     denormalizationContext={"groups"={"abstract-collaborator:write"}, "swagger_definition_name"="Write",
  31.  *     "skip_null_values" = true},
  32.  *     itemOperations={
  33.  *          "get" = {
  34.  *                  "path"="/collaborators/{id}"
  35.  *              },
  36.  *          "put" = {
  37.  *                  "denormalization_context"={"groups"={"abstract-collaborator:put"},"skip_null_values" = true},
  38.  *                  "security" = "is_granted('PROFILE_UPDATE', object)" ,
  39.  *              },
  40.  *          "update_password" = {
  41.  *              "method"="PATCH",
  42.  *              "access_control"="is_granted('ROLE_ADMIN')",
  43.  *              "path"="/collaborators/{id}/update_password",
  44.  *              "controller"=UpdatePasswordController::class,
  45.  *              "openapi_context"={
  46.  *                  "summary"="Update password",
  47.  *                  "description"="Update password of users by Admin"
  48.  *              }
  49.  *          }
  50.  *     },
  51.  *     collectionOperations={
  52.  *           "get" = {
  53.  *                  "path"="/collaborators"
  54.  *              },
  55.  *     },
  56.  *     attributes={
  57.  *          "pagination_items_per_page"=10,
  58.  *          "formats"={"jsonld", "json", "html", "jsonhal", "csv"={"text/csv"} }
  59.  *     }
  60.  * )
  61.  *
  62.  * @ApiFilter(CurrentUserFilter::class)
  63.  * @ApiFilter(SearchFilter::class, properties={
  64.  *     "id": "exact",
  65.  *     "firstName": "ipartial",
  66.  *     "lastName": "ipartial",
  67.  *     "email": "partial",
  68.  *     "professionalEmail": "partial",
  69.  *     "address.city.name":"ipartial",
  70.  *     "referenceStatus": "exact"
  71.  * })
  72.  *
  73.  * @ApiFilter(CustomMainPhoneFilter::class, properties={"mainPhone"})
  74.  * @ApiFilter(FullNameSearchFilter::class)
  75.  * @ApiFilter(DirectoryListFilter::class, properties={"isDirectory"})
  76.  * @ApiFilter(ReferenceStateFilter::class, properties={"referenceState"})
  77.  * @ORM\InheritanceType("JOINED")
  78.  * @ORM\DiscriminatorColumn(name="type", type="string", length=12)
  79.  * @ORM\DiscriminatorMap({
  80.  *     "agent"="Agent",
  81.  *     "manager" = "Manager",
  82.  *     "managerBack" = "ManagerBackOffice",
  83.  *     "managerIt" = "ManagerIt"
  84.  * })
  85.  *
  86.  * @ORM\Entity(repositoryClass=AbstractCollaboratorRepository::class)
  87.  * @ORM\Table(indexes={@ORM\Index(name="abstract_collaborator_search_idx", columns={"first_name","last_name",
  88.  *            "email","main_phone"})})
  89.  * @ORM\HasLifecycleCallbacks()
  90.  *
  91.  */
  92. abstract class AbstractCollaborator implements UserInterfacePasswordAuthenticatedUserInterface
  93. {
  94.     use TimeStampTrait;
  95.     public const ROLE_AGENT 'ROLE_AGENT';
  96.     public const ROLE_MANAGER 'ROLE_MANAGER';
  97.     public const ROLE_ADMIN 'ROLE_ADMIN';
  98.     public const ROLE_MANAGER_IT 'ROLE_IT';
  99.     public const ROLE_MANAGER_BACK_OFFICE 'ROLE_BACK';
  100.     public const ROLE_CONSTELLATION_HEAD 'ROLE_CONSTELLATION_HEAD';
  101.     public const ROLE_BUSINESS_INDICATION 'ROLE_BUSINESS_INDICATION';
  102.     public const ROLE_PUBLIC_ACCESS 'ROLE_PUBLIC_ACCESS';
  103.     public const ALL_ROLES = [
  104.         self::ROLE_AGENT,
  105.         self::ROLE_MANAGER,
  106.         self::ROLE_ADMIN,
  107.         self::ROLE_MANAGER_IT,
  108.         self::ROLE_MANAGER_BACK_OFFICE,
  109.         self::ROLE_CONSTELLATION_HEAD,
  110.         self::ROLE_BUSINESS_INDICATION,
  111.     ];
  112.     /**
  113.      * @ORM\Id
  114.      * @ORM\GeneratedValue
  115.      * @ORM\Column(type="integer")
  116.      *
  117.      * @Groups({
  118.      *   "abstract-collaborator:read",
  119.      *   "directory:collaborator:search",
  120.      *   "candidate:read",
  121.      *   "prescriber:read",
  122.      *   "contact:read",
  123.      *   "genealogy:read",
  124.      *   "mandate:read",
  125.      *   "property:read",
  126.      *   "agent:read",
  127.      *   "transaction-item:read",
  128.      *   "milkiya:read",
  129.      *   "business-indication:item:read",
  130.      *   "business-indication:collection:read",
  131.      *   "manager:read",
  132.      *   "agent:light"
  133.      * })
  134.      */
  135.     protected ?int $id;
  136.     /**
  137.      * @ORM\Column(type="string", length=255)
  138.      *
  139.      * @Assert\Sequentially({
  140.      *      @Assert\NotBlank(),
  141.      *      @Assert\Type("string"),
  142.      *      @Assert\Length(
  143.      *          min = 2,
  144.      *          max = 253,
  145.      *          minMessage = "First Name must be at least {{ limit }} characters long",
  146.      *          maxMessage = "First Name cannot be longer than {{ limit }} characters"
  147.      *      ),
  148.      * })
  149.      *
  150.      * @Groups({
  151.      *   "abstract-collaborator:read",
  152.      *   "directory:collaborator:search",
  153.      *   "candidate:read",
  154.      *   "contact:read",
  155.      *   "prescriber:read",
  156.      *   "genealogy:read",
  157.      *   "mandate:read",
  158.      *   "property:read",
  159.      *   "agent:read","siege:put","siege:write",
  160.      *   "transaction-item:read",
  161.      *   "transaction:collection:read",
  162.      *   "business-indication:item:read",
  163.      *   "business-indication:collection:read",
  164.      *   "manager:read",
  165.      *   "milkiya:read",
  166.      *   "agent:light"
  167.      * })
  168.      *
  169.      */
  170.     protected ?string $firstName;
  171.     /**
  172.      * @ORM\Column(type="string", length=255)
  173.      *
  174.      * @Assert\Sequentially({
  175.      *      @Assert\NotBlank(),
  176.      *      @Assert\Type("string"),
  177.      *      @Assert\Length(
  178.      *          min = 2,
  179.      *          max = 253,
  180.      *          minMessage = "Last Name must be at least {{ limit }} characters long",
  181.      *          maxMessage = "Last Name cannot be longer than {{ limit }} characters"
  182.      *      ),
  183.      * })
  184.      *
  185.      * @Groups({
  186.      *   "abstract-collaborator:read",
  187.      *   "directory:collaborator:search",
  188.      *   "candidate:read",
  189.      *   "contact:read",
  190.      *   "prescriber:read",
  191.      *   "genealogy:read",
  192.      *   "mandate:read",
  193.      *   "property:read",
  194.      *   "agent:read","siege:put","siege:write",
  195.      *   "transaction-item:read",
  196.      *   "transaction:collection:read",
  197.      *   "business-indication:item:read",
  198.      *   "business-indication:collection:read",
  199.      *   "manager:read",
  200.      *   "milkiya:read",
  201.      *   "agent:light"
  202.      * })
  203.      */
  204.     protected ?string $lastName;
  205.     /**
  206.      * @ORM\Column(type="string", length=255)
  207.      *
  208.      * @Assert\Sequentially({
  209.      *      @Assert\NotBlank(),
  210.      *      @Assert\Email(),
  211.      *      @Assert\Length(
  212.      *          min = 2,
  213.      *          max = 253,
  214.      *          minMessage = "Email must be at least {{ limit }} characters long",
  215.      *          maxMessage = "Email cannot be longer than {{ limit }} characters"
  216.      *      ),
  217.      * })
  218.      *
  219.      * @Groups({
  220.      *   "abstract-collaborator:read",
  221.      *   "directory:collaborator:search",
  222.      *   "candidate:read",
  223.      *   "contact:read",
  224.      *   "mandate:read",
  225.      *   "property:read",
  226.      *   "agent:read","siege:put","siege:write",
  227.      *   "transaction-item:read",
  228.      *   "business-indication:item:read",
  229.      * })
  230.      */
  231.     protected ?string $email;
  232.     /**
  233.      * @ORM\Column(type="string", length=255)
  234.      *
  235.      * @Assert\Sequentially({
  236.      *      @Assert\NotBlank(),
  237.      *      @Assert\Email(),
  238.      *      @Assert\Length(
  239.      *          min = 2,
  240.      *          max = 253,
  241.      *          minMessage = "Professional Email must be at least {{ limit }} characters long",
  242.      *          maxMessage = "Professional Email cannot be longer than {{ limit }} characters"
  243.      *      ),
  244.      * })
  245.      *
  246.      * @Groups({
  247.      *   "directory:collaborator:search",
  248.      *   "abstract-collaborator:read",
  249.      *   "candidate:read",
  250.      *   "contact:read",
  251.      *   "mandate:read",
  252.      *   "property:read",
  253.      *   "agent:read","siege:put","siege:write",
  254.      *   "transaction-item:read",
  255.      *   "milkiya:read",
  256.      *   "agent:light"
  257.      * })
  258.      */
  259.     protected ?string $professionalEmail;
  260.     /**
  261.      * @ORM\Column(type="date", nullable=true)
  262.      * @Assert\LessThan("-18 years")
  263.      * @Groups({
  264.      *   "directory:collaborator:search",
  265.      *   "abstract-collaborator:read",
  266.      *   "candidate:read",
  267.      *   "contact:read",
  268.      *   "mandate:read:private",
  269.      *   "property:read",
  270.      *   "agent:read","siege:put","siege:write",
  271.      *   "business-indication:item:read",
  272.      * })
  273.      *
  274.      */
  275.     protected $birthDay;
  276.     /**
  277.      * @ORM\Column(type="string", length=255,nullable=true)
  278.      *
  279.      * @Groups({
  280.      *   "abstract-collaborator:read",
  281.      *   "directory:collaborator:search",
  282.      *   "candidate:read",
  283.      *   "contact:read",
  284.      *   "mandate:read",
  285.      *   "property:read",
  286.      *   "agent:read","siege:put","abstract-collaborator:put","siege:write",
  287.      * })
  288.      */
  289.     protected ?string $phone;
  290.     /**
  291.      * @ORM\Column(type="string", length=255)
  292.      *
  293.      * @Groups({
  294.      *   "abstract-collaborator:read",
  295.      *   "directory:collaborator:search",
  296.      *   "candidate:read",
  297.      *   "contact:read",
  298.      *   "mandate:read",
  299.      *   "property:read",
  300.      *   "agent:read","siege:put","abstract-collaborator:put","siege:write",
  301.      *   "recommandation:read",
  302.      *   "milkiya:read"
  303.      * })
  304.      */
  305.     protected ?string $mainPhone;
  306.     /**
  307.      * @ORM\OneToOne(targetEntity=Address::class, cascade={"persist", "remove"})
  308.      * @ORM\JoinColumn(nullable=false)
  309.      *
  310.      * @Groups({
  311.      *    "abstract-collaborator:read",
  312.      *    "directory:collaborator:search",
  313.      *    "candidate:read",
  314.      *    "contact:read",
  315.      *    "mandate:read:private",
  316.      *    "property:read",
  317.      *    "agent:read","siege:put","abstract-collaborator:put","siege:write"
  318.      * })
  319.      */
  320.     protected ?Address $address;
  321.     /**
  322.      * @ORM\ManyToOne(targetEntity=Gender::class, inversedBy="abstractPeople")
  323.      * @ORM\JoinColumn(nullable=false)
  324.      *
  325.      * @Groups({
  326.      *   "directory:collaborator:search",
  327.      *   "abstract-collaborator:read",
  328.      *   "candidate:read",
  329.      *   "contact:read",
  330.      *   "mandate:read",
  331.      *   "property:read",
  332.      *   "agent:read","siege:put","siege:write",
  333.      *   "milkiya:read"
  334.      * })
  335.      */
  336.     protected ?Gender $gender;
  337.     /**
  338.      * @ORM\Column(type="json")
  339.      * @ApiFilter(RoleSearchFilter::class)
  340.      * @Groups({
  341.      *   "directory:collaborator:search",
  342.      *   "abstract-collaborator:read",
  343.      *   "agent:read",
  344.      *   "siege:write",
  345.      * })
  346.      */
  347.     protected array $roles = [];
  348.     /**
  349.      * @var string The hashed password
  350.      * @ORM\Column(type="string")
  351.      * @Groups({
  352.     * "siege:write",
  353.      * })
  354.      *
  355.      */
  356.     protected string $password;
  357.     /**
  358.      *
  359.      */
  360.     protected ?string $plainPassword;
  361.     /**
  362.      * @ORM\ManyToOne(targetEntity=ReferenceCollaboratorStatus::class, inversedBy="collaborators")
  363.      * @ORM\JoinColumn(nullable=true)
  364.      *
  365.      * @Groups({
  366.      *   "directory:collaborator:search",
  367.      *   "abstract-colloborator:read",
  368.      *   "agent:read","siege:put",
  369.      * })
  370.      */
  371.     private ?ReferenceCollaboratorStatus $referenceStatus;
  372.     /**
  373.      * @ORM\ManyToOne(targetEntity=ReferencePersonMaritalStatus::class)
  374.      * @ORM\JoinColumn(nullable=true)
  375.      *
  376.      * @Groups({
  377.      *   "agent:read","agent:put","siege:put",
  378.      *   "directory:collaborator:search",
  379.      *   "abstract-colloborator:read"
  380.      * })
  381.      *
  382.      */
  383.     private ?ReferencePersonMaritalStatus $referenceMaritalStatus;
  384.     /**
  385.      * @ORM\OneToOne(targetEntity=Avatar::class, mappedBy="collaborator", cascade={"persist", "remove"})
  386.      *
  387.      *  @Groups({
  388.      *   "directory:collaborator:search",
  389.      *   "abstract-colloborator:read",
  390.      *   "agent:read","siege:put",
  391.      *   "milkiya:read"
  392.      * })
  393.      */
  394.     private ?Avatar $avatar;
  395.     /**
  396.      * @ORM\Column(type="datetime", nullable=true)
  397.      */
  398.     private $lastConnection;
  399.     /**
  400.      * @ORM\OneToOne(targetEntity=Cgu::class, mappedBy="collaborator", cascade={"persist", "remove"})
  401.      * @Groups({
  402.      *   "directory:collaborator:search",
  403.      *   "abstract-collaborator:read",
  404.      *   "agent:read",
  405.      * })
  406.      */
  407.     private $cgu;
  408.     /**
  409.      * @ORM\Column(type="string", length=255, nullable=true)
  410.      *
  411.      * @Groups({
  412.      *   "directory:collaborator:search",
  413.      *   "siege:put","siege:write",
  414.      *   "agent:read",
  415.      *   "siege:write"
  416.      * })
  417.      */
  418.     private ?string $personType null;
  419.     public function __construct()
  420.     {
  421.     }
  422.     public function getId(): ?int
  423.     {
  424.         return $this->id;
  425.     }
  426.     public function getFirstName(): ?string
  427.     {
  428.         return $this->firstName;
  429.     }
  430.     public function setFirstName(string $firstName): self
  431.     {
  432.         $this->firstName $firstName;
  433.         return $this;
  434.     }
  435.     public function getLastName(): ?string
  436.     {
  437.         return $this->lastName;
  438.     }
  439.     public function setLastName(string $lastName): self
  440.     {
  441.         $this->lastName $lastName;
  442.         return $this;
  443.     }
  444.     public function getBirthDay(): ?DateTimeInterface
  445.     {
  446.         return $this->birthDay;
  447.     }
  448.     public function setBirthDay(?DateTimeInterface $birthDay): self
  449.     {
  450.         $this->birthDay $birthDay;
  451.         return $this;
  452.     }
  453.     public function getPhone(): ?string
  454.     {
  455.         return $this->phone;
  456.     }
  457.     public function setPhone(?string $phone): self
  458.     {
  459.         $this->phone $phone;
  460.         return $this;
  461.     }
  462.     public function getMainPhone(): ?string
  463.     {
  464.         return $this->mainPhone;
  465.     }
  466.     public function setMainPhone(string $mainPhone): self
  467.     {
  468.         $this->mainPhone $mainPhone;
  469.         return $this;
  470.     }
  471.     public function getEmail(): ?string
  472.     {
  473.         return $this->email;
  474.     }
  475.     /**
  476.      * @param string $email
  477.      *
  478.      * @return $this
  479.      */
  480.     public function setEmail(string $email): self
  481.     {
  482.         $this->email $email;
  483.         return $this;
  484.     }
  485.     public function getAddress(): ?Address
  486.     {
  487.         return $this->address;
  488.     }
  489.     public function setAddress(Address $address): self
  490.     {
  491.         $this->address $address;
  492.         return $this;
  493.     }
  494.     public function getGender(): ?Gender
  495.     {
  496.         return $this->gender;
  497.     }
  498.     public function setGender(?Gender $gender): self
  499.     {
  500.         $this->gender $gender;
  501.         return $this;
  502.     }
  503.     /**
  504.      * A visual identifier that represents this user.
  505.      * @see UserInterface
  506.      */
  507.     public function getUserIdentifier(): string
  508.     {
  509.         return (string) $this->professionalEmail;
  510.     }
  511.     /**
  512.      *
  513.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  514.      */
  515.     public function getUsername(): string
  516.     {
  517.         return (string) $this->professionalEmail;
  518.     }
  519.     /**
  520.      * @see UserInterface
  521.      */
  522.     public function getRoles(): array
  523.     {
  524.         $roles $this->roles;
  525.         // guarantee every user at least has ROLE_USER
  526.         // $roles[] = 'ROLE_USER';
  527.         return array_unique($roles);
  528.     }
  529.     public function setRoles(array $roles): self
  530.     {
  531.         $this->roles $roles;
  532.         return $this;
  533.     }
  534.     /**
  535.      * @see PasswordAuthenticatedUserInterface
  536.      */
  537.     public function getPassword(): string
  538.     {
  539.         return $this->password;
  540.     }
  541.     /**
  542.      * @param string $password
  543.      * @return $this
  544.      */
  545.     public function setPassword(string $password): self
  546.     {
  547.         $this->password $password;
  548.         return $this;
  549.     }
  550.     /**
  551.      * Returning a salt is only needed, if you are not using a modern
  552.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  553.      *
  554.      * @see UserInterface
  555.      */
  556.     public function getSalt(): ?string
  557.     {
  558.         return null;
  559.     }
  560.     /**
  561.      * @see UserInterface
  562.      */
  563.     public function eraseCredentials()
  564.     {
  565.         $this->plainPassword null;
  566.     }
  567.     /**
  568.      * @return string|null
  569.      */
  570.     public function getPlainPassword(): ?string
  571.     {
  572.         return $this->plainPassword;
  573.     }
  574.     /**
  575.      * @param string $plainPassword
  576.      *
  577.      * @return $this
  578.      */
  579.     public function setPlainPassword(string $plainPassword): self
  580.     {
  581.         $this->plainPassword $plainPassword;
  582.         return $this;
  583.     }
  584.     public function getProfessionalEmail(): ?string
  585.     {
  586.         return $this->professionalEmail;
  587.     }
  588.     public function setProfessionalEmail(string $professionalEmail): self
  589.     {
  590.         $this->professionalEmail $professionalEmail;
  591.         return $this;
  592.     }
  593.     public function getReferenceStatus(): ?ReferenceCollaboratorStatus
  594.     {
  595.         return $this->referenceStatus;
  596.     }
  597.     public function setReferenceStatus(?ReferenceCollaboratorStatus $referenceStatus): self
  598.     {
  599.         $this->referenceStatus $referenceStatus;
  600.         return $this;
  601.     }
  602.     public function getReferenceMaritalStatus(): ?ReferencePersonMaritalStatus
  603.     {
  604.         return $this->referenceMaritalStatus;
  605.     }
  606.     public function setReferenceMaritalStatus(?ReferencePersonMaritalStatus $referenceMaritalStatus): self
  607.     {
  608.         $this->referenceMaritalStatus $referenceMaritalStatus;
  609.         return $this;
  610.     }
  611.     /**
  612.      * @param int|null $id
  613.      *
  614.      * @return $this
  615.      */
  616.     public function setId(?int $id): self
  617.     {
  618.         $this->id $id;
  619.         return $this;
  620.     }
  621.     public function getAvatar(): ?Avatar
  622.     {
  623.         return $this->avatar;
  624.     }
  625.     public function getFullPathAvatar(): ?string
  626.     {
  627.         return $this->avatar Avatar::AVATAR_PATH $this->avatar->getFilePath() : null;
  628.     }
  629.     public function setAvatar(?Avatar $avatar): self
  630.     {
  631.         // unset the owning side of the relation if necessary
  632.         if ($avatar === null && $this->avatar !== null) {
  633.             $this->avatar->setCollaborator(null);
  634.         }
  635.         // set the owning side of the relation if necessary
  636.         if ($avatar !== null && $avatar->getCollaborator() !== $this) {
  637.             $avatar->setCollaborator($this);
  638.         }
  639.         $this->avatar $avatar;
  640.         return $this;
  641.     }
  642.     /**
  643.      * @SerializedName("currency")
  644.      * @Groups({
  645.      *    "agent:read",
  646.      *    "abstract-collaborator:read",
  647.      * })
  648.      */
  649.     public function getCurrency(): ?string
  650.     {
  651.         $country $this->getAddress()->getCity()->getCountry();
  652.         return $country->getCurrency() ?
  653.             $country->getCurrency()->getSymbol() :
  654.             Currency::DEFAULT_CURRENCY;
  655.     }
  656.     public function getLastConnection(): ?\DateTimeInterface
  657.     {
  658.         return $this->lastConnection;
  659.     }
  660.     public function setLastConnection(?\DateTimeInterface $lastConnection): self
  661.     {
  662.         $this->lastConnection $lastConnection;
  663.         return $this;
  664.     }
  665.     public function getCgu(): ?Cgu
  666.     {
  667.         return $this->cgu;
  668.     }
  669.     public function setCgu(Cgu $cgu): self
  670.     {
  671.         // set the owning side of the relation if necessary
  672.         if ($cgu->getCollaborator() !== $this) {
  673.             $cgu->setCollaborator($this);
  674.         }
  675.         $this->cgu $cgu;
  676.         return $this;
  677.     }
  678.     /**
  679.      * @return string
  680.      * @Groups({
  681.      *   "abstract-collaborator:read",
  682.      *   "directory:collaborator:search",
  683.      *   "candidate:read",
  684.      *   "contact:read",
  685.      *   "prescriber:read",
  686.      *   "genealogy:read",
  687.      *   "mandate:read",
  688.      *   "property:read",
  689.      *   "agent:read","siege:put","siege:write",
  690.      *   "transaction-item:read",
  691.      *   "transaction:collection:read",
  692.      *   "business-indication:item:read",
  693.      *   "business-indication:collection:read",
  694.      *   "manager:read",
  695.      *   "agent:light"
  696.      * })
  697.      */
  698.     public function getFullName(): string
  699.     {
  700.         if (null === $this->firstName && null === $this->lastName) {
  701.             return '';
  702.         }
  703.         return sprintf('%s %s'ucfirst($this->firstName), strtoupper($this->lastName));
  704.     }
  705.     public function getPersonType(): ?string
  706.     {
  707.         return $this->personType;
  708.     }
  709.     public function setPersonType(?string $personType): self
  710.     {
  711.         $this->personType $personType;
  712.         return $this;
  713.     }
  714.     /**
  715.      * @return PersonTypeReference|null
  716.      *
  717.      * @Groups({
  718.      *   "abstract-collaborator:read",
  719.      *   "directory:collaborator:search",
  720.      *   "candidate:read",
  721.      *   "contact:read",
  722.      *   "prescriber:read",
  723.      *   "genealogy:read",
  724.      *   "mandate:read",
  725.      *   "property:read",
  726.      *   "agent:read",
  727.      *   "transaction-item:read",
  728.      *   "transaction:collection:read",
  729.      *   "business-indication:item:read",
  730.      *   "business-indication:collection:read",
  731.      *   "manager:read"
  732.      * })
  733.      *
  734.      * @SerializedName("personType")
  735.      */
  736.     public function getReferencePersonType(): ?PersonTypeReference
  737.     {
  738.         if (null === $this->personType) {
  739.             return null;
  740.         }
  741.         return PersonTypeReference::createFromCode($this->getPersonType());
  742.     }
  743.     /**
  744.      * @SerializedName("isAgentConstellationHead")
  745.      *
  746.      * @Groups({"milkiya:read"})
  747.      *
  748.      * @return bool|null
  749.      *
  750.      */
  751.     public function isAgentConstellationHead(): ?bool
  752.     {
  753.         return in_array(self::ROLE_CONSTELLATION_HEAD$this->getRoles(), true);
  754.     }
  755. }