| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- <?php
- declare(strict_types=1);
- namespace App\Entity\Network;
- use ApiPlatform\Core\Annotation\ApiResource;
- use App\Annotation\DateTimeConstraintAware;
- use App\Entity\Organization\Organization;
- use App\Repository\Network\NetworkOrganizationRepository;
- use Doctrine\ORM\Mapping as ORM;
- use Symfony\Component\Serializer\Annotation\Groups;
- /**
- * Fait le lien entre une Organization et un Network
- */
- #[ApiResource(
- collectionOperations: [
- "get" => ["security" => "is_granted('ROLE_ORGANIZATION_VIEW')"]
- ],
- itemOperations: [
- 'get' => [
- 'security' => 'is_granted("ROLE_ORGANIZATION_VIEW" and object.getOrganization().getId() == user.getOrganization().getId()'
- ]
- ],
- attributes: ["security" => "is_granted('ROLE_ORGANIZATION')"],
- normalizationContext: [
- 'groups' => ['network'],
- ]
- )]
- #[ORM\Entity(repositoryClass: NetworkOrganizationRepository::class)]
- #[DateTimeConstraintAware(startDateFieldName: "startDate", endDateFieldName: "endDate")]
- class NetworkOrganization
- {
- #[ORM\Id]
- #[ORM\Column]
- #[ORM\GeneratedValue]
- #[Groups("network")]
- private ?int $id = null;
- #[ORM\ManyToOne]
- #[ORM\JoinColumn(nullable: true)]
- #[Groups("network")]
- private Network $network;
- #[ORM\ManyToOne(inversedBy: 'networkOrganizations')]
- #[ORM\JoinColumn(nullable: true)]
- private Organization $organization;
- #[ORM\ManyToOne(inversedBy: 'networkOrganizationChildren')]
- private ?Organization $parent;
- #[ORM\Column(length: 255, nullable: true)]
- private ?string $leadingCause = null;
- #[ORM\Column(type: 'date', nullable: true)]
- #[Groups("network")]
- private ?\DateTimeInterface $startDate = null;
- #[ORM\Column(type: 'date', nullable: true)]
- private ?\DateTimeInterface $endDate = null;
- public function getId(): ?int
- {
- return $this->id;
- }
- public function getNetwork(): ?Network
- {
- return $this->network;
- }
- public function setNetwork(?Network $network): self
- {
- $this->network = $network;
- return $this;
- }
- public function getOrganization(): ?Organization
- {
- return $this->organization;
- }
- public function setOrganization(?Organization $organization): self
- {
- $this->organization = $organization;
- return $this;
- }
- public function getParent(): ?Organization
- {
- return $this->parent;
- }
- public function setParent(?Organization $parent): self
- {
- $this->parent = $parent;
- return $this;
- }
- public function getLeadingCause(): ?string
- {
- return $this->leadingCause;
- }
- public function setLeadingCause(?string $leadingCause): self
- {
- $this->leadingCause = $leadingCause;
- return $this;
- }
- public function getStartDate(): ?\DateTimeInterface {
- return $this->startDate;
- }
- public function setStartDate(?\DateTime $startDate = null): self {
- if($startDate == null) $startDate = new \DateTime();
- $this->startDate = $startDate;
- return $this;
- }
- public function getEndDate(): ?\DateTimeInterface {
- return $this->endDate;
- }
- public function setEndDate(?\DateTime $endDate = null) :self {
- $this->endDate = $endDate;
- return $this;
- }
- }
|