src/Entity/QualificationLevel.php line 30

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\QualificationLevelRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use ApiPlatform\Core\Annotation\ApiResource;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. /**
  10.  * @ApiResource(
  11.  *     security= "is_granted('ROLE_AGENT') or is_granted('ROLE_MANAGER')",
  12.  *     normalizationContext={"groups"={"qualification-level:read"}, "swagger_definition_name"="Read"},
  13.  *     denormalizationContext={"groups"={"qualification-level:write"}, "swagger_definition_name"="Write"},
  14.  *     itemOperations={
  15.  *          "get"
  16.  *     },
  17.  *     collectionOperations={
  18.  *          "get",
  19.  *     },
  20.  *     attributes={
  21.  *          "pagination_items_per_page"=10,
  22.  *          "formats"={"jsonld", "json", "html", "jsonhal", "csv"={"text/csv"} }
  23.  *     }
  24.  * )
  25.  * @ORM\Entity(repositoryClass=QualificationLevelRepository::class)
  26.  */
  27. class QualificationLevel
  28. {
  29.     public const REFERENCE_MANAGER_STARTER_LABEL_COLOR 'none';
  30.     public const REFERENCE_MANAGER_STARTER_LABEL 'reference.qualification.STARTER';
  31.     public const REFERENCE_MANAGER_BRONZE_LABEL 'reference.qualification.BRONZE';
  32.     public const REFERENCE_MANAGER_SILVER_STATUS_LABEL 'reference.qualification.SILVER';
  33.     public const REFERENCE_MANAGER_GOLD_LABEL 'reference.qualification.GOLD';
  34.     public const REFERENCE_MANAGER_PLATINUM_LABEL 'reference.qualification.PLATINUM';
  35.     public const REFERENCE_MANAGER_DIAMOND_LABEL 'reference.qualification.DIAMOND';
  36.     public const REFERENCE_CODE_LEVEL_ZERO '0';
  37.     public const REFERENCE_CODE_LEVEL_ONE '1';
  38.     public const REFERENCE_CODE_LEVEL_TWO '2';
  39.     public const REFERENCE_CODE_LEVEL_THREE '3';
  40.     public const REFERENCE_CODE_LEVEL_FOUR '4';
  41.     public const REFERENCE_CODE_LEVEL_FIVE '5';
  42.     public const REFERENCE_STARTER_GOAL 0;
  43.     public const REFERENCE_BRONZE_GOAL 300000;
  44.     public const REFERENCE_SILVER_GOAL 250000;
  45.     public const REFERENCE_GOLD_GOAL 200000;
  46.     public const REFERENCE_PLATINUM_GOAL 150000;
  47.     public const REFERENCE_DIAMOND_GOAL 75000;
  48.     public const REFERENCE_STARTER_MAX_SPONSORSHIP_REQUEST = -1;
  49.     public const REFERENCE_BRONZE_MAX_SPONSORSHIP_REQUEST 5;
  50.     public const REFERENCE_SILVER_MAX_SPONSORSHIP_REQUEST 10;
  51.     public const REFERENCE_GOLD_MAX_SPONSORSHIP_REQUEST 15;
  52.     public const REFERENCE_PLATINUM_MAX_SPONSORSHIP_REQUEST 0;
  53.     public const REFERENCE_DIAMOND_MAX_SPONSORSHIP_REQUEST 0;
  54.     public const RECURRENCE_0 '0';
  55.     public const RECURRENCE_0_2 '0.2';
  56.     public const RECURRENCE_0_5 '0.5';
  57.     public const RECURRENCE_1_5 '1.5';
  58.     public const RECURRENCE_3_0 '3.0';
  59.     public const RECURRENCE_7_0 '7.0';
  60.     public const MAX_LEVEL '5';
  61.     public const ALL_QUALIFICATION_LABELS = [
  62.         self::REFERENCE_MANAGER_STARTER_LABEL,
  63.         self::REFERENCE_MANAGER_BRONZE_LABEL,
  64.         self::REFERENCE_MANAGER_SILVER_STATUS_LABEL,
  65.         self::REFERENCE_MANAGER_GOLD_LABEL,
  66.         self::REFERENCE_MANAGER_PLATINUM_LABEL,
  67.         self::REFERENCE_MANAGER_DIAMOND_LABEL,
  68.     ];
  69.     public const QUALIFICATION_LEVEL_COLORS = [
  70.         self::REFERENCE_MANAGER_STARTER_LABEL => self::REFERENCE_MANAGER_STARTER_LABEL_COLOR,
  71.         self::REFERENCE_MANAGER_BRONZE_LABEL => '#C1865D',
  72.         self::REFERENCE_MANAGER_SILVER_STATUS_LABEL => '#7c7373',
  73.         self::REFERENCE_MANAGER_GOLD_LABEL => '#eb9517',
  74.         self::REFERENCE_MANAGER_PLATINUM_LABEL => '#326B62',
  75.         self::REFERENCE_MANAGER_DIAMOND_LABEL => '#14b3d7',
  76.     ];
  77.     public const ALL_MAX_SPONSORSHIP_REQUEST = [
  78.         self::REFERENCE_STARTER_MAX_SPONSORSHIP_REQUEST,
  79.         self::REFERENCE_BRONZE_MAX_SPONSORSHIP_REQUEST,
  80.         self::REFERENCE_SILVER_MAX_SPONSORSHIP_REQUEST,
  81.         self::REFERENCE_GOLD_MAX_SPONSORSHIP_REQUEST,
  82.         self::REFERENCE_PLATINUM_MAX_SPONSORSHIP_REQUEST,
  83.         self::REFERENCE_DIAMOND_MAX_SPONSORSHIP_REQUEST
  84.     ];
  85.     public const ALL_LEVELS = [
  86.         self::REFERENCE_CODE_LEVEL_ZERO,
  87.         self::REFERENCE_CODE_LEVEL_ONE,
  88.         self::REFERENCE_CODE_LEVEL_TWO,
  89.         self::REFERENCE_CODE_LEVEL_THREE,
  90.         self::REFERENCE_CODE_LEVEL_FOUR,
  91.         self::REFERENCE_CODE_LEVEL_FIVE
  92.     ];
  93.     public const ALL_RECURENCES = [
  94.         self::RECURRENCE_0,
  95.         self::RECURRENCE_7_0,
  96.         self::RECURRENCE_3_0,
  97.         self::RECURRENCE_1_5,
  98.         self::RECURRENCE_0_5,
  99.         self::RECURRENCE_0_2,
  100.     ];
  101.     public const ALL_QUALIFICATION_GOALS = [
  102.         self::REFERENCE_STARTER_GOAL,
  103.         self::REFERENCE_BRONZE_GOAL,
  104.         self::REFERENCE_SILVER_GOAL,
  105.         self::REFERENCE_GOLD_GOAL,
  106.         self::REFERENCE_PLATINUM_GOAL,
  107.         self::REFERENCE_DIAMOND_GOAL
  108.     ];
  109.     /**
  110.      * @ORM\Id
  111.      * @ORM\GeneratedValue
  112.      * @ORM\Column(type="integer")
  113.      * @Groups({
  114.      *   "collaborator:read",
  115.      *   "genealogy:read",
  116.      *   "abstract-colloborator:read",
  117.      *   "directory:collaborator:search",
  118.      *   "qualification-level:read",
  119.      *   "agent:read"
  120.      * })
  121.      */
  122.     private $id;
  123.     /**
  124.      * @ORM\Column(type="integer")
  125.      * @Groups({
  126.      *   "collaborator:read",
  127.      *   "abstract-colloborator:read",
  128.      *   "directory:collaborator:search",
  129.      *   "agent:read",
  130.      *   "milkiya:read"
  131.      * })
  132.      */
  133.     private ?int $level;
  134.     /**
  135.      * @ORM\Column(type="float")
  136.      * @Groups({
  137.      *   "collaborator:read",
  138.      *   "abstract-colloborator:read",
  139.      *   "directory:collaborator:search",
  140.      *   "qualification-level:read",
  141.      *   "agent:read"
  142.      * })
  143.      */
  144.     private ?float $recurrence;
  145.     /**
  146.      * @ORM\Column(type="string", length=255)
  147.      * @Groups({
  148.      *     "collaborator:read",
  149.      *     "candidate:read",
  150.      *     "genealogy:read",
  151.      *     "abstract-colloborator:read",
  152.      *     "directory:collaborator:search",
  153.      *     "qualification-level:read",
  154.      *     "agent:read",
  155.      *     "milkiya:read"
  156.      * })
  157.      */
  158.     private ?string $label;
  159.     /**
  160.      * @ORM\OneToMany(targetEntity=Agent::class, mappedBy="qualificationLevel")
  161.      *
  162.      */
  163.     private $collaborators;
  164.     /**
  165.      * @ORM\Column(type="integer")
  166.      *
  167.      * @Groups({
  168.      *   "collaborator:read",
  169.      *   "abstract-colloborator:read",
  170.      *   "directory:collaborator:search",
  171.      *   "qualification-level:read",
  172.      *   "agent:read"
  173.      * })
  174.      */
  175.     private ?int $qualificationLevelGoal;
  176.     /**
  177.      * @ORM\Column(type="integer",nullable=true)
  178.      * @Groups({
  179.      *   "collaborator:read",
  180.      *   "abstract-colloborator:read",
  181.      *   "directory:collaborator:search",
  182.      *   "qualification-level:read",
  183.      *   "agent:read"
  184.      * })
  185.      */
  186.     private ?int $maxSponsorshipRequest;
  187.     public function __construct()
  188.     {
  189.         $this->collaborators = new ArrayCollection();
  190.     }
  191.     public function getId(): ?int
  192.     {
  193.         return $this->id;
  194.     }
  195.     public function getLevel(): ?int
  196.     {
  197.         return $this->level;
  198.     }
  199.     public function setLevel(int $level): self
  200.     {
  201.         $this->level $level;
  202.         return $this;
  203.     }
  204.     public function getRecurrence(): ?float
  205.     {
  206.         return $this->recurrence;
  207.     }
  208.     public function setRecurrence(float $recurrence): self
  209.     {
  210.         $this->recurrence $recurrence;
  211.         return $this;
  212.     }
  213.     public function getLabel(): ?string
  214.     {
  215.         return $this->label;
  216.     }
  217.     public function setLabel(string $label): self
  218.     {
  219.         $this->label $label;
  220.         return $this;
  221.     }
  222.     /**
  223.      * @return Collection|Agent[]
  224.      */
  225.     public function getCollaborators(): Collection
  226.     {
  227.         return $this->collaborators;
  228.     }
  229.     public function addCollaborator(Agent $collaborator): self
  230.     {
  231.         if (!$this->collaborators->contains($collaborator)) {
  232.             $this->collaborators[] = $collaborator;
  233.             $collaborator->setQualificationLevel($this);
  234.         }
  235.         return $this;
  236.     }
  237.     public function removeCollaborator(Agent $collaborator): self
  238.     {
  239.         // set the owning side to null (unless already changed)
  240.         if ($this->collaborators->removeElement($collaborator) && $collaborator->getQualificationLevel() === $this) {
  241.             $collaborator->setQualificationLevel(null);
  242.         }
  243.         return $this;
  244.     }
  245.     public function getQualificationLevelGoal(): ?int
  246.     {
  247.         return $this->qualificationLevelGoal;
  248.     }
  249.     public function setQualificationLevelGoal(int $qualificationLevelGoal): self
  250.     {
  251.         $this->qualificationLevelGoal $qualificationLevelGoal;
  252.         return $this;
  253.     }
  254.     public function getMaxSponsorshipRequest(): ?int
  255.     {
  256.         return $this->maxSponsorshipRequest;
  257.     }
  258.     public function setMaxSponsorshipRequest(?int $maxSponsorshipRequest): self
  259.     {
  260.         $this->maxSponsorshipRequest $maxSponsorshipRequest;
  261.         return $this;
  262.     }
  263. }