src/Entity/Media/Media.php line 28

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Media;
  3. use App\Entity\BaseEntity;
  4. use App\Entity\Chats;
  5. use App\Entity\Finance\MediaEarning;
  6. use App\Entity\Post\Post;
  7. use App\Entity\Program\Program;
  8. use App\Entity\Shortcut;
  9. use App\Entity\SocialMedia;
  10. use App\Entity\User;
  11. use Doctrine\Common\Collections\ArrayCollection;
  12. use Doctrine\Common\Collections\Collection;
  13. use Doctrine\ORM\Mapping as ORM;
  14. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  15. /**
  16.  * @ORM\Entity(repositoryClass="App\Repository\Media\MediaRepository")
  17.  * @UniqueEntity(
  18.  *     fields={"url"},
  19.  *     errorPath="url",
  20.  *     message="This url is already in use on that host."
  21.  * )
  22.  * @ORM\HasLifecycleCallbacks()
  23.  */
  24. class Media extends BaseEntity
  25. {
  26.     private $logoFile;
  27.     /**
  28.      * @ORM\Column(type="string", length=255, nullable=true)
  29.      */
  30.     private $logo;
  31.     /**
  32.      * @ORM\Column(type="string", length=255, nullable=false)
  33.      */
  34.     private $name;
  35.     /**
  36.      * @ORM\Column(type="text", nullable=true)
  37.      */
  38.     private $about;
  39.     /**
  40.      * @ORM\Column(type="string", length=255, nullable=false, unique=true)
  41.      */
  42.     private $url;
  43.     /**
  44.      * @ORM\Column(type="text", nullable=true)
  45.      */
  46.     private $dynamicLink;
  47.     /**
  48.      * @ORM\Column(type="string", length=255, nullable=true)
  49.      */
  50.     private $shortDynamicLink;
  51.     /**
  52.      * @ORM\Column(type="string", length=255, nullable=true)
  53.      */
  54.     private $website;
  55.     /**
  56.      * @ORM\Column(type="string", length=255, nullable=false)
  57.      */
  58.     private $type;
  59.     /**
  60.      * @ORM\Column(type="string", length=255, nullable=false)
  61.      */
  62.     private $category;
  63.     /**
  64.      * @ORM\Column(type="json", length=255, nullable=true)
  65.      */
  66.     private $languages;
  67.     /**
  68.      * @ORM\Column(type="json", length=255, nullable=true)
  69.      */
  70.     private $zones;
  71.     /**
  72.      * @ORM\OneToOne(targetEntity="App\Entity\SocialMedia", inversedBy="media",cascade={"persist"})
  73.      */
  74.     private $socialMedia;
  75.     //Champ pour coordonnée
  76.     /**
  77.      * @ORM\Column(type="string", length=255, nullable=true)
  78.      */
  79.     private $tel;
  80.     /**
  81.      * @ORM\Column(type="string", length=255, nullable=true)
  82.      */
  83.     private $email1;
  84.     /**
  85.      * @ORM\Column(type="string", length=255, nullable=true)
  86.      */
  87.     private $email2;
  88.     /**
  89.      * @ORM\Column(type="string", length=255, nullable=true)
  90.      */
  91.     private $address;
  92.     /**
  93.      * @ORM\Column(type="string", length=255, nullable=true)
  94.      */
  95.     private $city;
  96.     /**
  97.      * @ORM\Column(type="string", length=255, nullable=true)
  98.      */
  99.     private $zipCode;
  100.     /**
  101.      * @ORM\Column(type="string", length=255, nullable=false)
  102.      */
  103.     private $country;
  104.     /**
  105.      * @ORM\OneToMany(targetEntity="App\Entity\Program\Program",mappedBy="media",cascade={"persist"})
  106.      */
  107.     private $programs;
  108.     /**
  109.      * @ORM\OneToMany(targetEntity="App\Entity\Post\Post",mappedBy="media",cascade={"persist"}, orphanRemoval=true)
  110.      */
  111.     private $posts;
  112.     /**
  113.      * @ORM\OneToMany(targetEntity="App\Entity\Media\MediaTeam",mappedBy="media",cascade={"persist"})
  114.      */
  115.     private $teams;
  116.     /**
  117.      * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="mediasCreated")
  118.      * @ORM\JoinColumn(nullable=false)
  119.      */
  120.     private $createdBy;
  121.     // TOBE deleted
  122.     /**
  123.      * @ORM\Column(type="integer")
  124.      */
  125.     private $nbrFollowers;
  126.     public $isFollowed;
  127.     public $nbrPosts;
  128.     /**
  129.      * @ORM\Column(type="integer", options={"default" : 0})
  130.      */
  131.     public $score;
  132.     /**
  133.      * @ORM\OneToMany(targetEntity="App\Entity\Chats",mappedBy="media",cascade={"persist"}, orphanRemoval=true)
  134.      */
  135.     private $chats;
  136.     /**
  137.      * @ORM\Column(type="integer", options={"default" : 0})
  138.      */
  139.     private $numberChatsNonLu;
  140.     public $isInShortCut;
  141.     /**
  142.      * @ORM\OneToMany(targetEntity=Shortcut::class, mappedBy="media")
  143.      */
  144.     private $shortcuts;
  145.     /**
  146.      * @ORM\Column(type="integer")
  147.      */
  148.     public $numberParticipation;
  149.     /**
  150.      * @ORM\Column(type="integer")
  151.      */
  152.     private $level;
  153.     /**
  154.      * @ORM\OneToMany(targetEntity="App\Entity\Finance\MediaEarning",mappedBy="media",cascade={"persist"})
  155.      */
  156.     private $mediaEarnings;
  157.     public function __construct()
  158.     {
  159.         $this->programs = new ArrayCollection();
  160.         $this->posts = new ArrayCollection();
  161.         $this->teams = new ArrayCollection();
  162.         $this->logo "logo-default.png";
  163.         $this->nbrFollowers 0;
  164.         $this->score 0;
  165.         $this->chats = new ArrayCollection();
  166.         $this->numberChatsNonLu 0;
  167.         $this->shortcuts = new ArrayCollection();
  168.         $this->setNumberParticipation(0);
  169.         $this->level 0;
  170.         $this->mediaEarnings = new ArrayCollection();
  171.     }
  172.     public function getLogo(): ?string
  173.     {
  174.         return $this->logo;
  175.     }
  176.     public function setLogo(?string $logo): self
  177.     {
  178.         $this->logo $logo;
  179.         return $this;
  180.     }
  181.     public function getId(): ?int
  182.     {
  183.         return $this->id;
  184.     }
  185.     public function getName(): ?string
  186.     {
  187.         return $this->name;
  188.     }
  189.     public function setName(string $name): self
  190.     {
  191.         $this->name $name;
  192.         return $this;
  193.     }
  194.     public function getAbout(): ?string
  195.     {
  196.         return $this->about;
  197.     }
  198.     public function setAbout(?string $about): self
  199.     {
  200.         $this->about $about;
  201.         return $this;
  202.     }
  203.     public function getUrl(): ?string
  204.     {
  205.         return $this->url;
  206.     }
  207.     public function setUrl(string $url): self
  208.     {
  209.         $this->url $url;
  210.         return $this;
  211.     }
  212.     public function getWebsite(): ?string
  213.     {
  214.         return $this->website;
  215.     }
  216.     public function setWebsite(string $website): self
  217.     {
  218.         $this->website $website;
  219.         return $this;
  220.     }
  221.     public function getEmail1(): ?string
  222.     {
  223.         return $this->email1;
  224.     }
  225.     public function setEmail1(string $email1): self
  226.     {
  227.         $this->email1 $email1;
  228.         return $this;
  229.     }
  230.     public function getEmail2(): ?string
  231.     {
  232.         return $this->email2;
  233.     }
  234.     public function setEmail2(string $email2): self
  235.     {
  236.         $this->email2 $email2;
  237.         return $this;
  238.     }
  239.     public function getZipCode(): ?string
  240.     {
  241.         return $this->zipCode;
  242.     }
  243.     public function setZipCode(string $zipCode): self
  244.     {
  245.         $this->zipCode $zipCode;
  246.         return $this;
  247.     }
  248.     public function getSocialMedia(): ?SocialMedia
  249.     {
  250.         return $this->socialMedia;
  251.     }
  252.     public function setSocialMedia(?SocialMedia $socialMedia): self
  253.     {
  254.         $this->socialMedia $socialMedia;
  255.         return $this;
  256.     }
  257.     public function __toString()
  258.     {
  259.         return $this->name;
  260.     }
  261.     /**
  262.      * @return Collection|Post[]
  263.      */
  264.     public function getPosts(): Collection
  265.     {
  266.         return $this->posts;
  267.     }
  268.     public function addPost(Post $post): self
  269.     {
  270.         if (!$this->posts->contains($post)) {
  271.             $this->posts[] = $post;
  272.             $post->setMedia($this);
  273.         }
  274.         return $this;
  275.     }
  276.     public function removePost(Post $post): self
  277.     {
  278.         if ($this->posts->contains($post)) {
  279.             $this->posts->removeElement($post);
  280.             // set the owning side to null (unless already changed)
  281.             if ($post->getMedia() === $this) {
  282.                 $post->setMedia(null);
  283.             }
  284.         }
  285.         return $this;
  286.     }
  287.     /**
  288.      * @return Collection|MediaTeam[]
  289.      */
  290.     public function getTeams(): Collection
  291.     {
  292.         return $this->teams;
  293.     }
  294.     public function addTeam(MediaTeam $team): self
  295.     {
  296.         if (!$this->teams->contains($team)) {
  297.             $this->teams[] = $team;
  298.             $team->setMedia($this);
  299.         }
  300.         return $this;
  301.     }
  302.     public function removeTeam(MediaTeam $team): self
  303.     {
  304.         if ($this->teams->contains($team)) {
  305.             $this->teams->removeElement($team);
  306.             // set the owning side to null (unless already changed)
  307.             if ($team->getMedia() === $this) {
  308.                 $team->setMedia(null);
  309.             }
  310.         }
  311.         return $this;
  312.     }
  313.     public function getCreatedBy(): ?User
  314.     {
  315.         return $this->createdBy;
  316.     }
  317.     public function setCreatedBy(?User $createdBy): self
  318.     {
  319.         $this->createdBy $createdBy;
  320.         return $this;
  321.     }
  322.     public function getType(): ?string
  323.     {
  324.         return $this->type;
  325.     }
  326.     public function setType(?string $type): self
  327.     {
  328.         $this->type $type;
  329.         return $this;
  330.     }
  331.     public function getCategory(): ?string
  332.     {
  333.         return $this->category;
  334.     }
  335.     public function setCategory(?string $category): self
  336.     {
  337.         $this->category $category;
  338.         return $this;
  339.     }
  340.     public function getZones(): ?array
  341.     {
  342.         return $this->zones;
  343.     }
  344.     public function setZones(?array $zones): self
  345.     {
  346.         $this->zones $zones;
  347.         return $this;
  348.     }
  349.     public function getLanguages(): ?array
  350.     {
  351.         return $this->languages;
  352.     }
  353.     public function setLanguages(?array $languages): self
  354.     {
  355.         $this->languages $languages;
  356.         return $this;
  357.     }
  358.     public function getNbrFollowers(): ?int
  359.     {
  360.         return $this->nbrFollowers;
  361.     }
  362.     public function setNbrFollowers(int $nbrFollowers): self
  363.     {
  364.         $this->nbrFollowers $nbrFollowers;
  365.         return $this;
  366.     }
  367.     public function getScore(): ?int
  368.     {
  369.         return $this->score;
  370.     }
  371.     public function setScore(int $score): self
  372.     {
  373.         $this->score $score;
  374.         return $this;
  375.     }
  376.     /**
  377.      * @return Collection|Chats[]
  378.      */
  379.     public function getChats(): Collection
  380.     {
  381.         return $this->chats;
  382.     }
  383.     public function addChat(Chats $chat): self
  384.     {
  385.         if (!$this->chats->contains($chat)) {
  386.             $this->chats[] = $chat;
  387.             $chat->setMedia($this);
  388.         }
  389.         return $this;
  390.     }
  391.     public function removeChat(Chats $chat): self
  392.     {
  393.         if ($this->chats->removeElement($chat)) {
  394.             // set the owning side to null (unless already changed)
  395.             if ($chat->getMedia() === $this) {
  396.                 $chat->setMedia(null);
  397.             }
  398.         }
  399.         return $this;
  400.     }
  401.     public function getNumberChatsNonLu(): ?int
  402.     {
  403.         return $this->numberChatsNonLu;
  404.     }
  405.     public function setNumberChatsNonLu(int $numberChatsNonLu): self
  406.     {
  407.         $this->numberChatsNonLu $numberChatsNonLu;
  408.         return $this;
  409.     }
  410.     /**
  411.      * @return Collection|Program[]
  412.      */
  413.     public function getPrograms(): Collection
  414.     {
  415.         return $this->programs;
  416.     }
  417.     public function addProgram(Program $program): self
  418.     {
  419.         if (!$this->programs->contains($program)) {
  420.             $this->programs[] = $program;
  421.             $program->setMedia($this);
  422.         }
  423.         return $this;
  424.     }
  425.     public function removeProgram(Program $program): self
  426.     {
  427.         if ($this->programs->contains($program)) {
  428.             $this->programs->removeElement($program);
  429.             // set the owning side to null (unless already changed)
  430.             if ($program->getMedia() === $this) {
  431.                 $program->setMedia(null);
  432.             }
  433.         }
  434.         return $this;
  435.     }
  436.     /**
  437.      * @param Collection|Program[] $programs
  438.      * @return $this
  439.      * Méthode used to set the list of program only to show this in twig for the user is crewMember
  440.      * Do not use this to persist in dataBase
  441.      */
  442.     public function setPrograms($programs): self
  443.     {
  444.         $this->programs $programs;
  445.         return $this;
  446.     }
  447.     /**
  448.      * @return Collection|Shortcut[]
  449.      */
  450.     public function getShortcuts(): Collection
  451.     {
  452.         return $this->shortcuts;
  453.     }
  454.     public function addShortcut(Shortcut $shortcut): self
  455.     {
  456.         if (!$this->shortcuts->contains($shortcut)) {
  457.             $this->shortcuts[] = $shortcut;
  458.             $shortcut->setMedia($this);
  459.         }
  460.         return $this;
  461.     }
  462.     public function removeShortcut(Shortcut $shortcut): self
  463.     {
  464.         if ($this->shortcuts->removeElement($shortcut)) {
  465.             // set the owning side to null (unless already changed)
  466.             if ($shortcut->getMedia() === $this) {
  467.                 $shortcut->setMedia(null);
  468.             }
  469.         }
  470.         return $this;
  471.     }
  472.     public function getNumberParticipation(): ?int
  473.     {
  474.         return $this->numberParticipation;
  475.     }
  476.     public function setNumberParticipation(int $numberParticipation): self
  477.     {
  478.         $this->numberParticipation $numberParticipation;
  479.         return $this;
  480.     }
  481.     public function getTel(): ?string
  482.     {
  483.         return $this->tel;
  484.     }
  485.     public function setTel(?string $tel): self
  486.     {
  487.         $this->tel $tel;
  488.         return $this;
  489.     }
  490.     public function getAddress(): ?string
  491.     {
  492.         return $this->address;
  493.     }
  494.     public function setAddress(?string $address): self
  495.     {
  496.         $this->address $address;
  497.         return $this;
  498.     }
  499.     public function getCountry(): ?string
  500.     {
  501.         return $this->country;
  502.     }
  503.     public function setCountry(string $country): self
  504.     {
  505.         $this->country $country;
  506.         return $this;
  507.     }
  508.     public function getCity(): ?string
  509.     {
  510.         return $this->city;
  511.     }
  512.     public function setCity(?string $city): self
  513.     {
  514.         $this->city $city;
  515.         return $this;
  516.     }
  517.     public function getDynamicLink(): ?string
  518.     {
  519.         return $this->dynamicLink;
  520.     }
  521.     public function setDynamicLink(?string $dynamicLink): self
  522.     {
  523.         $this->dynamicLink $dynamicLink;
  524.         return $this;
  525.     }
  526.     public function getShortDynamicLink(): ?string
  527.     {
  528.         return $this->shortDynamicLink;
  529.     }
  530.     public function setShortDynamicLink(?string $shortDynamicLink): self
  531.     {
  532.         $this->shortDynamicLink $shortDynamicLink;
  533.         return $this;
  534.     }
  535.     public function getLevel(): ?int
  536.     {
  537.         return $this->level;
  538.     }
  539.     public function setLevel(int $level): self
  540.     {
  541.         $this->level $level;
  542.         return $this;
  543.     }
  544.     /**
  545.      * @return Collection|MediaEarning[]
  546.      */
  547.     public function getMediaEarnings(): Collection
  548.     {
  549.         return $this->mediaEarnings;
  550.     }
  551.     public function addMediaEarning(MediaEarning $mediaEarning): self
  552.     {
  553.         if (!$this->mediaEarnings->contains($mediaEarning)) {
  554.             $this->mediaEarnings[] = $mediaEarning;
  555.             $mediaEarning->setMedia($this);
  556.         }
  557.         return $this;
  558.     }
  559.     public function removeMediaEarning(MediaEarning $mediaEarning): self
  560.     {
  561.         if ($this->mediaEarnings->removeElement($mediaEarning)) {
  562.             // set the owning side to null (unless already changed)
  563.             if ($mediaEarning->getMedia() === $this) {
  564.                 $mediaEarning->setMedia(null);
  565.             }
  566.         }
  567.         return $this;
  568.     }
  569. }