<?php
namespace App\Entity\ReseauSociaux;
use App\Entity\Company;
use App\Entity\User;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Security\Core\Security;
use Doctrine\Common\Collections\ArrayCollection;
use App\Repository\ReseauSociaux\EspaceRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity(repositoryClass=EspaceRepository::class)
*/
class Espace
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups("post:read", "publication:read", "espace:read")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Groups("post:read", "publication:read", "espace:read")
*/
private $name;
/**
* @ORM\Column(type="string", length=50, nullable=true)
* @Groups("post:read", "publication:read", "espace:read")
*/
private $image;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="espaces")
*/
private $propriotaire;
/**
* @ORM\OneToMany(targetEntity=Publication::class, mappedBy="espace")
*/
private $publications;
/**
* @ORM\ManyToMany(targetEntity=User::class, mappedBy="follow")
*/
private $users;
/**
* @ORM\Column(type="text")
*/
private $description;
/**
* @ORM\ManyToOne(targetEntity=Audience::class)
* @ORM\JoinColumn(nullable=false)
* @Groups("post:read")
* @Groups("publication:read")
*/
private $audience;
/**
* @ORM\Column(type="datetime")
* @Groups("post:read")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @Groups("publication:read")
*/
private $following = false;
/**
* @ORM\ManyToOne(targetEntity=Company::class, inversedBy="espaces")
*/
private $proprietairecomp;
/**
* @ORM\ManyToMany(targetEntity=Company::class, mappedBy="follow")
*/
private $companies;
public function __construct()
{
$this->publications = new ArrayCollection();
$this->users = new ArrayCollection();
$this->companies = new ArrayCollection();
}
/**
* @Groups("publication:read")
*/
public function getId(): ?int
{
return $this->id;
}
/**
* @Groups("publication:read")
*/
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getPropriotaire(): ?User
{
return $this->propriotaire;
}
public function setPropriotaire(?User $propriotaire): self
{
$this->propriotaire = $propriotaire;
return $this;
}
/**
* @return Collection|Publication[]
*/
public function getPublications(): Collection
{
return $this->publications;
}
public function addPublication(Publication $publication): self
{
if (!$this->publications->contains($publication)) {
$this->publications[] = $publication;
$publication->setEspace($this);
}
return $this;
}
public function removePublication(Publication $publication): self
{
if ($this->publications->removeElement($publication)) {
// set the owning side to null (unless already changed)
if ($publication->getEspace() === $this) {
$publication->setEspace(null);
}
}
return $this;
}
/**
* @return Collection|User[]
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
$user->addFollow($this);
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->users->removeElement($user)) {
$user->removeFollow($this);
}
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(string $description): self
{
$this->description = $description;
return $this;
}
public function getAudience(): ?Audience
{
return $this->audience;
}
public function setAudience(?Audience $audience): self
{
$this->audience = $audience;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
public function isFollowing(User $user): bool
{
if ($this->users->contains($user)) {
return true;
}
return false;
}
public function setFollowing(bool $following): void
{
$this->following = $following;
}
public function getFollowing(): ?bool
{
return $this->following;
}
public function getProprietairecomp(): ?Company
{
return $this->proprietairecomp;
}
public function setProprietairecomp(?Company $proprietairecomp): self
{
$this->proprietairecomp = $proprietairecomp;
return $this;
}
/**
* @return Collection<int, Company>
*/
public function getCompanies(): Collection
{
return $this->companies;
}
public function addCompany(Company $company): self
{
if (!$this->companies->contains($company)) {
$this->companies[] = $company;
$company->addFollow($this);
}
return $this;
}
public function removeCompany(Company $company): self
{
if ($this->companies->removeElement($company)) {
$company->removeFollow($this);
}
return $this;
}
}