| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- <?php
- declare(strict_types=1);
- namespace App\Entity\Organization;
- use ApiPlatform\Core\Annotation\ApiResource;
- use App\Entity\Network\NetworkOrganization;
- use App\Repository\Organization\OrganizationRepository;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- /**
- * Structure, organisation
- *
- * @ApiResource(
- * collectionOperations={
- * "get"={"security"="is_granted('ROLE_ORGANIZATION')"},
- * "post"={"security"="is_granted('ROLE_ORGANIZATION_CREATE')"}
- * },
- * itemOperations={
- * "get"={"security"="is_granted('ROLE_ORGANIZATION_EDIT') and object.getId() == user.organization.getId()"},
- * "put"={"security"="is_granted('ROLE_ORGANIZATION_EDIT')"}
- * }
- * )
- * @ORM\Entity(repositoryClass=OrganizationRepository::class)
- */
- class Organization
- {
- /**
- * @ORM\Id
- * @ORM\GeneratedValue
- * @ORM\Column(type="integer")
- */
- private $id;
- /**
- * @ORM\Column(type="string", length=128)
- */
- private $name;
- /**
- * @ORM\Column(type="string", length=128)
- */
- private $identifier;
- /**
- * @ORM\Column(type="string", length=255, nullable=true)
- */
- private $legalStatus;
- /**
- * @ORM\Column(type="string", length=255, nullable=true)
- */
- private $principalType;
- /**
- * @ORM\OneToOne(targetEntity=Settings::class, mappedBy="organization", cascade={"persist", "remove"})
- */
- private $settings;
- /**
- * @ORM\OneToMany(targetEntity=NetworkOrganization::class, mappedBy="organization", orphanRemoval=true)
- */
- private $networkOrganizations;
- /**
- * @ORM\OneToMany(targetEntity=NetworkOrganization::class, mappedBy="parent")
- */
- private $networkOrganizationChildren;
- /**
- * @ORM\OneToOne(targetEntity=Parameters::class, cascade={"persist", "remove"})
- * @ORM\JoinColumn(nullable=false)
- */
- private $parameters;
- public function __construct()
- {
- $this->networkOrganizations = new ArrayCollection();
- $this->networkOrganizationChildren = new ArrayCollection();
- }
- 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 getIdentifier(): ?string
- {
- return $this->identifier;
- }
- public function setIdentifier(string $identifier): self
- {
- $this->identifier = $identifier;
- return $this;
- }
- public function getLegalStatus(): ?string
- {
- return $this->legalStatus;
- }
- public function setLegalStatus(?string $legalStatus): self
- {
- $this->legalStatus = $legalStatus;
- return $this;
- }
- public function getPrincipalType(): ?string
- {
- return $this->principalType;
- }
- public function setPrincipalType(?string $principalType): self
- {
- $this->principalType = $principalType;
- return $this;
- }
- public function getSettings(): ?Settings
- {
- return $this->settings;
- }
- public function setSettings(Settings $settings): self
- {
- // set the owning side of the relation if necessary
- if ($settings->getOrganization() !== $this) {
- $settings->setOrganization($this);
- }
- $this->settings = $settings;
- return $this;
- }
- /**
- * @return Collection|NetworkOrganization[]
- */
- public function getNetworkOrganizations(): Collection
- {
- return $this->networkOrganizations;
- }
- public function addNetworkOrganization(NetworkOrganization $networkOrganization): self
- {
- if (!$this->networkOrganizations->contains($networkOrganization)) {
- $this->networkOrganizations[] = $networkOrganization;
- $networkOrganization->setOrganization($this);
- }
- return $this;
- }
- public function removeNetworkOrganization(NetworkOrganization $networkOrganization): self
- {
- if ($this->networkOrganizations->removeElement($networkOrganization)) {
- // set the owning side to null (unless already changed)
- if ($networkOrganization->getOrganization() === $this) {
- $networkOrganization->setOrganization(null);
- }
- }
- return $this;
- }
- /**
- * @return Collection|NetworkOrganization[]
- */
- public function getNetworkOrganizationChildren(): Collection
- {
- return $this->networkOrganizationChildren;
- }
- public function addNetworkOrganizationChild(NetworkOrganization $networkOrganizationChild): self
- {
- if (!$this->networkOrganizationChildren->contains($networkOrganizationChild)) {
- $this->networkOrganizationChildren[] = $networkOrganizationChild;
- $networkOrganizationChild->setParent($this);
- }
- return $this;
- }
- public function removeNetworkOrganizationChild(NetworkOrganization $networkOrganizationChild): self
- {
- if ($this->networkOrganizationChildren->removeElement($networkOrganizationChild)) {
- // set the owning side to null (unless already changed)
- if ($networkOrganizationChild->getParent() === $this) {
- $networkOrganizationChild->setParent(null);
- }
- }
- return $this;
- }
- public function getParameters(): ?Parameters
- {
- return $this->parameters;
- }
- public function setParameters(Parameters $parameters): self
- {
- $this->parameters = $parameters;
- return $this;
- }
- }
|