| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- <?php
- declare(strict_types=1);
- namespace App\Entity\Network;
- use ApiPlatform\Metadata\ApiResource;
- use App\Entity\Core\File;
- use App\Repository\Network\NetworkRepository;
- // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- use JetBrains\PhpStorm\Pure;
- use Symfony\Component\Serializer\Annotation\Groups;
- /**
- * Enum des différents réseaux auxquels peut appartenir une Organization.
- */
- #[ApiResource(operations: [])]
- // #[Auditable]
- #[ORM\Entity(repositoryClass: NetworkRepository::class)]
- class Network
- {
- #[ORM\Id]
- #[ORM\Column]
- #[ORM\GeneratedValue]
- #[Groups('network')]
- private ?int $id = null;
- #[ORM\Column(length: 255)]
- #[Groups('network')]
- private string $name;
- #[ORM\Column(length: 255, nullable: true)]
- private ?string $logo = null;
- #[ORM\Column(length: 255, nullable: true)]
- private ?string $url = null;
- #[ORM\OneToMany(mappedBy: 'network', targetEntity: NetworkOrganization::class, orphanRemoval: true)]
- private Collection $organizations;
- #[ORM\ManyToOne(targetEntity: File::class, cascade: [], inversedBy: 'networks')]
- protected File $image;
- #[Pure]
- public function __construct()
- {
- $this->organizations = new ArrayCollection();
- }
- public function setId(int $id): self
- {
- $this->id = $id;
- return $this;
- }
- public function getId(): ?int
- {
- return $this->id;
- }
- public function getName(): string
- {
- return $this->name;
- }
- public function setName(string $name): self
- {
- $this->name = $name;
- return $this;
- }
- public function getLogo(): ?string
- {
- return $this->logo;
- }
- public function setLogo(?string $logo): self
- {
- $this->logo = $logo;
- return $this;
- }
- public function getUrl(): ?string
- {
- return $this->url;
- }
- public function setUrl(?string $url): self
- {
- $this->url = $url;
- return $this;
- }
- /**
- * @return Collection<int, NetworkOrganization>
- */
- public function getOrganizations(): Collection
- {
- return $this->organizations;
- }
- public function addOrganization(NetworkOrganization $organization): self
- {
- if (!$this->organizations->contains($organization)) {
- $this->organizations[] = $organization;
- $organization->setNetwork($this);
- }
- return $this;
- }
- public function removeOrganization(NetworkOrganization $organization): self
- {
- if ($this->organizations->removeElement($organization)) {
- // set the owning side to null (unless already changed)
- if ($organization->getNetwork() === $this) {
- $organization->setNetwork(null);
- }
- }
- return $this;
- }
- public function getImage(): File
- {
- return $this->image;
- }
- public function setImage(File $image): self
- {
- $this->image = $image;
- return $this;
- }
- }
|