src/Entity/Project.php line 36

  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use App\Controller\Api\Action\Project\ProjectDetailsGetAction;
  6. use App\Controller\Api\Action\Project\ProjectItemGetAction;
  7. use App\Repository\ProjectRepository;
  8. use DateTime;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. #[ORM\Entity(
  13.     repositoryClassProjectRepository::class
  14. )]
  15. #[ORM\Table(
  16.     name'project'
  17. )]
  18. #[ApiResource(
  19.     collectionOperations: [],
  20.     itemOperations: [
  21.         'get' => [
  22.             'controller' => ProjectItemGetAction::class
  23.         ],
  24.         'details' => [
  25.             'access_control' => 'is_granted("ROLE_USER")',
  26.             'controller' => ProjectDetailsGetAction::class,
  27.             'method' => 'GET',
  28.             'path' => '/projects/details/{id}'
  29.         ]
  30.     ]
  31. )]
  32. class Project
  33. {
  34.     #[ORM\Id]
  35.     #[ORM\GeneratedValue]
  36.     #[ORM\Column(
  37.         type'integer'
  38.     )]
  39.     private ?int $id null;
  40.     #[ORM\Column(
  41.         type'datetime',
  42.         nullabletrue
  43.     )]
  44.     private ?DateTime $dateCreated null;
  45.     #[ORM\Column(
  46.         type'datetime',
  47.         nullabletrue
  48.     )]
  49.     private ?DateTime $dateChanged null;
  50.     #[ORM\ManyToOne(
  51.         targetEntityUser::class,
  52.         cascade: ['persist']
  53.     )]
  54.     #[ORM\JoinColumn(
  55.         name'user_created',
  56.         nullabletrue
  57.     )]
  58.     private ?User $userCreated null;
  59.     #[ORM\ManyToOne(
  60.         targetEntityUser::class,
  61.         cascade: ['persist']
  62.     )]
  63.     #[ORM\JoinColumn(
  64.         name'user_changed',
  65.         nullabletrue
  66.     )]
  67.     private ?User $userChanged null;
  68.     #[ORM\Column(
  69.         name'color',
  70.         type'string',
  71.         length191,
  72.         nullabletrue
  73.     )]
  74.     #[Assert\NotBlank(
  75.         groups: ['action']
  76.     )]
  77.     #[Assert\Length(
  78.         max100,
  79.         groups: ['action']
  80.     )]
  81.     private ?string $color null;
  82.     #[ORM\Column(
  83.         name'active',
  84.         type'boolean',
  85.         options: ['default' => true]
  86.     )]
  87.     private bool $active true;
  88.     #[ORM\Column(
  89.         name'show_in_calendar',
  90.         type'boolean',
  91.         options: ['default' => true]
  92.     )]
  93.     private bool $showInCalendar true;
  94.     #[ORM\Column(
  95.         name'name',
  96.         type'string',
  97.         length181,
  98.         nullabletrue
  99.     )]
  100.     #[Assert\NotNull(
  101.         groups: ['action']
  102.     )]
  103.     private ?string $name null;
  104.     #[ORM\Column(
  105.         name'call_name',
  106.         type'string',
  107.         length181,
  108.         nullabletrue
  109.     )]
  110.     private ?string $callName null;
  111.     #[ORM\Column(
  112.         name'call_code',
  113.         type'string',
  114.         length181,
  115.         nullabletrue
  116.     )]
  117.     private ?string $callCode null;
  118.     #[ORM\Column(
  119.         name'conductor',
  120.         type'string',
  121.         length181,
  122.         nullabletrue
  123.     )]
  124.     private ?string $conductor null;
  125.     #[ORM\Column(
  126.         name'price',
  127.         type'decimal',
  128.         precision20,
  129.         scale2,
  130.         nullabletrue
  131.     )]
  132.     private ?string $price null;
  133.     #[ORM\Column(
  134.         name'non_refundable_funds',
  135.         type'decimal',
  136.         precision20,
  137.         scale2,
  138.         nullabletrue
  139.     )]
  140.     private ?string $nonRefundableFunds null;
  141.     #[ORM\Column(
  142.         name'personal_funds',
  143.         type'decimal',
  144.         precision20,
  145.         scale2,
  146.         nullabletrue
  147.     )]
  148.     private ?string $personalFunds null;
  149.     #[ORM\Column(
  150.         name'short_name',
  151.         type'string',
  152.         length181,
  153.         nullabletrue
  154.     )]
  155.     private ?string $shortName null;
  156.     #[ORM\Column(
  157.         name'short_description',
  158.         type'text',
  159.         nullabletrue
  160.     )]
  161.     private ?string $shortDescription null;
  162.     #[ORM\Column(
  163.         name'start_date',
  164.         type'datetime',
  165.         nullabletrue
  166.     )]
  167.     private ?DateTime $startDate null;
  168.     #[ORM\Column(
  169.         name'end_date',
  170.         type'datetime',
  171.         nullabletrue
  172.     )]
  173.     private ?DateTime $endDate null;
  174.     #[ORM\Column(
  175.         name'purpose',
  176.         type'text',
  177.         nullabletrue
  178.     )]
  179.     private ?string $purpose null;
  180.     #[ORM\Column(
  181.         name'sustainability',
  182.         type'text',
  183.         nullabletrue
  184.     )]
  185.     private ?string $sustainability null;
  186.     #[ORM\Column(
  187.         name'contact_person_pt',
  188.         type'text',
  189.         nullabletrue
  190.     )]
  191.     private ?string $contactPersonPt null;
  192.     #[ORM\Column(
  193.         name'notes_for_pm',
  194.         type'text',
  195.         nullabletrue
  196.     )]
  197.     private ?string $notesForPm null;
  198.     #[ORM\Column(
  199.         name'summary',
  200.         type'text',
  201.         nullabletrue
  202.     )]
  203.     private ?string $summary null;
  204.     #[ORM\ManyToOne(
  205.         targetEntityInstitution::class,
  206.         cascade: ['persist']
  207.     )]
  208.     #[ORM\JoinColumn(
  209.         name'institution'
  210.     )]
  211.     private ?Institution $institution null;
  212.     #[ORM\ManyToOne(
  213.         targetEntityUser::class,
  214.         cascade: ['persist']
  215.     )]
  216.     #[ORM\JoinColumn(
  217.         name'project_manager'
  218.     )]
  219.     private ?User $projectManager null;
  220.     #[ORM\OneToMany(
  221.         mappedBy'project',
  222.         targetEntityItem::class,
  223.         cascade: ['persist'],
  224.         fetch'EXTRA_LAZY',
  225.         orphanRemovaltrue
  226.     )]
  227.     private ?iterable $items;
  228.     #[ORM\OneToMany(
  229.         mappedBy'project',
  230.         targetEntityReport::class,
  231.         cascade: ['persist'],
  232.         fetch'EXTRA_LAZY',
  233.         orphanRemovaltrue
  234.     )]
  235.     #[Assert\Valid(
  236.         groups: ['action']
  237.     )]
  238.     private ?iterable $reports;
  239.     #[ORM\OneToMany(
  240.         mappedBy'project',
  241.         targetEntityProjectPartner::class,
  242.         cascade: ['persist'],
  243.         fetch'EXTRA_LAZY',
  244.         orphanRemovaltrue
  245.     )]
  246.     #[Assert\Valid(
  247.         groups: ['action']
  248.     )]
  249.     private ?iterable $partners;
  250.     #[ORM\OneToMany(
  251.         mappedBy'project',
  252.         targetEntityIndicator::class,
  253.         cascade: ['persist'],
  254.         fetch'EXTRA_LAZY',
  255.         orphanRemovaltrue
  256.     )]
  257.     #[Assert\Valid(
  258.         groups: ['action']
  259.     )]
  260.     private ?iterable $indicators;
  261.     #[ORM\OneToMany(
  262.         mappedBy'project',
  263.         targetEntityGoal::class,
  264.         cascade: ['persist'],
  265.         fetch'EXTRA_LAZY',
  266.         orphanRemovaltrue
  267.     )]
  268.     #[Assert\Valid(
  269.         groups: ['action']
  270.     )]
  271.     private ?iterable $goals;
  272.     public function __construct()
  273.     {
  274.         $this->items = new ArrayCollection();
  275.         $this->reports = new ArrayCollection();
  276.         $this->partners = new ArrayCollection();
  277.         $this->indicators = new ArrayCollection();
  278.         $this->goals = new ArrayCollection();
  279.     }
  280.     public function getId(): ?int
  281.     {
  282.         return $this->id;
  283.     }
  284.     public function setId($id): self
  285.     {
  286.         $this->id $id;
  287.         return $this;
  288.     }
  289.     public function getDateCreated(): ?DateTime
  290.     {
  291.         return $this->dateCreated;
  292.     }
  293.     public function setDateCreated(?DateTime $dateCreated): self
  294.     {
  295.         $this->dateCreated $dateCreated;
  296.         return $this;
  297.     }
  298.     public function getDateChanged(): ?DateTime
  299.     {
  300.         return $this->dateChanged;
  301.     }
  302.     public function setDateChanged(?DateTime $dateChanged): self
  303.     {
  304.         $this->dateChanged $dateChanged;
  305.         return $this;
  306.     }
  307.     public function getUserCreated(): ?User
  308.     {
  309.         return $this->userCreated;
  310.     }
  311.     public function setUserCreated(?User $userCreated): self
  312.     {
  313.         $this->userCreated $userCreated;
  314.         return $this;
  315.     }
  316.     public function getUserChanged(): ?User
  317.     {
  318.         return $this->userChanged;
  319.     }
  320.     public function setUserChanged(?User $userChanged): self
  321.     {
  322.         $this->userChanged $userChanged;
  323.         return $this;
  324.     }
  325.     public function isActive(): bool
  326.     {
  327.         return $this->active;
  328.     }
  329.     public function setActive(bool $active): void
  330.     {
  331.         $this->active $active;
  332.     }
  333.     public function isShowInCalendar(): bool
  334.     {
  335.         return $this->showInCalendar;
  336.     }
  337.     public function setShowInCalendar(bool $showInCalendar): void
  338.     {
  339.         $this->showInCalendar $showInCalendar;
  340.     }
  341.     public function getName(): ?string
  342.     {
  343.         return $this->name;
  344.     }
  345.     public function getColor(): ?string
  346.     {
  347.         return $this->color;
  348.     }
  349.     public function setColor(?string $color): self
  350.     {
  351.         $this->color $color;
  352.         return $this;
  353.     }
  354.     public function setName(?string $name): self
  355.     {
  356.         $this->name $name;
  357.         return $this;
  358.     }
  359.     public function getCallName(): ?string
  360.     {
  361.         return $this->callName;
  362.     }
  363.     public function setCallName(?string $callName): self
  364.     {
  365.         $this->callName $callName;
  366.         return $this;
  367.     }
  368.     public function getCallCode(): ?string
  369.     {
  370.         return $this->callCode;
  371.     }
  372.     public function setCallCode(?string $callCode): self
  373.     {
  374.         $this->callCode $callCode;
  375.         return $this;
  376.     }
  377.     public function getConductor(): ?string
  378.     {
  379.         return $this->conductor;
  380.     }
  381.     public function setConductor(?string $conductor): self
  382.     {
  383.         $this->conductor $conductor;
  384.         return $this;
  385.     }
  386.     public function getPrice(): ?string
  387.     {
  388.         return $this->price;
  389.     }
  390.     public function setPrice(?string $price): self
  391.     {
  392.         $this->price $price;
  393.         return $this;
  394.     }
  395.     public function getNonRefundableFunds(): ?string
  396.     {
  397.         return $this->nonRefundableFunds;
  398.     }
  399.     public function setNonRefundableFunds(?string $nonRefundableFunds): self
  400.     {
  401.         $this->nonRefundableFunds $nonRefundableFunds;
  402.         return $this;
  403.     }
  404.     public function getPersonalFunds(): ?string
  405.     {
  406.         return $this->personalFunds;
  407.     }
  408.     public function setPersonalFunds(?string $personalFunds): self
  409.     {
  410.         $this->personalFunds $personalFunds;
  411.         return $this;
  412.     }
  413.     public function getItems(): iterable
  414.     {
  415.         return $this->items;
  416.     }
  417.     public function getShortName(): ?string
  418.     {
  419.         return $this->shortName;
  420.     }
  421.     public function setShortName(?string $shortName): self
  422.     {
  423.         $this->shortName $shortName;
  424.         return $this;
  425.     }
  426.     public function getShortDescription(): ?string
  427.     {
  428.         return $this->shortDescription;
  429.     }
  430.     public function setShortDescription(?string $shortDescription): self
  431.     {
  432.         $this->shortDescription $shortDescription;
  433.         return $this;
  434.     }
  435.     public function getStartDate(): ?DateTime
  436.     {
  437.         return $this->startDate;
  438.     }
  439.     public function setStartDate(?DateTime $startDate): self
  440.     {
  441.         $this->startDate $startDate;
  442.         return $this;
  443.     }
  444.     public function getEndDate(): ?DateTime
  445.     {
  446.         return $this->endDate;
  447.     }
  448.     public function setEndDate(?DateTime $endDate): self
  449.     {
  450.         $this->endDate $endDate;
  451.         return $this;
  452.     }
  453.     public function getPurpose(): ?string
  454.     {
  455.         return $this->purpose;
  456.     }
  457.     public function setPurpose(?string $purpose): self
  458.     {
  459.         $this->purpose $purpose;
  460.         return $this;
  461.     }
  462.     public function getSustainability(): ?string
  463.     {
  464.         return $this->sustainability;
  465.     }
  466.     public function setSustainability(?string $sustainability): self
  467.     {
  468.         $this->sustainability $sustainability;
  469.         return $this;
  470.     }
  471.     public function getContactPersonPt(): ?string
  472.     {
  473.         return $this->contactPersonPt;
  474.     }
  475.     public function setContactPersonPt(?string $contactPersonPt): self
  476.     {
  477.         $this->contactPersonPt $contactPersonPt;
  478.         return $this;
  479.     }
  480.     public function getNotesForPm(): ?string
  481.     {
  482.         return $this->notesForPm;
  483.     }
  484.     public function setNotesForPm(?string $notesForPm): self
  485.     {
  486.         $this->notesForPm $notesForPm;
  487.         return $this;
  488.     }
  489.     public function getSummary(): ?string
  490.     {
  491.         return $this->summary;
  492.     }
  493.     public function setSummary(?string $summary): self
  494.     {
  495.         $this->summary $summary;
  496.         return $this;
  497.     }
  498.     public function getInstitution(): ?Institution
  499.     {
  500.         return $this->institution;
  501.     }
  502.     public function setInstitution(?Institution $institution): self
  503.     {
  504.         $this->institution $institution;
  505.         return $this;
  506.     }
  507.     public function getProjectManager(): ?User
  508.     {
  509.         return $this->projectManager;
  510.     }
  511.     public function setProjectManager(?User $projectManager): self
  512.     {
  513.         $this->projectManager $projectManager;
  514.         return $this;
  515.     }
  516.     public function addItem(Item $item): void
  517.     {
  518.         if ($this->items->contains($item)) {
  519.             return;
  520.         }
  521.         $this->items[] = $item;
  522.         $item->setProject($this);
  523.     }
  524.     public function removeItem(Item $item): void
  525.     {
  526.         if (!$this->items->contains($item)) {
  527.             return;
  528.         }
  529.         $this->items->removeElement($item);
  530.         $item->setProject(null);
  531.     }
  532.     public function getReports(): iterable
  533.     {
  534.         return $this->reports;
  535.     }
  536.     public function addReport(Report $report): void
  537.     {
  538.         if ($this->reports->contains($report)) {
  539.             return;
  540.         }
  541.         $this->reports[] = $report;
  542.         $report->setProject($this);
  543.     }
  544.     public function removeReport(Report $report): void
  545.     {
  546.         if (!$this->reports->contains($report)) {
  547.             return;
  548.         }
  549.         $this->reports->removeElement($report);
  550.         $report->setProject(null);
  551.     }
  552.     public function getPartners(): iterable
  553.     {
  554.         return $this->partners;
  555.     }
  556.     public function addPartner(ProjectPartner $partner): void
  557.     {
  558.         if ($this->partners->contains($partner)) {
  559.             return;
  560.         }
  561.         $this->partners[] = $partner;
  562.         $partner->setProject($this);
  563.     }
  564.     public function removePartner(ProjectPartner $partner): void
  565.     {
  566.         if (!$this->partners->contains($partner)) {
  567.             return;
  568.         }
  569.         $this->partners->removeElement($partner);
  570.         $partner->setProject(null);
  571.     }
  572.     public function getIndicators(): iterable
  573.     {
  574.         return $this->indicators;
  575.     }
  576.     public function getGoals(): iterable
  577.     {
  578.         return $this->goals;
  579.     }
  580.     public function addGoal(Goal $goal): void
  581.     {
  582.         if ($this->goals->contains($goal)) {
  583.             return;
  584.         }
  585.         $this->goals[] = $goal;
  586.         $goal->setProject($this);
  587.     }
  588.     public function removeGoal(Goal $goal): void
  589.     {
  590.         if (!$this->goals->contains($goal)) {
  591.             return;
  592.         }
  593.         $this->goals->removeElement($goal);
  594.         $goal->setProject(null);
  595.     }
  596.     public function addIndicator(Indicator $indicator): void
  597.     {
  598.         if ($this->indicators->contains($indicator)) {
  599.             return;
  600.         }
  601.         $this->indicators[] = $indicator;
  602.         $indicator->setProject($this);
  603.     }
  604.     public function removeIndicator(Indicator $indicator): void
  605.     {
  606.         if (!$this->indicators->contains($indicator)) {
  607.             return;
  608.         }
  609.         $this->indicators->removeElement($indicator);
  610.         $indicator->setProject(null);
  611.     }
  612. }