src/Entity/Video.php line 123

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use ApiPlatform\Core\Annotation\ApiSubresource;
  6. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\BooleanFilter;
  7. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
  8. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  9. use ApiPlatform\Core\Serializer\Filter\GroupFilter;
  10. use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
  11. use ApiPlatform\Core\Annotation\ApiProperty;
  12. use App\Annotation\Exclusions;
  13. use App\Repository\VideoRepository;
  14. use Doctrine\Common\Collections\ArrayCollection;
  15. use Doctrine\Common\Collections\Collection;
  16. use Doctrine\ORM\Mapping as ORM;
  17. use Gedmo\Mapping\Annotation as Gedmo;
  18. use Symfony\Component\HttpFoundation\File\UploadedFile;
  19. use Symfony\Component\Serializer\Annotation\Groups;
  20. use Symfony\Component\Validator\Constraints as Assert;
  21. /**
  22.  * @ORM\Entity(repositoryClass=VideoRepository::class)
  23.  * @ApiResource(
  24.  *     normalizationContext={
  25.  *         "groups"={"video:read"}
  26.  *     },
  27.  *     denormalizationContext={
  28.  *          "groups"={"video:write"}
  29.  *     },
  30.  *     collectionOperations={
  31.  *          "get"={"security"="is_granted('ROLE_USER')"},
  32.  *          "post"={"security"="is_granted('ROLE_ADMIN')"},
  33.  *          "addFavoriteVideo"={
  34.  *             "description"="Add video to favorite's list User",
  35.  *             "path"="/videos/{id}/favorite/add",
  36.  *             "method"="POST",
  37.  *             "controller"="App\Controller\Api\VideoController::addFavoriteVideo",
  38.  *             "deserialize"=false,
  39.  *             "security"="is_granted('ROLE_CLIENT')"
  40.  *          },
  41.  *          "removeFavoriteVideo"={
  42.  *             "description"="Delete video to favorite's list User",
  43.  *             "path"="/videos/{id}/favorite/remove",
  44.  *             "method"="POST",
  45.  *             "controller"="App\Controller\Api\VideoController::removeFavoriteVideo",
  46.  *             "deserialize"=false,
  47.  *             "security"="is_granted('ROLE_CLIENT')"
  48.  *          },
  49.  *          "post_update"={
  50.  *              "security"="is_granted('ROLE_ADMIN')",
  51.  *              "path"="/videos/{id}",
  52.  *              "description"="Update a Video with method POST (using content-type: 'multipart')",
  53.  *              "method"="POST",
  54.  *              "controller"="App\Controller\Api\VideoController::update"
  55.  *          },
  56.  *          "vitality_balance_recommended_videos_by_client"={
  57.  *             "description"="Get vitality balance recommended videos by client.",
  58.  *             "path"="/clients/{id}/vitality-balance/recommended-videos",
  59.  *             "method"="GET",
  60.  *             "controller"="App\Controller\Api\VitalityBalanceController::getVitalityBalanceRecommandedVideosByClient",
  61.  *             "security"="is_granted('ROLE_CLIENT')"
  62.  *          },
  63.  *          "get_favorite_videos_by_user"={
  64.  *             "description"="Get favorite videos by user.",
  65.  *             "path"="/users/{id}/favorite-videos",
  66.  *             "method"="GET",
  67.  *             "controller"="App\Controller\Api\VideoController::getFavoriteVideosByUser",
  68.  *             "security"="is_granted('ROLE_CLIENT')"
  69.  *          },
  70.  *          "get_last_seen_videos_by_user"={
  71.  *             "description"="Get last seen videos by user.",
  72.  *             "path"="/users/{id}/last-seen-videos",
  73.  *             "method"="GET",
  74.  *             "controller"="App\Controller\Api\VideoController::getLastSeenVideosByUser",
  75.  *             "security"="is_granted('ROLE_CLIENT')"
  76.  *          },
  77.  *          "get_videos_by_day"={
  78.  *             "description"="Get videos by day.",
  79.  *             "path"="/days/{id}/videos",
  80.  *             "method"="GET",
  81.  *             "controller"="App\Controller\Api\VideoController::getVideosByDay",
  82.  *             "security"="is_granted('ROLE_CLIENT')"
  83.  *          },
  84.  *          "add_video_to_user_playlists"={
  85.  *             "description"="Add video to User playlists",
  86.  *             "path"="/users/{user}/videos/{id}/user-playlists",
  87.  *             "method"="POST",
  88.  *             "controller"="App\Controller\Api\VideoController::addVideoToUserPlaylists",
  89.  *             "deserialize"=false,
  90.  *             "security"="is_granted('ROLE_CLIENT')"
  91.  *          }
  92.  *     },
  93.  *     itemOperations={
  94.  *          "get"={"security"="is_granted('VIDEO_GET', object)"},
  95.  *          "patch_video"={
  96.  *                  "method"="PATCH",
  97.  *                  "security"="is_granted('ROLE_USER')",
  98.  *                  "path"="/videos/{id}",
  99.  *                  "controller"="App\Controller\Api\VideoController::patchVideo",
  100.  *                  "input_formats"={"json"={"application/merge-patch+json"}}
  101.  *          },
  102.  *          "delete"={"security"="is_granted('ROLE_ADMIN')"}
  103.  *     }
  104.  * )
  105.  * @ApiFilter(OrderFilter::class, properties={"code", "reference", "id", "name", "status", "active", "duration", "url"})
  106.  * @ApiFilter(SearchFilter::class, properties={"name": "partial", "status", "reference": "partial", "playlists.id"})
  107.  * @ApiFilter(BooleanFilter::class, properties={"active"})
  108.  * @ApiFilter(GroupFilter::class, arguments={"parameterName": "groups", "overrideDefaultGroups": true, "whitelist": {
  109.  *      "homepage:read", "video_list", "video_form_complete", "video_form", "video_tech_infos"
  110.  * }})
  111.  * @ApiFilter(PropertyFilter::class, 
  112.  *      arguments={
  113.  *          "parameterName"="fields", 
  114.  *          "overrideDefaultProperties"=true
  115.  *     }
  116.  * )
  117.  * @ORM\HasLifecycleCallbacks()
  118.  * @Exclusions(exclusionsClass="App\Entity\ExclusionsVideo", property="exclusionsVideos")
  119.  */
  120. class Video
  121. {
  122.     const NEW = 'new_vimeo';
  123.     const ONLINE 'online';
  124.     const OFFLINE 'offline';
  125.     /**
  126.      * @ORM\Id
  127.      * @ORM\GeneratedValue
  128.      * @ORM\Column(type="integer")
  129.      * @Groups({"video:read", "video:read:id", "homepage:read", "playlist:read", "stats", "day:read", "expert:read", "channel:read",
  130.      *      "search_engine", "objective:read", "slide:read", "filters_filter:read", "filters_category:read",
  131.      *      "video_list", "video_form_complete", "video_form", "objective:read", "video_tech_infos", 
  132.      *      "teamplay_challenge:read", "program:read"
  133.      * })
  134.      */
  135.     private $id;
  136.     /**
  137.      * @ORM\Column(type="string", length=255)
  138.      * @Groups({"channel:read", "homepage:read", "video:read", "video:read:name", "video:write", "playlist:read", "video_tip:read",
  139.      *     "stats", "expert:read", "day:read", "search_engine", "objective:read", "slide:read", "filters_filter:read", "filters_category:read",
  140.      *     "program_single_list", "video_list", "video_form_complete", "video_form", "objective:read", "objective_form_complete", "answer_recommended_objectives_edit",
  141.      *     "teamplay_challenge:read", "program:read"
  142.      * })
  143.      * @Assert\NotBlank
  144.      * @Assert\NotNull
  145.      */
  146.     private $name;
  147.     /**
  148.      * @ORM\Column(type="text", nullable=true)
  149.      * @Groups({"channel:read", "homepage:read", "video:read", "video:read:description", "video:write", "expert:read", "day:read", "slide:read",
  150.      *     "filters_filter:read", "filters_category:read", "video_form_complete", "teamplay_challenge:read", "program:read"})
  151.      */
  152.     private $description;
  153.     /**
  154.      * @ORM\Column(type="string", length=255)
  155.      * @Groups({"channel:read", "homepage:read", "video:read", "video:read:url", "channel:read", "video:write", "day:read",
  156.      *     "search_engine", "objective:read", "filters_filter:read", "filters_category:read", "video_list", "video_form_complete", "teamplay_challenge:read", "program:read"})
  157.      * @Assert\NotBlank
  158.      * @Assert\NotNull
  159.      */
  160.     private $url;
  161.     /**
  162.      * @ORM\Column(type="integer")
  163.      * @Groups({"channel:read", "homepage:read", "video:read", "video:read:duration", "day:read", "slide:read", "search_engine", "objective:read",
  164.      *      "filters_filter:read", "filters_category:read", "video_list", "video_form_complete", "teamplay_challenge:read", "program:read"})
  165.      */
  166.     private $duration;
  167.     /**
  168.      * @ORM\Column(type="string", length=255)
  169.      * @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"})
  170.      */
  171.     private $code;
  172.     /**
  173.      * @ORM\Column(type="boolean", options={"default": 1})
  174.      * @Groups({"video:read", "video:read:active", "video:write", "filters_filter:read", "filters_category:read", "video_list", 
  175.      *      "video_form_complete", "teamplay_challenge:read", "program:read"
  176.      * })
  177.      */
  178.     private $active true;
  179.     /**
  180.      * @ORM\Column(type="datetime")
  181.      * @Groups({"video:read", "video:read:createdAt", "video_form_complete", "program:read"})
  182.      * @Gedmo\Timestampable(on="create")
  183.      */
  184.     private $createdAt;
  185.     /**
  186.      * @var bool
  187.      */
  188.     public $populated false;
  189.     /**
  190.      * @ORM\ManyToMany(targetEntity=TvTag::class)
  191.      * @Groups({"video:read", "video:read:tvTags", "video:write", "day:read", "video_form_complete", "program:read"})
  192.      */
  193.     private $tvTags;
  194.     /**
  195.      * @ORM\OneToMany(targetEntity=VideoEvent::class, mappedBy="video", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  196.      * @ApiSubresource(maxDepth=1)
  197.      */
  198.     private $videoEvents;
  199.     /**
  200.      * @ORM\ManyToOne(targetEntity=MediaObject::class)
  201.      * @Groups({"channel:read", "homepage:read", "video:read", "video:read:preview", "video:write", "stats", "expert:read",
  202.      *      "day:read", "search_engine", "objective:read", "filters_filter:read", "filters_category:read", "video_form_complete",
  203.      *      "teamplay_challenge:read", "program:read"
  204.      * })
  205.      */
  206.     private $preview;
  207.     /**
  208.      * @ORM\Column(type="string", length=255)
  209.      * @Groups({"video:read", "video:read:status", "video_list", "video_form_complete", "program:read"})
  210.      */
  211.     private $status self::NEW;
  212.     /**
  213.      * @ORM\ManyToMany(targetEntity=Expert::class, inversedBy="videos")
  214.      * @Groups({"channel:read", "homepage:read", "video:read", "video:read:experts", "video:write", "day:read", "slide:read", "search_engine", "objective:read",
  215.      *     "filters_filter:read", "filters_category:read", "video_form_complete", "teamplay_challenge:read", "program:read"})
  216.      * @ApiSubresource(maxDepth=1)
  217.      */
  218.     private $experts;
  219.     /**
  220.      * @ORM\ManyToOne(targetEntity=MediaObject::class)
  221.      * @Groups({"channel:read", "video:read", "video:read:picture", "video:write", "stats", "day:read", "search_engine", "objective:read", "slide:read",
  222.      *     "slide:read", "filters_filter:read", "filters_category:read", "video_form_complete", "teamplay_challenge:read", "program:read"
  223.      * })
  224.      */
  225.     private $picture;
  226.     /**
  227.      * @ORM\ManyToOne(targetEntity=MediaObject::class)
  228.      * @Groups({"video:read", "video:read:tip", "video:write", "day:read", "search_engine", "objective:read", "homepage:read", "filters_filter:read",
  229.      *     "filters_category:read", "video_form_complete","teamplay_challenge:read", "program:read"
  230.      * })
  231.      * @ApiSubresource(maxDepth=1)
  232.      */
  233.     private $tip;
  234.     /**
  235.      * @ORM\Column(type="text", nullable=true)
  236.      * @Groups({"video:read", "video:read:shortDescription", "homepage:read", "video:write", "day:read", "search_engine", "objective:read", "slide:read",
  237.      *     "filters_filter:read", "filters_category:read", "video_form_complete", "teamplay_challenge:read", "program:read"
  238.      * })
  239.      */
  240.     private $shortDescription;
  241.     /**
  242.      * @var array|null
  243.      * @Groups({"video:read", "video:read:linkedTo", "search_engine", "objective:read", "slide:read", "day:read"})
  244.      */
  245.     public $linkedTo null;
  246.     /**
  247.      * @var int|null
  248.      * @Groups({"video:read", "video:read:lastTimecode", "search_engine", "objective:read", "homepage:read", "filters_filter:read", "filters_category:read", "teamplay_challenge:read", "program:read"})
  249.      */
  250.     public $lastTimecode null;
  251.     /**
  252.      * @ORM\ManyToMany(targetEntity=Playlist::class, mappedBy="videos")
  253.      */
  254.     private $playlists;
  255.     /**
  256.      * @ApiProperty(security="is_granted('ROLE_ADMIN')", securityPostDenormalize= "is_granted('UPDATE', object)")
  257.      * @Groups({"video:write", "video:read", "video:read:playlistsChannel", "video_form_complete"})
  258.      */
  259.     private $playlistsChannel = [];
  260.     /**
  261.      * A conserver elle est utilisée en interne
  262.      * @var Playlist[]
  263.      */
  264.     private $playlistsDay = [];
  265.     /**
  266.      * A conserver elle est utilisée en interne
  267.      * @var Playlist[]
  268.      */
  269.     private $playlistsUser = [];
  270.     /**
  271.      * @ORM\ManyToOne(targetEntity=Channel::class, inversedBy="defaultVideos")
  272.      * @Groups({"video:read", "video:read:defaultChannel", "search_engine", "slide:read", "day:read", "video:write", "stats",
  273.      *      "filters_filter:read", "filters_category:read", "program_single_list", "video_list", "video_form_complete",
  274.      *      "teamplay_challenge:read", "program:read"
  275.      * })
  276.      */
  277.     private $defaultChannel;
  278.     /**
  279.      * @ORM\Column(type="boolean", options={"default": 1})
  280.      * @Groups({"channel:read", "homepage:read", "video:read", "video:read:forthcoming", "video:write", "playlist:read", "video_tip:read",
  281.      *     "stats", "expert:read", "day:read", "search_engine", "objective:read", "slide:read", "filters_filter:read",
  282.      *     "filters_category:read", "video_form_complete", "teamplay_challenge:read"
  283.      * })
  284.      */
  285.     private $forthcoming 1;
  286.     /**
  287.      * @ORM\OneToMany(targetEntity=ExclusionsVideo::class, mappedBy="video", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
  288.      * @Groups({"video:read", "video:read:exclusionsVideos", "video:write", "video_form_complete"})
  289.      */
  290.     private $exclusionsVideos;
  291.     /**
  292.      * @ORM\OneToMany(targetEntity=Notation::class, mappedBy="video", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
  293.      */
  294.     private $notations;
  295.     /**
  296.      * @var int|null
  297.      * @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"})
  298.      */
  299.     public $rate null;
  300.     /**
  301.      * @var int|null
  302.      * @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"})
  303.      */
  304.     public $rateQuality null;
  305.     /**
  306.      * @var int|null
  307.      * @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"})
  308.      */
  309.     public $rateExpert null;
  310.     /**
  311.      * @var int|null
  312.      * @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"})
  313.      */
  314.     public $ratePresentation null;
  315.     /**
  316.      * @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"})
  317.      */
  318.     public $asRated false;
  319.     /**
  320.      * @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"})
  321.      */
  322.     public $isFavorite false;
  323.     /**
  324.      * @ORM\Column(type="boolean", options={"default": 0})
  325.      * @Groups({"single_channel:read", "channel:read", "homepage:read", "video:read", "video:read:isRecipe", "category:read", "video:write",
  326.      *     "playlist:read", "video_tip:read", "stats", "expert:read", "day:read", "search_engine", "objective:read", "slide:read", "filters_filter:read",
  327.      *     "filters_category:read", "video_form_complete", "teamplay_challenge:read", "program:read"})
  328.      */
  329.     private $isRecipe false;
  330.     /**
  331.      * @var int|null
  332.      * @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"})
  333.      */
  334.     public $rank null;
  335.     /**
  336.      * @var bool
  337.      * @Groups({"video:read", "video:read:isFree"})
  338.      */
  339.     public $isFree false;
  340.     /**
  341.      * @var int
  342.      * @Groups({"video:read", "video:read:channelVideosCount"})
  343.      */
  344.     public $channelVideosCount null;
  345.     /**
  346.      * @var array
  347.      * @Groups({"video:read", "video:read:videosBottom"})
  348.      */
  349.     public $videosBottom null;
  350.     /**
  351.      * @ORM\ManyToMany(targetEntity=FiltersFilter::class, inversedBy="videos")
  352.      * @Groups({"single_channel:read", "channel:read", "homepage:read", "video:read", "video:read:filters", "category:read", "video:write",
  353.      *     "playlist:read", "video_tip:read", "stats", "expert:read", "day:read", "search_engine", "objective:read", "slide:read", "video_form_complete"})
  354.      */
  355.     private $filters;
  356.     /**
  357.      * @ORM\Column(type="string", length=255, nullable=true)
  358.      * @Groups({"single_channel:read", "channel:read", "homepage:read", "video:read", "video:read:reference", "category:read","video:write",
  359.      *     "playlist:read", "video_tip:read", "stats", "expert:read", "day:read", "search_engine", "objective:read", "slide:read",
  360.      *     "video_form_complete"})
  361.      */
  362.     private $reference;
  363.     /**
  364.      * @var array|null
  365.      * @Groups({"video:read", "video:read:moodAfterPostResponses", "video_form_complete"})
  366.      */
  367.     public $moodAfterPostResponses null;
  368.     /**
  369.      * @Groups({"single_channel:read", "channel:read", "homepage:read", "video:read", "video:read:flags", "category:read",
  370.      *     "playlist:read", "video_tip:read", "stats", "expert:read", "day:read", "search_engine", "objective:read", "slide:read"})
  371.      */
  372.     public $flags null;
  373.     /**
  374.      * @ORM\Column(type="text", nullable=true)
  375.      * @Groups({"video:read", "video:read:stringifyTags"})
  376.      */
  377.     private $stringifyTags '';
  378.     /**
  379.      * @var bool
  380.      * @Groups({"video_list"})
  381.      */
  382.     public $excluded false;
  383.     /**
  384.      * @Groups({"single_channel:read", "channel:read", "homepage:read", "video:read", "video:read:awardOperations", "category:read",
  385.      *     "playlist:read", "video_tip:read", "stats", "expert:read", "day:read", "search_engine", "objective:read", "slide:read"})
  386.      */
  387.     public $awardOperations null;
  388.     /**
  389.      * @ORM\Column(type="json", nullable=true)
  390.      * @Groups({"video_tech_infos"})
  391.      */
  392.     private $srcLinks = [];
  393.     /**
  394.      * @ORM\Column(type="boolean", options={"default": 0})
  395.      * @Groups({"single_channel:read", "channel:read", "homepage:read", "video:read", "video:read:public", "video:write", "category:read",
  396.      *     "playlist:read", "video_tip:read", "stats", "expert:read", "day:read", "search_engine", "objective:read", "slide:read",
  397.      *     "video_form_complete", "teamplay_challenge:read", "program:read"
  398.      * })
  399.      */
  400.     private $public false;
  401.     /**
  402.      * @ORM\OneToMany(targetEntity=Favorite::class, mappedBy="video", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  403.      */
  404.     private $favorites;
  405.     /**
  406.      * @ORM\OneToMany(targetEntity=UserVideoTimecode::class, mappedBy="video", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
  407.      */
  408.     private $userVideoTimecodes;
  409.     /**
  410.      * @ORM\OneToMany(targetEntity=VideoLastValidate::class, mappedBy="video", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
  411.      */
  412.     private $videoLastValidates;
  413.     /**
  414.      * @ORM\OneToMany(targetEntity=VideoLastSeen::class, mappedBy="video", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
  415.      */
  416.     private $videoLastSeens;
  417.     /**
  418.      * @ORM\OneToMany(targetEntity=TeamplayChallenge::class, mappedBy="video", cascade={"persist", "refresh", "remove"}, orphanRemoval=true)
  419.      */
  420.     private $teamplayChallenges;
  421.     /**
  422.      * @ORM\Column(type="boolean", options={"default": 0})
  423.      * @Groups({"video:read", "video:read:itCanInterrest", "video:write"})
  424.      */
  425.     private $itCanInterrest false;
  426.     /**
  427.      * @ORM\Column(type="datetime", nullable=true)
  428.      * @Groups({"video:read", "video:read:updatedAt", "video_form_complete"})
  429.      * @Gedmo\Timestampable(on="update")
  430.      */
  431.     private $updatedAt;
  432.     /**
  433.      * Custom fields
  434.      * @Groups({"video:read", "video:read:userPlaylists", "video:write", "teamplay_challenge:read", "program:read"})
  435.      */
  436.     private $userPlaylists null;
  437.     public function __construct()
  438.     {
  439.         $this->tvTags = new ArrayCollection();
  440.         $this->videoEvents = new ArrayCollection();
  441.         $this->experts = new ArrayCollection();
  442.         $this->playlists = new ArrayCollection();
  443.         $this->exclusionsVideos = new ArrayCollection();
  444.         $this->notations = new ArrayCollection();
  445.         $this->isRecipe 0;
  446.         $this->filters = new ArrayCollection();
  447.         $this->public false;
  448.         $this->favorites = new ArrayCollection();
  449.         $this->userVideoTimecodes = new ArrayCollection();
  450.         $this->videoLastValidates = new ArrayCollection();
  451.         $this->videoLastSeens = new ArrayCollection();
  452.         $this->teamplayChallenges = new ArrayCollection();
  453.         $this->playlistsUser = [];
  454.     }
  455.     public function getId(): ?int
  456.     {
  457.         return $this->id;
  458.     }
  459.     public function getName(): ?string
  460.     {
  461.         return $this->name;
  462.     }
  463.     public function setName(string $name): self
  464.     {
  465.         $this->name $name;
  466.         return $this;
  467.     }
  468.     public function getDescription(): ?string
  469.     {
  470.         return $this->description;
  471.     }
  472.     public function setDescription(?string $description): self
  473.     {
  474.         $this->description $description;
  475.         return $this;
  476.     }
  477.     public function getUrl(): ?string
  478.     {
  479.         return $this->url;
  480.     }
  481.     public function setUrl(string $url): self
  482.     {
  483.         $this->url $url;
  484.         return $this;
  485.     }
  486.     public function getDuration(): ?int
  487.     {
  488.         return $this->duration;
  489.     }
  490.     public function setDuration(int $duration): self
  491.     {
  492.         $this->duration $duration;
  493.         return $this;
  494.     }
  495.     public function getCode(): ?string
  496.     {
  497.         return $this->code;
  498.     }
  499.     public function setCode(string $code): self
  500.     {
  501.         $this->code $code;
  502.         return $this;
  503.     }
  504.     public function getActive(): ?bool
  505.     {
  506.         return $this->active;
  507.     }
  508.     public function setActive(bool $active): self
  509.     {
  510.         if ($active) {
  511.             $this->status self::ONLINE;
  512.         } elseif ($this->status !== self::NEW) {
  513.             $this->status self::OFFLINE;
  514.         }
  515.         $this->active $active;
  516.         return $this;
  517.     }
  518.     public function getCreatedAt(): ?\DateTimeInterface
  519.     {
  520.         return $this->createdAt;
  521.     }
  522.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  523.     {
  524.         $this->createdAt $createdAt;
  525.         return $this;
  526.     }
  527.     /**
  528.      * @return Collection|TvTag[]
  529.      */
  530.     public function getTvTags(): Collection
  531.     {
  532.         return $this->tvTags;
  533.     }
  534.     /**
  535.      * @return Video
  536.      * @Groups({"video:write"})
  537.      */
  538.     public function setTvTags(Collection $tvTags): self
  539.     {
  540.         $this->tvTags $tvTags;
  541.         foreach ($this->tvTags as $tvTag) {
  542.             $this->stringifyTags .= "#".$tvTag->getName();
  543.         }
  544.         return $this;
  545.     }
  546.     public function addTvTag(TvTag $tvTag): self
  547.     {
  548.         if (!$this->tvTags->contains($tvTag)) {
  549.             $this->tvTags[] = $tvTag;
  550.         }
  551.         return $this;
  552.     }
  553.     public function removeTvTag(TvTag $tvTag): self
  554.     {
  555.         $this->tvTags->removeElement($tvTag);
  556.         return $this;
  557.     }
  558.     /**
  559.      * @return Collection|VideoEvent[]
  560.      */
  561.     public function getVideoEvents(): Collection
  562.     {
  563.         return $this->videoEvents;
  564.     }
  565.     public function addVideoEvent(VideoEvent $videoEvent): self
  566.     {
  567.         if (!$this->videoEvents->contains($videoEvent)) {
  568.             $this->videoEvents[] = $videoEvent;
  569.             $videoEvent->setVideo($this);
  570.         }
  571.         return $this;
  572.     }
  573.     public function removeVideoEvent(VideoEvent $videoEvent): self
  574.     {
  575.         if ($this->videoEvents->removeElement($videoEvent)) {
  576.             // set the owning side to null (unless already changed)
  577.             if ($videoEvent->getVideo() === $this) {
  578.                 $videoEvent->setVideo(null);
  579.             }
  580.         }
  581.         return $this;
  582.     }
  583.     public function getPreview(): ?MediaObject
  584.     {
  585.         return $this->preview;
  586.     }
  587.     public function setPreview(?MediaObject $preview): self
  588.     {
  589.         $this->preview $preview;
  590.         return $this;
  591.     }
  592.     /**
  593.      * @Groups({"video:write"})
  594.      */
  595.     public function setPreviewFile($file null): self
  596.     {
  597.         if($file instanceof UploadedFile) {
  598.             $preview = empty($this->preview) ? new MediaObject $this->preview;
  599.             $preview->setFile($file);
  600.             $this->setPreview($preview);
  601.         }
  602.         return $this;
  603.     }
  604.     public function getStatus(): ?string
  605.     {
  606.         return $this->status;
  607.     }
  608.     public function setStatus(string $status): self
  609.     {
  610.         $this->status $status;
  611.         return $this;
  612.     }
  613.     /**
  614.      * @return Collection|Expert[]
  615.      */
  616.     public function getExperts(): Collection
  617.     {
  618.         return $this->experts;
  619.     }
  620.     public function addExpert(Expert $expert): self
  621.     {
  622.         if (!$this->experts->contains($expert)) {
  623.             $this->experts[] = $expert;
  624.         }
  625.         return $this;
  626.     }
  627.     public function removeExpert(Expert $expert): self
  628.     {
  629.         $this->experts->removeElement($expert);
  630.         return $this;
  631.     }
  632.     public function getPicture(): ?MediaObject
  633.     {
  634.         return $this->picture;
  635.     }
  636.     public function setPicture(?MediaObject $picture): self
  637.     {
  638.         $this->picture $picture;
  639.         return $this;
  640.     }
  641.     /**
  642.      * @Groups({"video:write"})
  643.      */
  644.     public function setPictureFile($file null): self
  645.     {
  646.         if($file instanceof UploadedFile) {
  647.             $picture = empty($this->picture) ? new MediaObject $this->picture;
  648.             $picture->setFile($file);
  649.             $this->setPicture($picture);
  650.         }
  651.         return $this;
  652.     }
  653.     public function getTip(): ?MediaObject
  654.     {
  655.         return $this->tip;
  656.     }
  657.     public function setTip(?MediaObject $tip): self
  658.     {
  659.         $this->tip $tip;
  660.         return $this;
  661.     }
  662.     /**
  663.      * @Groups({"video:write"})
  664.      */
  665.     public function setTipFile($file null): self
  666.     {
  667.         if($file instanceof UploadedFile) {
  668.             $tip = empty($this->tip) ? new MediaObject $this->tip;
  669.             $tip->setFile($file);
  670.             $this->setTip($tip);
  671.         }
  672.         return $this;
  673.     }
  674.     public function getShortDescription(): ?string
  675.     {
  676.         return $this->shortDescription;
  677.     }
  678.     /**
  679.      * @return array|null
  680.      * @Groups({"channel:read", "homepage:read", "video:read", "video:read:splitName", "video:write", "playlist:read", "video_tip:read",
  681.      *    "stats", "expert:read", "day:read", "search_engine", "objective:read", "slide:read", "filters_filter:read", "filters_category:read",
  682.      *     "program_single_list", "video_list"})
  683.      */
  684.     public function getSplitName(): ?array
  685.     {
  686.         return (is_string($this->name))?
  687.             array_map(function ($elem){return trim($elem);}, explode('|'$this->name))
  688.             :$this->name;
  689.     }
  690.     /**
  691.      * @return string|null
  692.      * @Groups({"channel:read", "homepage:read", "video:read", "video:read:managedName", "video:write", "playlist:read", "video_tip:read",
  693.      *     "stats", "expert:read", "day:read", "search_engine", "objective:read", "slide:read", "filters_filter:read", "filters_category:read"})
  694.      */
  695.     public function getManagedName(): ?string
  696.     {
  697.         return (is_string($this->name)) ? trim(str_replace('|'' '$this->name)) : $this->name;
  698.     }
  699.     public function setShortDescription(?string $shortDescription): self
  700.     {
  701.         $this->shortDescription $shortDescription;
  702.         return $this;
  703.     }
  704.     /**
  705.      * @return Collection|Playlist[]
  706.      */
  707.     public function getPlaylists(): Collection
  708.     {
  709.         return $this->playlists;
  710.     }
  711.     /**
  712.      * @return Video
  713.      */
  714.     public function setPlaylists($playlists): self
  715.     {
  716.         if(is_array($playlists)) {
  717.             $playlists = new ArrayCollection($playlists);
  718.         } 
  719.         
  720.         if($playlists instanceof ArrayCollection) {
  721.             $this->playlists $playlists;
  722.         }
  723.         return $this;
  724.     }
  725.     public function addPlaylist(Playlist $playlist): self
  726.     {
  727.         if (!$this->playlists->contains($playlist)) {
  728.             $this->playlists[] = $playlist;
  729.         }
  730.         return $this;
  731.     }
  732.     public function removePlaylist(Playlist $playlist): self
  733.     {
  734.         $this->playlists->removeElement($playlist);
  735.         return $this;
  736.     }
  737.     /**
  738.      * @Groups({"video:write"})
  739.      */
  740.     public function setAddPlaylists($playlists): self
  741.     {
  742.         foreach ($playlists as $playlist) {
  743.             if($playlist instanceof Playlist) {
  744.                 $this->addPlaylist($playlist);
  745.             }
  746.         }
  747.         return $this;
  748.     }
  749.     /**
  750.      * @Groups({"video:write"})
  751.      */
  752.     public function setRemovePlaylists($playlists): self
  753.     {
  754.         foreach ($playlists as $playlist) {
  755.             if($playlist instanceof Playlist) {
  756.                 $this->removePlaylist($playlist);
  757.             }
  758.         }
  759.         return $this;
  760.     }
  761.     /**
  762.      * @return Playlist[]
  763.      */
  764.     public function getPlaylistsChannel(): ?array
  765.     {
  766.         $playlistsChannel = new ArrayCollection;
  767.         // Parcourir toute les playlists 
  768.         // Si la video est dans cette playlist, l'ajouter Ã  la variable
  769.         // Si la playlist est lié a un channel
  770.         foreach ($this->playlists as $playlist) {
  771.             if($playlist->getChannels()->count() > 0){
  772.                 foreach ($playlist->getChannels() as $channel) {
  773.                     if(!$playlistsChannel->contains($playlist)) {
  774.                         $playlistsChannel->add($playlist);
  775.                     }
  776.                 }
  777.             }
  778.         }
  779.         $this->playlistsChannel $playlistsChannel->toArray();
  780.         return $this->playlistsChannel;
  781.     }
  782.     /**
  783.      * @param Playlist[] $playlistsChannel
  784.      * @return Video
  785.      */
  786.     public function setPlaylistsChannel(?array $playlistsChannel): self
  787.     {
  788.         $this->playlistsChannel $playlistsChannel;
  789.         return $this;
  790.     }
  791.     /**
  792.      * @return Playlist[]
  793.      */
  794.     public function getPlaylistsDay(): ?array
  795.     {
  796.         return $this->playlistsDay;
  797.     }
  798.     /**
  799.      * @param Playlist[] $playlistsDay
  800.      * @return Video
  801.      */
  802.     public function setPlaylistsDay(?array $playlistsDay): Video
  803.     {
  804.         $this->playlistsDay $playlistsDay;
  805.         return $this;
  806.     }
  807.     /**
  808.      * @return Playlist[]
  809.      */
  810.     public function getPlaylistsUser(): ?array
  811.     {
  812.         return $this->playlistsUser;
  813.     }
  814.     /**
  815.      * @param Playlist[] $playlistsUser
  816.      * @return Video
  817.      */
  818.     public function setPlaylistsUser(?array $playlistsUser): Video
  819.     {
  820.         $this->playlistsUser $playlistsUser;
  821.         return $this;
  822.     }
  823.     public function getDefaultChannel(): ?Channel
  824.     {
  825.         return $this->defaultChannel;
  826.     }
  827.     public function setDefaultChannel(?Channel $defaultChannel): self
  828.     {
  829.         $this->defaultChannel $defaultChannel;
  830.         return $this;
  831.     }
  832.     public function getForthcoming(): ?bool
  833.     {
  834.         return $this->forthcoming;
  835.     }
  836.     public function setForthcoming(bool $forthcoming): self
  837.     {
  838.         $this->forthcoming $forthcoming;
  839.         return $this;
  840.     }
  841.     /**
  842.      * @return Collection|Notation[]
  843.      */
  844.     public function getNotations(): Collection
  845.     {
  846.         return $this->notations;
  847.     }
  848.     public function addNotation(Notation $notation): self
  849.     {
  850.         if (!$this->notations->contains($notation)) {
  851.             $this->notations[] = $notation;
  852.             $notation->setVideo($this);
  853.         }
  854.         return $this;
  855.     }
  856.     public function removeNotation(Notation $notation): self
  857.     {
  858.         if ($this->notations->removeElement($notation)) {
  859.             // set the owning side to null (unless already changed)
  860.             if ($notation->getVideo() === $this) {
  861.                 $notation->setVideo(null);
  862.             }
  863.         }
  864.         return $this;
  865.     }
  866.     /**
  867.      * @return Collection|ExclusionsVideo[]
  868.      */
  869.     public function getExclusionsVideos(): Collection
  870.     {
  871.         return $this->exclusionsVideos;
  872.     }
  873.     public function addExclusionsVideo(ExclusionsVideo $exclusionsVideo): self
  874.     {
  875.         if (!$this->exclusionsVideos->contains($exclusionsVideo)) {
  876.             $this->exclusionsVideos[] = $exclusionsVideo;
  877.             $exclusionsVideo->setVideo($this);
  878.         }
  879.         return $this;
  880.     }
  881.     public function removeExclusionsVideo(ExclusionsVideo $exclusionsVideo): self
  882.     {
  883.         if ($this->exclusionsVideos->removeElement($exclusionsVideo)) {
  884.             // set the owning side to null (unless already changed)
  885.             if ($exclusionsVideo->getVideo() === $this) {
  886.                 $exclusionsVideo->setVideo(null);
  887.             }
  888.         }
  889.         return $this;
  890.     }
  891.     public function getIsRecipe(): ?bool
  892.     {
  893.         return $this->isRecipe;
  894.     }
  895.     public function setIsRecipe(bool $isRecipe): self
  896.     {
  897.         $this->isRecipe $isRecipe;
  898.         return $this;
  899.     }
  900.     /**
  901.      * @return Collection|FiltersFilter[]
  902.      */
  903.     public function getFilters(): Collection
  904.     {
  905.         return $this->filters;
  906.     }
  907.     public function addFilter(FiltersFilter $filter): self
  908.     {
  909.         if (!$this->filters->contains($filter)) {
  910.             $this->filters[] = $filter;
  911.         }
  912.         return $this;
  913.     }
  914.     public function removeFilter(FiltersFilter $filter): self
  915.     {
  916.         $this->filters->removeElement($filter);
  917.         return $this;
  918.     }
  919.     public function getReference(): ?string
  920.     {
  921.         return $this->reference;
  922.     }
  923.     public function setReference(?string $reference): self
  924.     {
  925.         $this->reference $reference;
  926.         return $this;
  927.     }
  928.     public function getStringifyTags(): ?string
  929.     {
  930.         return $this->stringifyTags;
  931.     }
  932.     public function setStringifyTags(?string $stringifyTags): self
  933.     {
  934.         $this->stringifyTags $stringifyTags;
  935.         return $this;
  936.     }
  937.     public function getTvTagsName(): array
  938.     {
  939.         $tvTags = [];
  940.         foreach ($this->tvTags as $tvTag) {
  941.             if(!in_array($tvTag->getName(), $tvTags)) $tvTags[] = $tvTag->getName();
  942.         }
  943.         return $tvTags;
  944.     }
  945.     /**
  946.      * @return bool
  947.      */
  948.     public function isExcluded(): bool
  949.     {
  950.         return $this->excluded;
  951.     }
  952.     /**
  953.      * @param bool $excluded
  954.      * @return Video
  955.      */
  956.     public function setExcluded(bool $excluded): Video
  957.     {
  958.         $this->excluded $excluded;
  959.         return $this;
  960.     }
  961.     public function getSrcLinks(): ?array
  962.     {
  963.         return $this->srcLinks;
  964.     }
  965.     public function setSrcLinks(?array $srcLinks): self
  966.     {
  967.         $this->srcLinks $srcLinks;
  968.         return $this;
  969.     }
  970.     public function getPublic(): ?bool
  971.     {
  972.         return $this->public;
  973.     }
  974.     public function setPublic(bool $public): self
  975.     {
  976.         $this->public $public;
  977.         return $this;
  978.     }
  979.     /**
  980.      * @return Collection|Favorite[]
  981.      */
  982.     public function getFavorites(): Collection
  983.     {
  984.         return $this->favorites;
  985.     }
  986.     public function addFavorite(Favorite $favorite): self
  987.     {
  988.         if (!$this->favorites->contains($favorite)) {
  989.             $this->favorites[] = $favorite;
  990.         }
  991.         return $this;
  992.     }
  993.     public function removeFavorite(Favorite $favorite): self
  994.     {
  995.         $this->favorites->removeElement($favorite);
  996.         return $this;
  997.     }
  998.     /**
  999.      * @return Collection|UserVideoTimecode[]
  1000.      */
  1001.     public function getUserVideoTimecodes(): Collection
  1002.     {
  1003.         return $this->userVideoTimecodes;
  1004.     }
  1005.     public function addUserVideoTimecode(UserVideoTimecode $userVideoTimecode): self
  1006.     {
  1007.         if (!$this->userVideoTimecodes->contains($userVideoTimecode)) {
  1008.             $this->userVideoTimecodes[] = $userVideoTimecode;
  1009.             $userVideoTimecode->setVideo($this);
  1010.         }
  1011.         return $this;
  1012.     }
  1013.     public function removeUserVideoTimecode(UserVideoTimecode $userVideoTimecode): self
  1014.     {
  1015.         if ($this->userVideoTimecodes->removeElement($userVideoTimecode)) {
  1016.             // set the owning side to null (unless already changed)
  1017.             if ($userVideoTimecode->getVideo() === $this) {
  1018.                 $userVideoTimecode->setVideo(null);
  1019.             }
  1020.         }
  1021.         return $this;
  1022.     }
  1023.     /**
  1024.      * @return Collection|VideoLastValidate[]
  1025.      */
  1026.     public function getVideoLastValidates(): Collection
  1027.     {
  1028.         return $this->videoLastValidates;
  1029.     }
  1030.     public function addVideoLastValidate(VideoLastValidate $videoLastValidate): self
  1031.     {
  1032.         if (!$this->videoLastValidates->contains($videoLastValidate)) {
  1033.             $this->videoLastValidates[] = $videoLastValidate;
  1034.             $videoLastValidate->setVideo($this);
  1035.         }
  1036.         return $this;
  1037.     }
  1038.     public function removeVideoLastValidate(VideoLastValidate $videoLastValidate): self
  1039.     {
  1040.         if ($this->videoLastValidates->removeElement($videoLastValidate)) {
  1041.             // set the owning side to null (unless already changed)
  1042.             if ($videoLastValidate->getVideo() === $this) {
  1043.                 $videoLastValidate->setVideo(null);
  1044.             }
  1045.         }
  1046.         return $this;
  1047.     }
  1048.     /**
  1049.      * @return Collection|VideoLastSeen[]
  1050.      */
  1051.     public function getVideoLastSeens(): Collection
  1052.     {
  1053.         return $this->videoLastSeens;
  1054.     }
  1055.     public function addVideoLastSeen(VideoLastSeen $videoLastSeen): self
  1056.     {
  1057.         if (!$this->videoLastSeens->contains($videoLastSeen)) {
  1058.             $this->videoLastSeens[] = $videoLastSeen;
  1059.             $videoLastSeen->setVideo($this);
  1060.         }
  1061.         return $this;
  1062.     }
  1063.     public function removeVideoLastSeen(VideoLastSeen $videoLastSeen): self
  1064.     {
  1065.         if ($this->videoLastSeens->removeElement($videoLastSeen)) {
  1066.             // set the owning side to null (unless already changed)
  1067.             if ($videoLastSeen->getVideo() === $this) {
  1068.                 $videoLastSeen->setVideo(null);
  1069.             }
  1070.         }
  1071.         return $this;
  1072.     }
  1073.     /**
  1074.      * @return Collection|TeamplayChallenge[]
  1075.      */
  1076.     public function getTeamplayChallenges(): Collection
  1077.     {
  1078.         return $this->teamplayChallenges;
  1079.     }
  1080.     public function addTeamplayChallenge(TeamplayChallenge $teamplayChallenge): self
  1081.     {
  1082.         if (!$this->teamplayChallenges->contains($teamplayChallenge)) {
  1083.             $this->teamplayChallenges[] = $teamplayChallenge;
  1084.             $teamplayChallenge->setVideo($this);
  1085.         }
  1086.         return $this;
  1087.     }
  1088.     public function removeTeamplayChallenge(TeamplayChallenge $teamplayChallenge): self
  1089.     {
  1090.         if ($this->teamplayChallenges->removeElement($teamplayChallenge)) {
  1091.             // set the owning side to null (unless already changed)
  1092.             if ($teamplayChallenge->getVideo() === $this) {
  1093.                 $teamplayChallenge->setVideo(null);
  1094.             }
  1095.         }
  1096.         return $this;
  1097.     }
  1098.     public function getUpdatedAt(): ?\DateTimeInterface
  1099.     {
  1100.         return $this->updatedAt;
  1101.     }
  1102.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  1103.     {
  1104.         $this->updatedAt $updatedAt;
  1105.         return $this;
  1106.     }
  1107.     public function getItCanInterrest(): ?bool
  1108.     {
  1109.         return $this->itCanInterrest;
  1110.     }
  1111.     public function setItCanInterrest(bool $itCanInterrest): self
  1112.     {
  1113.         $this->itCanInterrest $itCanInterrest;
  1114.         return $this;
  1115.     }
  1116.     /**
  1117.      * @return array|Playlist[]
  1118.      */
  1119.     public function getUserPlaylists(): ?array
  1120.     {
  1121.         return $this->userPlaylists;
  1122.     }
  1123.     public function setUserPlaylists($userPlaylists): self
  1124.     {
  1125.         $this->userPlaylists $userPlaylists;
  1126.         return $this;
  1127.     }
  1128. }