src/Entity/ReseauSociaux/Espace.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity\ReseauSociaux;
  3. use App\Entity\Company;
  4. use App\Entity\ReseauSociaux\InvitationEspace;
  5. use App\Entity\SubCategory;
  6. use App\Entity\User;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Doctrine\Common\Collections\Collection;
  9. use Symfony\Component\Security\Core\Security;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. use App\Repository\ReseauSociaux\EspaceRepository;
  12. use Doctrine\ORM\EntityManagerInterface;
  13. use Symfony\Component\Serializer\Annotation\Groups;
  14. /**
  15.  * @ORM\Entity(repositoryClass=EspaceRepository::class)
  16.  */
  17. class Espace
  18. {
  19.     /**
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue
  22.      * @ORM\Column(type="integer")
  23.      * @Groups({"post:read", "publication:read", "espace:read", "invitation:read", "notif:read"})
  24.      */
  25.     private $id;
  26.     /**
  27.      * @ORM\Column(type="string", length=255)
  28.      * @Groups({"post:read", "publication:read", "espace:read", "invitation:read", "notif:read"})
  29.      */
  30.     private $name;
  31.     /**
  32.      * @ORM\Column(type="string", length=255, nullable=true)
  33.      * @Groups({"post:read", "publication:read", "espace:read"})
  34.      */
  35.     private $image;
  36.     /**
  37.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="espaces")
  38.      * @Groups({"group:read"})
  39.      */
  40.     private $propriotaire;
  41.     /**
  42.      * @ORM\OneToMany(targetEntity=Publication::class, mappedBy="espace")
  43.      */
  44.     private $publications;
  45.     /**
  46.      * @ORM\ManyToMany(targetEntity=User::class, mappedBy="follow")
  47.      * @Groups({"member:read"})
  48.      */
  49.     private $users;
  50.     /**
  51.      * @ORM\Column(type="text")
  52.      * @Groups({"group:read", "group-subcategory:read"})
  53.      */
  54.     private $description;
  55.     /**
  56.      * @ORM\ManyToOne(targetEntity=Audience::class)
  57.      * @ORM\JoinColumn(nullable=false)
  58.      * @Groups({"post:read", "group:read"})
  59.      * @Groups("publication:read")
  60.      */
  61.     private $audience;
  62.     /**
  63.      * @ORM\Column(type="datetime")
  64.      * @Groups({"post:read", "group:read", "invitation:read"})
  65.      */
  66.     private $createdAt;
  67.     /**
  68.      * @ORM\Column(type="datetime", nullable=true)
  69.      */
  70.     private $updatedAt;
  71.     /**
  72.      * @Groups("publication:read")
  73.      */
  74.     private $following false;
  75.     /**
  76.      * @ORM\ManyToOne(targetEntity=Company::class, inversedBy="espaces")
  77.      * @Groups({"group:read"})
  78.      */
  79.     private $proprietairecomp;
  80.     /**
  81.      * @ORM\ManyToMany(targetEntity=Company::class, mappedBy="follow")
  82.      * @Groups({"member:read"})
  83.      */
  84.     private $companies;
  85.     /**
  86.      * @ORM\OneToMany(targetEntity=InvitationEspace::class, mappedBy="espace")
  87.      */
  88.     private $invitationEspaces;
  89.     /**
  90.      * @ORM\ManyToMany(targetEntity=SubCategory::class, inversedBy="espaces")
  91.      * @Groups({"group-subcategory:read"})
  92.      */
  93.     private $subcategories;
  94.     public function __construct()
  95.     {
  96.         $this->publications = new ArrayCollection();
  97.         $this->users = new ArrayCollection();
  98.         $this->companies = new ArrayCollection();
  99.         $this->invitationEspaces = new ArrayCollection();
  100.         $this->subcategories = new ArrayCollection();
  101.     }
  102.     /**
  103.      * @Groups("publication:read")
  104.      */
  105.     public function getId(): ?int
  106.     {
  107.         return $this->id;
  108.     }
  109.     /**
  110.      * @Groups("publication:read")
  111.      */
  112.     public function getName(): ?string
  113.     {
  114.         return $this->name;
  115.     }
  116.     public function setName(string $name): self
  117.     {
  118.         $this->name $name;
  119.         return $this;
  120.     }
  121.     public function getPropriotaire(): ?User
  122.     {
  123.         return $this->propriotaire;
  124.     }
  125.     public function setPropriotaire(?User $propriotaire): self
  126.     {
  127.         $this->propriotaire $propriotaire;
  128.         return $this;
  129.     }
  130.     /**
  131.      * @return Collection|Publication[]
  132.      */
  133.     public function getPublications(): Collection
  134.     {
  135.         return $this->publications;
  136.     }
  137.     public function addPublication(Publication $publication): self
  138.     {
  139.         if (!$this->publications->contains($publication)) {
  140.             $this->publications[] = $publication;
  141.             $publication->setEspace($this);
  142.         }
  143.         return $this;
  144.     }
  145.     public function removePublication(Publication $publication): self
  146.     {
  147.         if ($this->publications->removeElement($publication)) {
  148.             // set the owning side to null (unless already changed)
  149.             if ($publication->getEspace() === $this) {
  150.                 $publication->setEspace(null);
  151.             }
  152.         }
  153.         return $this;
  154.     }
  155.     /**
  156.      * @return Collection|User[]
  157.      */
  158.     public function getUsers(): Collection
  159.     {
  160.         return $this->users;
  161.     }
  162.     public function addUser(User $user): self
  163.     {
  164.         if (!$this->users->contains($user)) {
  165.             $this->users[] = $user;
  166.             $user->addFollow($this);
  167.         }
  168.         return $this;
  169.     }
  170.     public function removeUser(User $user): self
  171.     {
  172.         if ($this->users->removeElement($user)) {
  173.             $user->removeFollow($this);
  174.         }
  175.         return $this;
  176.     }
  177.     public function getDescription(): ?string
  178.     {
  179.         return $this->description;
  180.     }
  181.     public function setDescription(string $description): self
  182.     {
  183.         $this->description $description;
  184.         return $this;
  185.     }
  186.     public function getAudience(): ?Audience
  187.     {
  188.         return $this->audience;
  189.     }
  190.     public function setAudience(?Audience $audience): self
  191.     {
  192.         $this->audience $audience;
  193.         return $this;
  194.     }
  195.     public function getCreatedAt(): ?\DateTimeInterface
  196.     {
  197.         return $this->createdAt;
  198.     }
  199.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  200.     {
  201.         $this->createdAt $createdAt;
  202.         return $this;
  203.     }
  204.     public function getUpdatedAt(): ?\DateTimeInterface
  205.     {
  206.         return $this->updatedAt;
  207.     }
  208.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  209.     {
  210.         $this->updatedAt $updatedAt;
  211.         return $this;
  212.     }
  213.     public function getImage(): ?string
  214.     {
  215.         return $this->image;
  216.     }
  217.     public function setImage(?string $image): self
  218.     {
  219.         $this->image $image;
  220.         return $this;
  221.     }
  222.     public function isFollowing(User $user): bool
  223.     {
  224.         if ($this->users->contains($user)) {
  225.             return true;
  226.         }
  227.         return false;
  228.     }
  229.     public function setFollowing(bool $following): void
  230.     {
  231.         $this->following $following;
  232.     }
  233.     public function getFollowing(): ?bool
  234.     {
  235.         return $this->following;
  236.     }
  237.     public function getProprietairecomp(): ?Company
  238.     {
  239.         return $this->proprietairecomp;
  240.     }
  241.     public function setProprietairecomp(?Company $proprietairecomp): self
  242.     {
  243.         $this->proprietairecomp $proprietairecomp;
  244.         return $this;
  245.     }
  246.     /**
  247.      * @return Collection<int, Company>
  248.      */
  249.     public function getCompanies(): Collection
  250.     {
  251.         return $this->companies;
  252.     }
  253.     public function addCompany(Company $company): self
  254.     {
  255.         if (!$this->companies->contains($company)) {
  256.             $this->companies[] = $company;
  257.             $company->addFollow($this);
  258.         }
  259.         return $this;
  260.     }
  261.     public function removeCompany(Company $company): self
  262.     {
  263.         if ($this->companies->removeElement($company)) {
  264.             $company->removeFollow($this);
  265.         }
  266.         return $this;
  267.     }
  268.     /**
  269.      * @return Collection<int, InvitationEspace>
  270.      */
  271.     public function getInvitationEspaces(): Collection
  272.     {
  273.         return $this->invitationEspaces;
  274.     }
  275.     public function addInvitationEspace(InvitationEspace $invitationEspace): self
  276.     {
  277.         if (!$this->invitationEspaces->contains($invitationEspace)) {
  278.             $this->invitationEspaces[] = $invitationEspace;
  279.             $invitationEspace->setEspace($this);
  280.         }
  281.         return $this;
  282.     }
  283.     public function removeInvitationEspace(InvitationEspace $invitationEspace): self
  284.     {
  285.         if ($this->invitationEspaces->removeElement($invitationEspace)) {
  286.             // set the owning side to null (unless already changed)
  287.             if ($invitationEspace->getEspace() === $this) {
  288.                 $invitationEspace->setEspace(null);
  289.             }
  290.         }
  291.         return $this;
  292.     }
  293.     /**
  294.      * @return Collection<int, SubCategory>
  295.      */
  296.     public function getSubcategories(): Collection
  297.     {
  298.         return $this->subcategories;
  299.     }
  300.     public function addSubcategory(SubCategory $subcategory): self
  301.     {
  302.         if (!$this->subcategories->contains($subcategory)) {
  303.             $this->subcategories[] = $subcategory;
  304.         }
  305.         return $this;
  306.     }
  307.     public function removeSubcategory(SubCategory $subcategory): self
  308.     {
  309.         $this->subcategories->removeElement($subcategory);
  310.         return $this;
  311.     }
  312. }