src/Entity/ReseauSociaux/Espace.php line 18

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