| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- <?php
- declare(strict_types=1);
- namespace App\Entity\Education;
- use ApiPlatform\Metadata\ApiResource;
- use ApiPlatform\Metadata\Delete;
- use ApiPlatform\Metadata\Get;
- use ApiPlatform\Metadata\GetCollection;
- use ApiPlatform\Metadata\Post;
- use ApiPlatform\Metadata\Put;
- use App\Attribute\OrganizationDefaultValue;
- use App\Entity\Organization\Organization;
- use App\Repository\Education\EducationTimingRepository;
- // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- /**
- * Temps d'un enseignement.
- *
- * Security :
- *
- * @see \App\Doctrine\Education\CurrentEducationTimingExtension
- */
- #[ApiResource(
- operations: [
- new Get(
- security: 'is_granted(\'ROLE_ORGANIZATION_VIEW\') and object.getOrganization().getId() == user.getOrganization().getId()'
- ),
- new Put(
- security: 'object.getOrganization().getId() == user.getOrganization().getId()'
- ),
- new Delete(
- security: 'object.getOrganization().getId() == user.getOrganization().getId()'
- ),
- new GetCollection(
- security: 'is_granted(\'ROLE_ORGANIZATION_VIEW\')'
- ),
- new Post(),
- ],
- security: 'is_granted(\'ROLE_ORGANIZATION\')'
- )]
- // #[Auditable]
- #[OrganizationDefaultValue(fieldName: 'organization')]
- #[ORM\Entity(repositoryClass: EducationTimingRepository::class)]
- class EducationTiming
- {
- #[ORM\Id]
- #[ORM\Column]
- #[ORM\GeneratedValue]
- private ?int $id = null;
- #[ORM\ManyToOne(inversedBy: 'educationTimings')]
- #[ORM\JoinColumn(nullable: false)]
- private Organization $organization;
- #[ORM\Column]
- private int $timing;
- #[ORM\OneToMany(mappedBy: 'educationTiming', targetEntity: EducationStudent::class, orphanRemoval: true)]
- private Collection $educationStudents;
- #[ORM\ManyToMany(targetEntity: EducationCurriculum::class, mappedBy: 'educationTimings')]
- private Collection $educationCurriculums;
- public function __construct()
- {
- $this->educationStudents = new ArrayCollection();
- $this->educationCurriculums = new ArrayCollection();
- }
- 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 setTiming(int $timing): self
- {
- $this->timing = $timing;
- return $this;
- }
- public function getTiming(): int
- {
- return $this->timing;
- }
- /**
- * @return Collection<int, EducationStudent>
- */
- public function getEducationStudents(): Collection
- {
- return $this->educationStudents;
- }
- public function addEducationStudent(EducationStudent $educationStudent): self
- {
- if (!$this->educationStudents->contains($educationStudent)) {
- $this->educationStudents[] = $educationStudent;
- $educationStudent->setEducationTiming($this);
- }
- return $this;
- }
- public function removeEducationStudent(EducationStudent $educationStudent): self
- {
- if ($this->educationStudents->removeElement($educationStudent)) {
- // set the owning side to null (unless already changed)
- if ($educationStudent->getEducationTiming() === $this) {
- $educationStudent->setEducationTiming(null);
- }
- }
- return $this;
- }
- /**
- * @return Collection<int, EducationCurriculum>
- */
- public function getEducationCurriculums(): Collection
- {
- return $this->educationCurriculums;
- }
- public function addEducationCurriculum(EducationCurriculum $educationCurriculum): self
- {
- if (!$this->educationCurriculums->contains($educationCurriculum)) {
- $this->educationCurriculums[] = $educationCurriculum;
- $educationCurriculum->addEducationTiming($this);
- }
- return $this;
- }
- public function removeEducationCurriculum(EducationCurriculum $educationCurriculum): self
- {
- if ($this->educationCurriculums->removeElement($educationCurriculum)) {
- $educationCurriculum->removeEducationTiming($this);
- }
- return $this;
- }
- }
|