<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Annotation\ApiSubresource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\BooleanFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Serializer\Filter\GroupFilter;
use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
use ApiPlatform\Core\Annotation\ApiProperty;
use App\Annotation\Exclusions;
use App\Repository\VideoRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=VideoRepository::class)
* @ApiResource(
* normalizationContext={
* "groups"={"video:read"}
* },
* denormalizationContext={
* "groups"={"video:write"}
* },
* collectionOperations={
* "get"={"security"="is_granted('ROLE_USER')"},
* "post"={"security"="is_granted('ROLE_ADMIN')"},
* "addFavoriteVideo"={
* "description"="Add video to favorite's list User",
* "path"="/videos/{id}/favorite/add",
* "method"="POST",
* "controller"="App\Controller\Api\VideoController::addFavoriteVideo",
* "deserialize"=false,
* "security"="is_granted('ROLE_CLIENT')"
* },
* "removeFavoriteVideo"={
* "description"="Delete video to favorite's list User",
* "path"="/videos/{id}/favorite/remove",
* "method"="POST",
* "controller"="App\Controller\Api\VideoController::removeFavoriteVideo",
* "deserialize"=false,
* "security"="is_granted('ROLE_CLIENT')"
* },
* "post_update"={
* "security"="is_granted('ROLE_ADMIN')",
* "path"="/videos/{id}",
* "description"="Update a Video with method POST (using content-type: 'multipart')",
* "method"="POST",
* "controller"="App\Controller\Api\VideoController::update"
* },
* "vitality_balance_recommended_videos_by_client"={
* "description"="Get vitality balance recommended videos by client.",
* "path"="/clients/{id}/vitality-balance/recommended-videos",
* "method"="GET",
* "controller"="App\Controller\Api\VitalityBalanceController::getVitalityBalanceRecommandedVideosByClient",
* "security"="is_granted('ROLE_CLIENT')"
* },
* "get_favorite_videos_by_user"={
* "description"="Get favorite videos by user.",
* "path"="/users/{id}/favorite-videos",
* "method"="GET",
* "controller"="App\Controller\Api\VideoController::getFavoriteVideosByUser",
* "security"="is_granted('ROLE_CLIENT')"
* },
* "get_last_seen_videos_by_user"={
* "description"="Get last seen videos by user.",
* "path"="/users/{id}/last-seen-videos",
* "method"="GET",
* "controller"="App\Controller\Api\VideoController::getLastSeenVideosByUser",
* "security"="is_granted('ROLE_CLIENT')"
* },
* "get_videos_by_day"={
* "description"="Get videos by day.",
* "path"="/days/{id}/videos",
* "method"="GET",
* "controller"="App\Controller\Api\VideoController::getVideosByDay",
* "security"="is_granted('ROLE_CLIENT')"
* },
* "add_video_to_user_playlists"={
* "description"="Add video to User playlists",
* "path"="/users/{user}/videos/{id}/user-playlists",
* "method"="POST",
* "controller"="App\Controller\Api\VideoController::addVideoToUserPlaylists",
* "deserialize"=false,
* "security"="is_granted('ROLE_CLIENT')"
* }
* },
* itemOperations={
* "get"={"security"="is_granted('VIDEO_GET', object)"},
* "patch_video"={
* "method"="PATCH",
* "security"="is_granted('ROLE_USER')",
* "path"="/videos/{id}",
* "controller"="App\Controller\Api\VideoController::patchVideo",
* "input_formats"={"json"={"application/merge-patch+json"}}
* },
* "delete"={"security"="is_granted('ROLE_ADMIN')"}
* }
* )
* @ApiFilter(OrderFilter::class, properties={"code", "reference", "id", "name", "status", "active", "duration", "url"})
* @ApiFilter(SearchFilter::class, properties={"name": "partial", "status", "reference": "partial", "playlists.id"})
* @ApiFilter(BooleanFilter::class, properties={"active"})
* @ApiFilter(GroupFilter::class, arguments={"parameterName": "groups", "overrideDefaultGroups": true, "whitelist": {
* "homepage:read", "video_list", "video_form_complete", "video_form", "video_tech_infos"
* }})
* @ApiFilter(PropertyFilter::class,
* arguments={
* "parameterName"="fields",
* "overrideDefaultProperties"=true
* }
* )
* @ORM\HasLifecycleCallbacks()
* @Exclusions(exclusionsClass="App\Entity\ExclusionsVideo", property="exclusionsVideos")
*/
class Video
{
const NEW = 'new_vimeo';
const ONLINE = 'online';
const OFFLINE = 'offline';
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"video:read", "video:read:id", "homepage:read", "playlist:read", "stats", "day:read", "expert:read", "channel:read",
* "search_engine", "objective:read", "slide:read", "filters_filter:read", "filters_category:read",
* "video_list", "video_form_complete", "video_form", "objective:read", "video_tech_infos",
* "teamplay_challenge:read", "program:read"
* })
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"channel:read", "homepage:read", "video:read", "video:read:name", "video:write", "playlist:read", "video_tip:read",
* "stats", "expert:read", "day:read", "search_engine", "objective:read", "slide:read", "filters_filter:read", "filters_category:read",
* "program_single_list", "video_list", "video_form_complete", "video_form", "objective:read", "objective_form_complete", "answer_recommended_objectives_edit",
* "teamplay_challenge:read", "program:read"
* })
* @Assert\NotBlank
* @Assert\NotNull
*/
private $name;
/**
* @ORM\Column(type="text", nullable=true)
* @Groups({"channel:read", "homepage:read", "video:read", "video:read:description", "video:write", "expert:read", "day:read", "slide:read",
* "filters_filter:read", "filters_category:read", "video_form_complete", "teamplay_challenge:read", "program:read"})
*/
private $description;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"channel:read", "homepage:read", "video:read", "video:read:url", "channel:read", "video:write", "day:read",
* "search_engine", "objective:read", "filters_filter:read", "filters_category:read", "video_list", "video_form_complete", "teamplay_challenge:read", "program:read"})
* @Assert\NotBlank
* @Assert\NotNull
*/
private $url;
/**
* @ORM\Column(type="integer")
* @Groups({"channel:read", "homepage:read", "video:read", "video:read:duration", "day:read", "slide:read", "search_engine", "objective:read",
* "filters_filter:read", "filters_category:read", "video_list", "video_form_complete", "teamplay_challenge:read", "program:read"})
*/
private $duration;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"video:read", "video:read:code", "day:read", "search_engine", "objective:read", "filters_filter:read", "filters_category:read", "video_list", "teamplay_challenge:read", "program:read"})
*/
private $code;
/**
* @ORM\Column(type="boolean", options={"default": 1})
* @Groups({"video:read", "video:read:active", "video:write", "filters_filter:read", "filters_category:read", "video_list",
* "video_form_complete", "teamplay_challenge:read", "program:read"
* })
*/
private $active = true;
/**
* @ORM\Column(type="datetime")
* @Groups({"video:read", "video:read:createdAt", "video_form_complete", "program:read"})
* @Gedmo\Timestampable(on="create")
*/
private $createdAt;
/**
* @var bool
*/
public $populated = false;
/**
* @ORM\ManyToMany(targetEntity=TvTag::class)
* @Groups({"video:read", "video:read:tvTags", "video:write", "day:read", "video_form_complete", "program:read"})
*/
private $tvTags;
/**
* @ORM\OneToMany(targetEntity=VideoEvent::class, mappedBy="video", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
* @ApiSubresource(maxDepth=1)
*/
private $videoEvents;
/**
* @ORM\ManyToOne(targetEntity=MediaObject::class)
* @Groups({"channel:read", "homepage:read", "video:read", "video:read:preview", "video:write", "stats", "expert:read",
* "day:read", "search_engine", "objective:read", "filters_filter:read", "filters_category:read", "video_form_complete",
* "teamplay_challenge:read", "program:read"
* })
*/
private $preview;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"video:read", "video:read:status", "video_list", "video_form_complete", "program:read"})
*/
private $status = self::NEW;
/**
* @ORM\ManyToMany(targetEntity=Expert::class, inversedBy="videos")
* @Groups({"channel:read", "homepage:read", "video:read", "video:read:experts", "video:write", "day:read", "slide:read", "search_engine", "objective:read",
* "filters_filter:read", "filters_category:read", "video_form_complete", "teamplay_challenge:read", "program:read"})
* @ApiSubresource(maxDepth=1)
*/
private $experts;
/**
* @ORM\ManyToOne(targetEntity=MediaObject::class)
* @Groups({"channel:read", "video:read", "video:read:picture", "video:write", "stats", "day:read", "search_engine", "objective:read", "slide:read",
* "slide:read", "filters_filter:read", "filters_category:read", "video_form_complete", "teamplay_challenge:read", "program:read"
* })
*/
private $picture;
/**
* @ORM\ManyToOne(targetEntity=MediaObject::class)
* @Groups({"video:read", "video:read:tip", "video:write", "day:read", "search_engine", "objective:read", "homepage:read", "filters_filter:read",
* "filters_category:read", "video_form_complete","teamplay_challenge:read", "program:read"
* })
* @ApiSubresource(maxDepth=1)
*/
private $tip;
/**
* @ORM\Column(type="text", nullable=true)
* @Groups({"video:read", "video:read:shortDescription", "homepage:read", "video:write", "day:read", "search_engine", "objective:read", "slide:read",
* "filters_filter:read", "filters_category:read", "video_form_complete", "teamplay_challenge:read", "program:read"
* })
*/
private $shortDescription;
/**
* @var array|null
* @Groups({"video:read", "video:read:linkedTo", "search_engine", "objective:read", "slide:read", "day:read"})
*/
public $linkedTo = null;
/**
* @var int|null
* @Groups({"video:read", "video:read:lastTimecode", "search_engine", "objective:read", "homepage:read", "filters_filter:read", "filters_category:read", "teamplay_challenge:read", "program:read"})
*/
public $lastTimecode = null;
/**
* @ORM\ManyToMany(targetEntity=Playlist::class, mappedBy="videos")
*/
private $playlists;
/**
* @ApiProperty(security="is_granted('ROLE_ADMIN')", securityPostDenormalize= "is_granted('UPDATE', object)")
* @Groups({"video:write", "video:read", "video:read:playlistsChannel", "video_form_complete"})
*/
private $playlistsChannel = [];
/**
* A conserver elle est utilisée en interne
* @var Playlist[]
*/
private $playlistsDay = [];
/**
* A conserver elle est utilisée en interne
* @var Playlist[]
*/
private $playlistsUser = [];
/**
* @ORM\ManyToOne(targetEntity=Channel::class, inversedBy="defaultVideos")
* @Groups({"video:read", "video:read:defaultChannel", "search_engine", "slide:read", "day:read", "video:write", "stats",
* "filters_filter:read", "filters_category:read", "program_single_list", "video_list", "video_form_complete",
* "teamplay_challenge:read", "program:read"
* })
*/
private $defaultChannel;
/**
* @ORM\Column(type="boolean", options={"default": 1})
* @Groups({"channel:read", "homepage:read", "video:read", "video:read:forthcoming", "video:write", "playlist:read", "video_tip:read",
* "stats", "expert:read", "day:read", "search_engine", "objective:read", "slide:read", "filters_filter:read",
* "filters_category:read", "video_form_complete", "teamplay_challenge:read"
* })
*/
private $forthcoming = 1;
/**
* @ORM\OneToMany(targetEntity=ExclusionsVideo::class, mappedBy="video", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
* @Groups({"video:read", "video:read:exclusionsVideos", "video:write", "video_form_complete"})
*/
private $exclusionsVideos;
/**
* @ORM\OneToMany(targetEntity=Notation::class, mappedBy="video", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
*/
private $notations;
/**
* @var int|null
* @Groups({"single_channel:read", "channel:read", "category:read", "video:read", "video:read:rate", "video:write", "playlist:read", "video_tip:read", "stats", "expert:read", "day:read", "search_engine", "objective:read", "slide:read", "filters_filter:read", "filters_category:read"})
*/
public $rate = null;
/**
* @var int|null
* @Groups({"single_channel:read", "channel:read", "category:read", "video:read", "video:read:rateQuality", "video:write", "playlist:read", "video_tip:read", "stats", "expert:read", "day:read", "search_engine", "objective:read", "slide:read", "filters_filter:read", "filters_category:read"})
*/
public $rateQuality = null;
/**
* @var int|null
* @Groups({"single_channel:read", "channel:read", "category:read", "video:read", "video:read:rateExpert", "video:write", "playlist:read", "video_tip:read", "stats", "expert:read", "day:read", "search_engine", "objective:read", "slide:read", "filters_filter:read", "filters_category:read"})
*/
public $rateExpert = null;
/**
* @var int|null
* @Groups({"single_channel:read", "channel:read", "homepage:read", "category:read", "video:read", "video:read:ratePresentation", "video:write", "playlist:read", "video_tip:read", "stats", "expert:read", "day:read", "search_engine", "objective:read", "slide:read"})
*/
public $ratePresentation = null;
/**
* @Groups({"single_channel:read", "channel:read", "video:read", "video:read:asRated", "category:read", "video:write", "playlist:read", "video_tip:read", "stats", "expert:read", "day:read", "search_engine", "objective:read", "slide:read", "filters_filter:read", "filters_category:read", "teamplay_challenge:read", "program:read"})
*/
public $asRated = false;
/**
* @Groups({"single_channel:read", "channel:read", "homepage:read", "video:read", "video:read:isFavorite", "category:read", "video:write", "playlist:read", "video_tip:read", "stats", "expert:read", "day:read", "search_engine", "objective:read", "slide:read", "filters_filter:read", "filters_category:read", "teamplay_challenge:read", "program:read"})
*/
public $isFavorite = false;
/**
* @ORM\Column(type="boolean", options={"default": 0})
* @Groups({"single_channel:read", "channel:read", "homepage:read", "video:read", "video:read:isRecipe", "category:read", "video:write",
* "playlist:read", "video_tip:read", "stats", "expert:read", "day:read", "search_engine", "objective:read", "slide:read", "filters_filter:read",
* "filters_category:read", "video_form_complete", "teamplay_challenge:read", "program:read"})
*/
private $isRecipe = false;
/**
* @var int|null
* @Groups({"single_channel:read", "channel:read", "homepage:read", "video:read", "video:read:rank", "category:read", "video:write", "playlist:read", "video_tip:read", "stats", "expert:read", "day:read", "search_engine", "objective:read", "slide:read", "filters_filter:read", "filters_category:read"})
*/
public $rank = null;
/**
* @var bool
* @Groups({"video:read", "video:read:isFree"})
*/
public $isFree = false;
/**
* @var int
* @Groups({"video:read", "video:read:channelVideosCount"})
*/
public $channelVideosCount = null;
/**
* @var array
* @Groups({"video:read", "video:read:videosBottom"})
*/
public $videosBottom = null;
/**
* @ORM\ManyToMany(targetEntity=FiltersFilter::class, inversedBy="videos")
* @Groups({"single_channel:read", "channel:read", "homepage:read", "video:read", "video:read:filters", "category:read", "video:write",
* "playlist:read", "video_tip:read", "stats", "expert:read", "day:read", "search_engine", "objective:read", "slide:read", "video_form_complete"})
*/
private $filters;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"single_channel:read", "channel:read", "homepage:read", "video:read", "video:read:reference", "category:read","video:write",
* "playlist:read", "video_tip:read", "stats", "expert:read", "day:read", "search_engine", "objective:read", "slide:read",
* "video_form_complete"})
*/
private $reference;
/**
* @var array|null
* @Groups({"video:read", "video:read:moodAfterPostResponses", "video_form_complete"})
*/
public $moodAfterPostResponses = null;
/**
* @Groups({"single_channel:read", "channel:read", "homepage:read", "video:read", "video:read:flags", "category:read",
* "playlist:read", "video_tip:read", "stats", "expert:read", "day:read", "search_engine", "objective:read", "slide:read"})
*/
public $flags = null;
/**
* @ORM\Column(type="text", nullable=true)
* @Groups({"video:read", "video:read:stringifyTags"})
*/
private $stringifyTags = '';
/**
* @var bool
* @Groups({"video_list"})
*/
public $excluded = false;
/**
* @Groups({"single_channel:read", "channel:read", "homepage:read", "video:read", "video:read:awardOperations", "category:read",
* "playlist:read", "video_tip:read", "stats", "expert:read", "day:read", "search_engine", "objective:read", "slide:read"})
*/
public $awardOperations = null;
/**
* @ORM\Column(type="json", nullable=true)
* @Groups({"video_tech_infos"})
*/
private $srcLinks = [];
/**
* @ORM\Column(type="boolean", options={"default": 0})
* @Groups({"single_channel:read", "channel:read", "homepage:read", "video:read", "video:read:public", "video:write", "category:read",
* "playlist:read", "video_tip:read", "stats", "expert:read", "day:read", "search_engine", "objective:read", "slide:read",
* "video_form_complete", "teamplay_challenge:read", "program:read"
* })
*/
private $public = false;
/**
* @ORM\OneToMany(targetEntity=Favorite::class, mappedBy="video", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $favorites;
/**
* @ORM\OneToMany(targetEntity=UserVideoTimecode::class, mappedBy="video", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $userVideoTimecodes;
/**
* @ORM\OneToMany(targetEntity=VideoLastValidate::class, mappedBy="video", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
*/
private $videoLastValidates;
/**
* @ORM\OneToMany(targetEntity=VideoLastSeen::class, mappedBy="video", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
*/
private $videoLastSeens;
/**
* @ORM\OneToMany(targetEntity=TeamplayChallenge::class, mappedBy="video", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
*/
private $teamplayChallenges;
/**
* @ORM\Column(type="boolean", options={"default": 0})
* @Groups({"video:read", "video:read:itCanInterrest", "video:write"})
*/
private $itCanInterrest = false;
/**
* @ORM\Column(type="datetime", nullable=true)
* @Groups({"video:read", "video:read:updatedAt", "video_form_complete"})
* @Gedmo\Timestampable(on="update")
*/
private $updatedAt;
/**
* Custom fields
* @Groups({"video:read", "video:read:userPlaylists", "video:write", "teamplay_challenge:read", "program:read"})
*/
private $userPlaylists = null;
public function __construct()
{
$this->tvTags = new ArrayCollection();
$this->videoEvents = new ArrayCollection();
$this->experts = new ArrayCollection();
$this->playlists = new ArrayCollection();
$this->exclusionsVideos = new ArrayCollection();
$this->notations = new ArrayCollection();
$this->isRecipe = 0;
$this->filters = new ArrayCollection();
$this->public = false;
$this->favorites = new ArrayCollection();
$this->userVideoTimecodes = new ArrayCollection();
$this->videoLastValidates = new ArrayCollection();
$this->videoLastSeens = new ArrayCollection();
$this->teamplayChallenges = new ArrayCollection();
$this->playlistsUser = [];
}
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 getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getUrl(): ?string
{
return $this->url;
}
public function setUrl(string $url): self
{
$this->url = $url;
return $this;
}
public function getDuration(): ?int
{
return $this->duration;
}
public function setDuration(int $duration): self
{
$this->duration = $duration;
return $this;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(string $code): self
{
$this->code = $code;
return $this;
}
public function getActive(): ?bool
{
return $this->active;
}
public function setActive(bool $active): self
{
if ($active) {
$this->status = self::ONLINE;
} elseif ($this->status !== self::NEW) {
$this->status = self::OFFLINE;
}
$this->active = $active;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
/**
* @return Collection|TvTag[]
*/
public function getTvTags(): Collection
{
return $this->tvTags;
}
/**
* @return Video
* @Groups({"video:write"})
*/
public function setTvTags(Collection $tvTags): self
{
$this->tvTags = $tvTags;
foreach ($this->tvTags as $tvTag) {
$this->stringifyTags .= "#".$tvTag->getName();
}
return $this;
}
public function addTvTag(TvTag $tvTag): self
{
if (!$this->tvTags->contains($tvTag)) {
$this->tvTags[] = $tvTag;
}
return $this;
}
public function removeTvTag(TvTag $tvTag): self
{
$this->tvTags->removeElement($tvTag);
return $this;
}
/**
* @return Collection|VideoEvent[]
*/
public function getVideoEvents(): Collection
{
return $this->videoEvents;
}
public function addVideoEvent(VideoEvent $videoEvent): self
{
if (!$this->videoEvents->contains($videoEvent)) {
$this->videoEvents[] = $videoEvent;
$videoEvent->setVideo($this);
}
return $this;
}
public function removeVideoEvent(VideoEvent $videoEvent): self
{
if ($this->videoEvents->removeElement($videoEvent)) {
// set the owning side to null (unless already changed)
if ($videoEvent->getVideo() === $this) {
$videoEvent->setVideo(null);
}
}
return $this;
}
public function getPreview(): ?MediaObject
{
return $this->preview;
}
public function setPreview(?MediaObject $preview): self
{
$this->preview = $preview;
return $this;
}
/**
* @Groups({"video:write"})
*/
public function setPreviewFile($file = null): self
{
if($file instanceof UploadedFile) {
$preview = empty($this->preview) ? new MediaObject : $this->preview;
$preview->setFile($file);
$this->setPreview($preview);
}
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(string $status): self
{
$this->status = $status;
return $this;
}
/**
* @return Collection|Expert[]
*/
public function getExperts(): Collection
{
return $this->experts;
}
public function addExpert(Expert $expert): self
{
if (!$this->experts->contains($expert)) {
$this->experts[] = $expert;
}
return $this;
}
public function removeExpert(Expert $expert): self
{
$this->experts->removeElement($expert);
return $this;
}
public function getPicture(): ?MediaObject
{
return $this->picture;
}
public function setPicture(?MediaObject $picture): self
{
$this->picture = $picture;
return $this;
}
/**
* @Groups({"video:write"})
*/
public function setPictureFile($file = null): self
{
if($file instanceof UploadedFile) {
$picture = empty($this->picture) ? new MediaObject : $this->picture;
$picture->setFile($file);
$this->setPicture($picture);
}
return $this;
}
public function getTip(): ?MediaObject
{
return $this->tip;
}
public function setTip(?MediaObject $tip): self
{
$this->tip = $tip;
return $this;
}
/**
* @Groups({"video:write"})
*/
public function setTipFile($file = null): self
{
if($file instanceof UploadedFile) {
$tip = empty($this->tip) ? new MediaObject : $this->tip;
$tip->setFile($file);
$this->setTip($tip);
}
return $this;
}
public function getShortDescription(): ?string
{
return $this->shortDescription;
}
/**
* @return array|null
* @Groups({"channel:read", "homepage:read", "video:read", "video:read:splitName", "video:write", "playlist:read", "video_tip:read",
* "stats", "expert:read", "day:read", "search_engine", "objective:read", "slide:read", "filters_filter:read", "filters_category:read",
* "program_single_list", "video_list"})
*/
public function getSplitName(): ?array
{
return (is_string($this->name))?
array_map(function ($elem){return trim($elem);}, explode('|', $this->name))
:$this->name;
}
/**
* @return string|null
* @Groups({"channel:read", "homepage:read", "video:read", "video:read:managedName", "video:write", "playlist:read", "video_tip:read",
* "stats", "expert:read", "day:read", "search_engine", "objective:read", "slide:read", "filters_filter:read", "filters_category:read"})
*/
public function getManagedName(): ?string
{
return (is_string($this->name)) ? trim(str_replace('|', ' ', $this->name)) : $this->name;
}
public function setShortDescription(?string $shortDescription): self
{
$this->shortDescription = $shortDescription;
return $this;
}
/**
* @return Collection|Playlist[]
*/
public function getPlaylists(): Collection
{
return $this->playlists;
}
/**
* @return Video
*/
public function setPlaylists($playlists): self
{
if(is_array($playlists)) {
$playlists = new ArrayCollection($playlists);
}
if($playlists instanceof ArrayCollection) {
$this->playlists = $playlists;
}
return $this;
}
public function addPlaylist(Playlist $playlist): self
{
if (!$this->playlists->contains($playlist)) {
$this->playlists[] = $playlist;
}
return $this;
}
public function removePlaylist(Playlist $playlist): self
{
$this->playlists->removeElement($playlist);
return $this;
}
/**
* @Groups({"video:write"})
*/
public function setAddPlaylists($playlists): self
{
foreach ($playlists as $playlist) {
if($playlist instanceof Playlist) {
$this->addPlaylist($playlist);
}
}
return $this;
}
/**
* @Groups({"video:write"})
*/
public function setRemovePlaylists($playlists): self
{
foreach ($playlists as $playlist) {
if($playlist instanceof Playlist) {
$this->removePlaylist($playlist);
}
}
return $this;
}
/**
* @return Playlist[]
*/
public function getPlaylistsChannel(): ?array
{
$playlistsChannel = new ArrayCollection;
// Parcourir toute les playlists
// Si la video est dans cette playlist, l'ajouter à la variable
// Si la playlist est lié a un channel
foreach ($this->playlists as $playlist) {
if($playlist->getChannels()->count() > 0){
foreach ($playlist->getChannels() as $channel) {
if(!$playlistsChannel->contains($playlist)) {
$playlistsChannel->add($playlist);
}
}
}
}
$this->playlistsChannel = $playlistsChannel->toArray();
return $this->playlistsChannel;
}
/**
* @param Playlist[] $playlistsChannel
* @return Video
*/
public function setPlaylistsChannel(?array $playlistsChannel): self
{
$this->playlistsChannel = $playlistsChannel;
return $this;
}
/**
* @return Playlist[]
*/
public function getPlaylistsDay(): ?array
{
return $this->playlistsDay;
}
/**
* @param Playlist[] $playlistsDay
* @return Video
*/
public function setPlaylistsDay(?array $playlistsDay): Video
{
$this->playlistsDay = $playlistsDay;
return $this;
}
/**
* @return Playlist[]
*/
public function getPlaylistsUser(): ?array
{
return $this->playlistsUser;
}
/**
* @param Playlist[] $playlistsUser
* @return Video
*/
public function setPlaylistsUser(?array $playlistsUser): Video
{
$this->playlistsUser = $playlistsUser;
return $this;
}
public function getDefaultChannel(): ?Channel
{
return $this->defaultChannel;
}
public function setDefaultChannel(?Channel $defaultChannel): self
{
$this->defaultChannel = $defaultChannel;
return $this;
}
public function getForthcoming(): ?bool
{
return $this->forthcoming;
}
public function setForthcoming(bool $forthcoming): self
{
$this->forthcoming = $forthcoming;
return $this;
}
/**
* @return Collection|Notation[]
*/
public function getNotations(): Collection
{
return $this->notations;
}
public function addNotation(Notation $notation): self
{
if (!$this->notations->contains($notation)) {
$this->notations[] = $notation;
$notation->setVideo($this);
}
return $this;
}
public function removeNotation(Notation $notation): self
{
if ($this->notations->removeElement($notation)) {
// set the owning side to null (unless already changed)
if ($notation->getVideo() === $this) {
$notation->setVideo(null);
}
}
return $this;
}
/**
* @return Collection|ExclusionsVideo[]
*/
public function getExclusionsVideos(): Collection
{
return $this->exclusionsVideos;
}
public function addExclusionsVideo(ExclusionsVideo $exclusionsVideo): self
{
if (!$this->exclusionsVideos->contains($exclusionsVideo)) {
$this->exclusionsVideos[] = $exclusionsVideo;
$exclusionsVideo->setVideo($this);
}
return $this;
}
public function removeExclusionsVideo(ExclusionsVideo $exclusionsVideo): self
{
if ($this->exclusionsVideos->removeElement($exclusionsVideo)) {
// set the owning side to null (unless already changed)
if ($exclusionsVideo->getVideo() === $this) {
$exclusionsVideo->setVideo(null);
}
}
return $this;
}
public function getIsRecipe(): ?bool
{
return $this->isRecipe;
}
public function setIsRecipe(bool $isRecipe): self
{
$this->isRecipe = $isRecipe;
return $this;
}
/**
* @return Collection|FiltersFilter[]
*/
public function getFilters(): Collection
{
return $this->filters;
}
public function addFilter(FiltersFilter $filter): self
{
if (!$this->filters->contains($filter)) {
$this->filters[] = $filter;
}
return $this;
}
public function removeFilter(FiltersFilter $filter): self
{
$this->filters->removeElement($filter);
return $this;
}
public function getReference(): ?string
{
return $this->reference;
}
public function setReference(?string $reference): self
{
$this->reference = $reference;
return $this;
}
public function getStringifyTags(): ?string
{
return $this->stringifyTags;
}
public function setStringifyTags(?string $stringifyTags): self
{
$this->stringifyTags = $stringifyTags;
return $this;
}
public function getTvTagsName(): array
{
$tvTags = [];
foreach ($this->tvTags as $tvTag) {
if(!in_array($tvTag->getName(), $tvTags)) $tvTags[] = $tvTag->getName();
}
return $tvTags;
}
/**
* @return bool
*/
public function isExcluded(): bool
{
return $this->excluded;
}
/**
* @param bool $excluded
* @return Video
*/
public function setExcluded(bool $excluded): Video
{
$this->excluded = $excluded;
return $this;
}
public function getSrcLinks(): ?array
{
return $this->srcLinks;
}
public function setSrcLinks(?array $srcLinks): self
{
$this->srcLinks = $srcLinks;
return $this;
}
public function getPublic(): ?bool
{
return $this->public;
}
public function setPublic(bool $public): self
{
$this->public = $public;
return $this;
}
/**
* @return Collection|Favorite[]
*/
public function getFavorites(): Collection
{
return $this->favorites;
}
public function addFavorite(Favorite $favorite): self
{
if (!$this->favorites->contains($favorite)) {
$this->favorites[] = $favorite;
}
return $this;
}
public function removeFavorite(Favorite $favorite): self
{
$this->favorites->removeElement($favorite);
return $this;
}
/**
* @return Collection|UserVideoTimecode[]
*/
public function getUserVideoTimecodes(): Collection
{
return $this->userVideoTimecodes;
}
public function addUserVideoTimecode(UserVideoTimecode $userVideoTimecode): self
{
if (!$this->userVideoTimecodes->contains($userVideoTimecode)) {
$this->userVideoTimecodes[] = $userVideoTimecode;
$userVideoTimecode->setVideo($this);
}
return $this;
}
public function removeUserVideoTimecode(UserVideoTimecode $userVideoTimecode): self
{
if ($this->userVideoTimecodes->removeElement($userVideoTimecode)) {
// set the owning side to null (unless already changed)
if ($userVideoTimecode->getVideo() === $this) {
$userVideoTimecode->setVideo(null);
}
}
return $this;
}
/**
* @return Collection|VideoLastValidate[]
*/
public function getVideoLastValidates(): Collection
{
return $this->videoLastValidates;
}
public function addVideoLastValidate(VideoLastValidate $videoLastValidate): self
{
if (!$this->videoLastValidates->contains($videoLastValidate)) {
$this->videoLastValidates[] = $videoLastValidate;
$videoLastValidate->setVideo($this);
}
return $this;
}
public function removeVideoLastValidate(VideoLastValidate $videoLastValidate): self
{
if ($this->videoLastValidates->removeElement($videoLastValidate)) {
// set the owning side to null (unless already changed)
if ($videoLastValidate->getVideo() === $this) {
$videoLastValidate->setVideo(null);
}
}
return $this;
}
/**
* @return Collection|VideoLastSeen[]
*/
public function getVideoLastSeens(): Collection
{
return $this->videoLastSeens;
}
public function addVideoLastSeen(VideoLastSeen $videoLastSeen): self
{
if (!$this->videoLastSeens->contains($videoLastSeen)) {
$this->videoLastSeens[] = $videoLastSeen;
$videoLastSeen->setVideo($this);
}
return $this;
}
public function removeVideoLastSeen(VideoLastSeen $videoLastSeen): self
{
if ($this->videoLastSeens->removeElement($videoLastSeen)) {
// set the owning side to null (unless already changed)
if ($videoLastSeen->getVideo() === $this) {
$videoLastSeen->setVideo(null);
}
}
return $this;
}
/**
* @return Collection|TeamplayChallenge[]
*/
public function getTeamplayChallenges(): Collection
{
return $this->teamplayChallenges;
}
public function addTeamplayChallenge(TeamplayChallenge $teamplayChallenge): self
{
if (!$this->teamplayChallenges->contains($teamplayChallenge)) {
$this->teamplayChallenges[] = $teamplayChallenge;
$teamplayChallenge->setVideo($this);
}
return $this;
}
public function removeTeamplayChallenge(TeamplayChallenge $teamplayChallenge): self
{
if ($this->teamplayChallenges->removeElement($teamplayChallenge)) {
// set the owning side to null (unless already changed)
if ($teamplayChallenge->getVideo() === $this) {
$teamplayChallenge->setVideo(null);
}
}
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getItCanInterrest(): ?bool
{
return $this->itCanInterrest;
}
public function setItCanInterrest(bool $itCanInterrest): self
{
$this->itCanInterrest = $itCanInterrest;
return $this;
}
/**
* @return array|Playlist[]
*/
public function getUserPlaylists(): ?array
{
return $this->userPlaylists;
}
public function setUserPlaylists($userPlaylists): self
{
$this->userPlaylists = $userPlaylists;
return $this;
}
}