<?php
namespace App\Entity\Media;
use App\Entity\BaseEntity;
use App\Entity\Chats;
use App\Entity\Finance\MediaEarning;
use App\Entity\Post\Post;
use App\Entity\Program\Program;
use App\Entity\Shortcut;
use App\Entity\SocialMedia;
use App\Entity\User;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass="App\Repository\Media\MediaRepository")
* @UniqueEntity(
* fields={"url"},
* errorPath="url",
* message="This url is already in use on that host."
* )
* @ORM\HasLifecycleCallbacks()
*/
class Media extends BaseEntity
{
private $logoFile;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $logo;
/**
* @ORM\Column(type="string", length=255, nullable=false)
*/
private $name;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $about;
/**
* @ORM\Column(type="string", length=255, nullable=false, unique=true)
*/
private $url;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $dynamicLink;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $shortDynamicLink;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $website;
/**
* @ORM\Column(type="string", length=255, nullable=false)
*/
private $type;
/**
* @ORM\Column(type="string", length=255, nullable=false)
*/
private $category;
/**
* @ORM\Column(type="json", length=255, nullable=true)
*/
private $languages;
/**
* @ORM\Column(type="json", length=255, nullable=true)
*/
private $zones;
/**
* @ORM\OneToOne(targetEntity="App\Entity\SocialMedia", inversedBy="media",cascade={"persist"})
*/
private $socialMedia;
//Champ pour coordonnée
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $tel;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $email1;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $email2;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $address;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $city;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $zipCode;
/**
* @ORM\Column(type="string", length=255, nullable=false)
*/
private $country;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Program\Program",mappedBy="media",cascade={"persist"})
*/
private $programs;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Post\Post",mappedBy="media",cascade={"persist"}, orphanRemoval=true)
*/
private $posts;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Media\MediaTeam",mappedBy="media",cascade={"persist"})
*/
private $teams;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="mediasCreated")
* @ORM\JoinColumn(nullable=false)
*/
private $createdBy;
// TOBE deleted
/**
* @ORM\Column(type="integer")
*/
private $nbrFollowers;
public $isFollowed;
public $nbrPosts;
/**
* @ORM\Column(type="integer", options={"default" : 0})
*/
public $score;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Chats",mappedBy="media",cascade={"persist"}, orphanRemoval=true)
*/
private $chats;
/**
* @ORM\Column(type="integer", options={"default" : 0})
*/
private $numberChatsNonLu;
public $isInShortCut;
/**
* @ORM\OneToMany(targetEntity=Shortcut::class, mappedBy="media")
*/
private $shortcuts;
/**
* @ORM\Column(type="integer")
*/
public $numberParticipation;
/**
* @ORM\Column(type="integer")
*/
private $level;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Finance\MediaEarning",mappedBy="media",cascade={"persist"})
*/
private $mediaEarnings;
public function __construct()
{
$this->programs = new ArrayCollection();
$this->posts = new ArrayCollection();
$this->teams = new ArrayCollection();
$this->logo = "logo-default.png";
$this->nbrFollowers = 0;
$this->score = 0;
$this->chats = new ArrayCollection();
$this->numberChatsNonLu = 0;
$this->shortcuts = new ArrayCollection();
$this->setNumberParticipation(0);
$this->level = 0;
$this->mediaEarnings = new ArrayCollection();
}
public function getLogo(): ?string
{
return $this->logo;
}
public function setLogo(?string $logo): self
{
$this->logo = $logo;
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 getAbout(): ?string
{
return $this->about;
}
public function setAbout(?string $about): self
{
$this->about = $about;
return $this;
}
public function getUrl(): ?string
{
return $this->url;
}
public function setUrl(string $url): self
{
$this->url = $url;
return $this;
}
public function getWebsite(): ?string
{
return $this->website;
}
public function setWebsite(string $website): self
{
$this->website = $website;
return $this;
}
public function getEmail1(): ?string
{
return $this->email1;
}
public function setEmail1(string $email1): self
{
$this->email1 = $email1;
return $this;
}
public function getEmail2(): ?string
{
return $this->email2;
}
public function setEmail2(string $email2): self
{
$this->email2 = $email2;
return $this;
}
public function getZipCode(): ?string
{
return $this->zipCode;
}
public function setZipCode(string $zipCode): self
{
$this->zipCode = $zipCode;
return $this;
}
public function getSocialMedia(): ?SocialMedia
{
return $this->socialMedia;
}
public function setSocialMedia(?SocialMedia $socialMedia): self
{
$this->socialMedia = $socialMedia;
return $this;
}
public function __toString()
{
return $this->name;
}
/**
* @return Collection|Post[]
*/
public function getPosts(): Collection
{
return $this->posts;
}
public function addPost(Post $post): self
{
if (!$this->posts->contains($post)) {
$this->posts[] = $post;
$post->setMedia($this);
}
return $this;
}
public function removePost(Post $post): self
{
if ($this->posts->contains($post)) {
$this->posts->removeElement($post);
// set the owning side to null (unless already changed)
if ($post->getMedia() === $this) {
$post->setMedia(null);
}
}
return $this;
}
/**
* @return Collection|MediaTeam[]
*/
public function getTeams(): Collection
{
return $this->teams;
}
public function addTeam(MediaTeam $team): self
{
if (!$this->teams->contains($team)) {
$this->teams[] = $team;
$team->setMedia($this);
}
return $this;
}
public function removeTeam(MediaTeam $team): self
{
if ($this->teams->contains($team)) {
$this->teams->removeElement($team);
// set the owning side to null (unless already changed)
if ($team->getMedia() === $this) {
$team->setMedia(null);
}
}
return $this;
}
public function getCreatedBy(): ?User
{
return $this->createdBy;
}
public function setCreatedBy(?User $createdBy): self
{
$this->createdBy = $createdBy;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): self
{
$this->type = $type;
return $this;
}
public function getCategory(): ?string
{
return $this->category;
}
public function setCategory(?string $category): self
{
$this->category = $category;
return $this;
}
public function getZones(): ?array
{
return $this->zones;
}
public function setZones(?array $zones): self
{
$this->zones = $zones;
return $this;
}
public function getLanguages(): ?array
{
return $this->languages;
}
public function setLanguages(?array $languages): self
{
$this->languages = $languages;
return $this;
}
public function getNbrFollowers(): ?int
{
return $this->nbrFollowers;
}
public function setNbrFollowers(int $nbrFollowers): self
{
$this->nbrFollowers = $nbrFollowers;
return $this;
}
public function getScore(): ?int
{
return $this->score;
}
public function setScore(int $score): self
{
$this->score = $score;
return $this;
}
/**
* @return Collection|Chats[]
*/
public function getChats(): Collection
{
return $this->chats;
}
public function addChat(Chats $chat): self
{
if (!$this->chats->contains($chat)) {
$this->chats[] = $chat;
$chat->setMedia($this);
}
return $this;
}
public function removeChat(Chats $chat): self
{
if ($this->chats->removeElement($chat)) {
// set the owning side to null (unless already changed)
if ($chat->getMedia() === $this) {
$chat->setMedia(null);
}
}
return $this;
}
public function getNumberChatsNonLu(): ?int
{
return $this->numberChatsNonLu;
}
public function setNumberChatsNonLu(int $numberChatsNonLu): self
{
$this->numberChatsNonLu = $numberChatsNonLu;
return $this;
}
/**
* @return Collection|Program[]
*/
public function getPrograms(): Collection
{
return $this->programs;
}
public function addProgram(Program $program): self
{
if (!$this->programs->contains($program)) {
$this->programs[] = $program;
$program->setMedia($this);
}
return $this;
}
public function removeProgram(Program $program): self
{
if ($this->programs->contains($program)) {
$this->programs->removeElement($program);
// set the owning side to null (unless already changed)
if ($program->getMedia() === $this) {
$program->setMedia(null);
}
}
return $this;
}
/**
* @param Collection|Program[] $programs
* @return $this
* Méthode used to set the list of program only to show this in twig for the user is crewMember
* Do not use this to persist in dataBase
*/
public function setPrograms($programs): self
{
$this->programs = $programs;
return $this;
}
/**
* @return Collection|Shortcut[]
*/
public function getShortcuts(): Collection
{
return $this->shortcuts;
}
public function addShortcut(Shortcut $shortcut): self
{
if (!$this->shortcuts->contains($shortcut)) {
$this->shortcuts[] = $shortcut;
$shortcut->setMedia($this);
}
return $this;
}
public function removeShortcut(Shortcut $shortcut): self
{
if ($this->shortcuts->removeElement($shortcut)) {
// set the owning side to null (unless already changed)
if ($shortcut->getMedia() === $this) {
$shortcut->setMedia(null);
}
}
return $this;
}
public function getNumberParticipation(): ?int
{
return $this->numberParticipation;
}
public function setNumberParticipation(int $numberParticipation): self
{
$this->numberParticipation = $numberParticipation;
return $this;
}
public function getTel(): ?string
{
return $this->tel;
}
public function setTel(?string $tel): self
{
$this->tel = $tel;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(?string $address): self
{
$this->address = $address;
return $this;
}
public function getCountry(): ?string
{
return $this->country;
}
public function setCountry(string $country): self
{
$this->country = $country;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): self
{
$this->city = $city;
return $this;
}
public function getDynamicLink(): ?string
{
return $this->dynamicLink;
}
public function setDynamicLink(?string $dynamicLink): self
{
$this->dynamicLink = $dynamicLink;
return $this;
}
public function getShortDynamicLink(): ?string
{
return $this->shortDynamicLink;
}
public function setShortDynamicLink(?string $shortDynamicLink): self
{
$this->shortDynamicLink = $shortDynamicLink;
return $this;
}
public function getLevel(): ?int
{
return $this->level;
}
public function setLevel(int $level): self
{
$this->level = $level;
return $this;
}
/**
* @return Collection|MediaEarning[]
*/
public function getMediaEarnings(): Collection
{
return $this->mediaEarnings;
}
public function addMediaEarning(MediaEarning $mediaEarning): self
{
if (!$this->mediaEarnings->contains($mediaEarning)) {
$this->mediaEarnings[] = $mediaEarning;
$mediaEarning->setMedia($this);
}
return $this;
}
public function removeMediaEarning(MediaEarning $mediaEarning): self
{
if ($this->mediaEarnings->removeElement($mediaEarning)) {
// set the owning side to null (unless already changed)
if ($mediaEarning->getMedia() === $this) {
$mediaEarning->setMedia(null);
}
}
return $this;
}
}