|
|
@@ -0,0 +1,112 @@
|
|
|
+<?php
|
|
|
+declare(strict_types=1);
|
|
|
+
|
|
|
+namespace App\Entity\Education;
|
|
|
+
|
|
|
+use ApiPlatform\Core\Annotation\ApiResource;
|
|
|
+use App\Repository\Education\CycleRepository;
|
|
|
+use App\Entity\Organization\Organization;
|
|
|
+use Doctrine\ORM\Mapping as ORM;
|
|
|
+use Symfony\Component\Validator\Constraints as Assert;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Enum des cycles éducatifs, utilisés par les EducationCurriculum
|
|
|
+ * NB: le nombre de cycles est fixé à 6, mais chaque Organization peut en modifier le label
|
|
|
+ */
|
|
|
+#[ApiResource(
|
|
|
+ collectionOperations: [
|
|
|
+ "get" => ["security" => "is_granted('ROLE_ORGANIZATION_VIEW')"]
|
|
|
+ ],
|
|
|
+ itemOperations: [
|
|
|
+ "get" => ["security" => "is_granted('ROLE_ORGANIZATION_VIEW') and object.getOrganization().getId() == user.getOrganization().getId()"],
|
|
|
+ "put" => ["security" => "object.getOrganization().getId() == user.getOrganization().getId()"],
|
|
|
+ ],
|
|
|
+ attributes: ["security" => "is_granted('ROLE_ORGANIZATION')"]
|
|
|
+)]
|
|
|
+#[ORM\Entity(repositoryClass: CycleRepository::class)]
|
|
|
+class Cycle
|
|
|
+{
|
|
|
+ #[ORM\Id]
|
|
|
+ #[ORM\Column]
|
|
|
+ #[ORM\GeneratedValue]
|
|
|
+ private ?int $id = null;
|
|
|
+
|
|
|
+ #[ORM\ManyToOne(inversedBy: 'cycles')]
|
|
|
+ private Organization $organization;
|
|
|
+
|
|
|
+ #[ORM\Column(nullable: true)]
|
|
|
+ private ?int $order = null;
|
|
|
+
|
|
|
+ #[ORM\Column(length: 255)]
|
|
|
+ private string $label;
|
|
|
+
|
|
|
+ #[ORM\Column(length: 255)]
|
|
|
+ #[Assert\Choice(callback: ['\App\Enum\Education\CycleEnum', 'toArray'], message: 'invalid-cycle')]
|
|
|
+ private string $cycleEnum;
|
|
|
+
|
|
|
+ #[ORM\Column(options: ['default' => false])]
|
|
|
+ private bool $isSystem = false;
|
|
|
+
|
|
|
+ public function getId() :?int
|
|
|
+ {
|
|
|
+ return $this->id;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setOrganization(Organization $organization): self
|
|
|
+ {
|
|
|
+ $this->organization = $organization;
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getOrganization(): Organization
|
|
|
+ {
|
|
|
+ return $this->organization;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setOrder(?int $order): self
|
|
|
+ {
|
|
|
+ $this->order = $order;
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getOrder(): ?int
|
|
|
+ {
|
|
|
+ return $this->order;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function setLabel(string $label): self
|
|
|
+ {
|
|
|
+ $this->label = $label;
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getLabel(): string
|
|
|
+ {
|
|
|
+ return $this->label;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setCycleEnum(string $cycleEnum): self
|
|
|
+ {
|
|
|
+ $this->cycleEnum = $cycleEnum;
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getCycleEnum(): string
|
|
|
+ {
|
|
|
+ return $this->cycleEnum;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function setIsSystem(bool $isSystem): self
|
|
|
+ {
|
|
|
+ $this->isSystem = $isSystem;
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function getIsSystem(): bool
|
|
|
+ {
|
|
|
+ return $this->isSystem;
|
|
|
+ }
|
|
|
+}
|