<?php
namespace App\Entity;
use App\Annotation\SerializedNameGroups;
use App\Repository\TvCompanyRepository;
use App\Security\UserChecker;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=TvCompanyRepository::class)
* @ORM\HasLifecycleCallbacks()
*/
class TvCompany
{
const STATUS_ACTIVE = 'active';
const STATUS_EXPIRED = 'expired';
const STATUS_SUSPENDED = 'suspended';
const STATUS_INACTIVE = 'deactivated';
const MESSAGE_RESTRICTION = 'restricted_msg';
const MESSAGE_QUOTAS = 'restricted_msg';
const MESSAGE_DEFAULT = 'default';
const STATUSES = [
self::STATUS_INACTIVE,
self::STATUS_EXPIRED,
self::STATUS_SUSPENDED,
self::STATUS_ACTIVE,
];
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"tv_company_read", "export_csv", "simple_company", "video_read", "message_read", "tv_user_tv_company_read", "company_form",
* "award_read", "team_read", "team_user_read", "notification_read"
* })
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"tv_user_read", "tv_company_read", "tv_company_write", "export_csv", "message_read", "tv_user_tv_company_read",
* "tv_user_read_creation", "simple_company", "video_read", "category_read", "channel_read", "company_form",
* "video_form_complete", "manager_dashboard", "award_read", "program_edit", "team_read", "team_user_read",
* "team_simple", "teamplay_read", "notification_read"
* })
* @Assert\NotBlank()
* @SerializedNameGroups(name="Nom", groups={"tv_user_read_creation", "team_simple"})
*/
private $name;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"tv_user_read", "tv_company_read", "tv_company_write", "export_csv", "manager_dashboard"})
* @Assert\NotBlank()
*/
private $addressLine;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"tv_user_read", "tv_company_read", "tv_company_write", "export_csv"})
* @Assert\NotBlank()
*/
private $city;
/**
* @ORM\Column(type="string", length=20)
* @Groups({"tv_user_read", "tv_company_read", "tv_company_write", "export_csv"})
* @Assert\NotBlank()
*/
private $zipCode;
/**
* @ORM\Column(type="string", length=100)
* @Groups({"tv_user_read", "tv_company_read", "tv_company_write", "export_csv"})
* @Assert\NotBlank()
*/
private $country;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"tv_company_read", "tv_company_write", "export_csv", "manager_dashboard"})
* @Assert\NotBlank()
*/
private $managerFirstName;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"tv_company_read", "tv_company_write", "export_csv", "manager_dashboard"})
* @Assert\NotBlank()
*/
private $managerLastName;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"tv_company_read", "tv_company_write", "export_csv", "manager_dashboard"})
* @Assert\NotBlank()
*/
private $managerFunction;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"tv_company_read", "tv_company_write", "export_csv", "manager_dashboard"})
* @Assert\NotBlank()
* @Assert\Length(min=8, max=20, minMessage="phone.min", maxMessage="phone.max")
* @Assert\Regex(pattern="/^(?:(?:\+|00)33|0)\s*[1-9](?:[\s.-]*\d{2}){4}$/i", message="phone.regex")
*/
private $managerPhone;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"tv_company_read", "tv_company_write", "export_csv", "manager_dashboard"})
* @Assert\NotBlank()
*/
private $managerEmail;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"tv_company_read", "tv_company_write", "export_csv", "manager_dashboard"})
* @Assert\NotBlank()
*/
private $siren;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"tv_company_read", "tv_company_write", "export_csv", "manager_dashboard"})
* @Assert\Choice(choices=self::STATUSES)
*/
private $status = self::STATUS_ACTIVE;
/**
* @ORM\Column(type="boolean", options={"default": 1})
* @Groups({"tv_company_read", "notification_read"})
*/
private $active = true;
/**
* @ORM\OneToMany(targetEntity=TvUser::class, mappedBy="tvCompany", cascade={"persist", "refresh", "remove"})
* @Groups({"tv_company_read"})
*/
private $tvUsers;
/**
* @ORM\OneToMany(targetEntity=Restriction::class, mappedBy="tvCompany", orphanRemoval=true, cascade={"remove"})
* @Groups({"tv_company_read"})
*/
private $restrictions;
/**
* @ORM\OneToMany(targetEntity=Order::class, mappedBy="tvCompany", cascade={"remove"})
* @Groups({"tv_company_read"})
*/
private $orders;
/**
* @ORM\ManyToOne(targetEntity=MediaObject::class)
* @Groups({"tv_company_read", "tv_company_write", "tv_user_tv_company_read", "manager_dashboard"})
*/
private $logo;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime")
*/
private $updatedAt;
/**
* @ORM\Column(type="datetime", nullable=true)
* @Groups({"tv_company_read", "tv_company_write", "export_csv", "manager_dashboard"})
*/
private $subscriptionStart;
/**
* @ORM\Column(type="datetime", nullable=true)
* @Groups({"tv_company_read", "tv_company_write", "export_csv", "manager_dashboard"})
*/
private $subscriptionEnd;
/**
* @ORM\Column(type="integer")
* @Groups({"tv_company_read", "export_csv"})
*/
private $tvUsersCount = 0;
/**
* Restriction messages if an tvUser bypasses any restrictions
* A 'default' message key will be used if the message has not been customized
* @ORM\Column(type="array")
* @Groups({"tv_company_read", "tv_company_write"})
*/
private $messages = [self::MESSAGE_DEFAULT => UserChecker::QUOTAS_MESSAGE];
/**
* Maximum users allowed for the tvCompany
* @ORM\Column(type="integer", nullable=true)
* @Groups({"tv_company_read", "tv_company_write"})
*/
private $maxUsers;
/**
* Forfait heure / forfait visionnage
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"tv_company_read", "tv_company_write"})
*/
private $plan;
/**
* Domain corresponding to this tvCompany ex:
* "orange.ulteam-tv.fr" will match tvCompany "Orange"
* @ORM\Column(type="string", length=255)
* @Groups({"tv_company_read", "tv_company_write"})
* @Assert\NotBlank
*/
private $slug;
/**
* Restriction par IP
* @ORM\Column(type="array", nullable=true)
* @Groups({"tv_company_read", "tv_company_write"})
*/
private $ips = [];
/**
* Restriction par domaine mail
* @ORM\Column(type="array", nullable=true)
* @Groups({"tv_company_read", "tv_company_write"})
*/
private $domain = [];
/**
* Restriction heure de visionnage par utilisateur (5h)
* @ORM\Column(type="integer", nullable=true)
* @Groups({"tv_company_read", "tv_company_write"})
*/
private $hourlyRestriction;
/**
* Restriction par code
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"tv_company_read", "tv_company_write"})
*/
private $code;
/**
* @ORM\OneToMany(targetEntity=Category::class, mappedBy="tvCompany", cascade={"persist", "refresh", "remove"})
*/
private $categories;
/**
* @ORM\OneToMany(targetEntity=Channel::class, mappedBy="tvCompany", cascade={"persist", "refresh", "remove"})
*/
private $channels;
/**
* @ORM\Column(type="boolean", options={"default": 0})
*/
private $customizable = false;
/**
* @ORM\OneToMany(targetEntity=ExclusionsChannel::class, mappedBy="tvCompany", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $exclusionsChannels;
/**
* @ORM\OneToMany(targetEntity=ExclusionsCategory::class, mappedBy="tvCompany", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $exclusionsCategories;
/**
* @ORM\OneToMany(targetEntity=ExclusionsVideo::class, mappedBy="tvCompany", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $exclusionsVideos;
/**
* @ORM\OneToMany(targetEntity=Department::class, mappedBy="tvCompany", cascade={"persist", "refresh", "remove"})
* @Groups({"tv_user_read", "tv_company_read", "tv_user_tv_company_read"})
*/
private $departments;
/**
* @ORM\Column(type="text", nullable=true)
* @Groups({"tv_user_read", "tv_company_read", "tv_company_write", "tv_user_tv_company_read"})
*/
private $cms;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"tv_user_read", "tv_company_read", "tv_company_write", "tv_user_tv_company_read"})
*/
private $cmsTitle;
/**
* @ORM\ManyToOne(targetEntity=MediaObject::class)
* @Groups({"tv_user_read", "tv_company_read", "tv_company_write", "tv_user_tv_company_read"})
*/
private $cmsImg;
/**
* @ORM\Column(type="text", nullable=true)
* @Groups({"tv_user_read", "tv_company_read", "tv_company_write", "tv_user_tv_company_read"})
*/
private $cmsText;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"tv_user_read", "tv_company_read", "tv_company_write", "tv_user_tv_company_read"})
*/
private $cmsCtaText;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"tv_user_read", "tv_company_read", "tv_company_write", "tv_user_tv_company_read"})
*/
private $cmsCtaUrl;
/**
* @ORM\OneToMany(targetEntity=LogEmail::class, mappedBy="tvCompany", cascade={"persist", "refresh", "remove"})
*/
private $logEmails;
/**
* @ORM\ManyToMany(targetEntity=Award::class, mappedBy="tvCompanies")
*/
private $awards;
/**
* @ORM\ManyToMany(targetEntity=Association::class)
* @Groups({"tv_user_tv_company_read", "tv_company_read", "tv_company_write"})
*/
private $associations;
/**
* @ORM\OneToMany(targetEntity=Program::class, mappedBy="tvCompany", cascade={"persist", "refresh", "remove"})
*/
private $programs;
/**
* @ORM\Column(type="boolean", nullable=true)
* @Groups({"tv_user_read", "tv_company_read", "tv_company_write", "export_csv", "message_read", "tv_user_tv_company_read",
* "tv_user_read_creation", "simple_company", "video_read", "category_read", "channel_read", "company_form",
* "video_form_complete", "manager_dashboard", "award_read"})
*/
private $resaLinkActive;
/**
* @ORM\OneToMany(targetEntity=Team::class, mappedBy="tvCompany", cascade={"persist", "refresh", "remove"})
*/
private $teams;
/**
* @Groups({"tv_user_read", "tv_company_read", "tv_user_tv_company_read"})
*/
private $teamplayTeams;
/**
* @ORM\OneToMany(targetEntity=Teamplay::class, mappedBy="tvCompany", cascade={"persist", "refresh", "remove"})
*/
private $teamplays;
/**
* @ORM\OneToMany(targetEntity=TeamplayChallenge::class, mappedBy="tvCompany", cascade={"persist", "refresh", "remove"})
*/
private $teamplayChallenges;
/**
* @ORM\OneToMany(targetEntity=TeamplayLog::class, mappedBy="tvCompany", cascade={"persist", "refresh", "remove"})
*/
private $teamplayLogs;
/**
* @ORM\OneToMany(targetEntity=PedometerLog::class, mappedBy="tvCompany", cascade={"persist", "refresh", "remove"})
*/
private $pedometerLogs;
/**
* @ORM\OneToMany(targetEntity=Log::class, mappedBy="tvCompany", cascade={"persist", "refresh", "remove"})
*/
private $logs;
/**
* @ORM\OneToMany(targetEntity=UserNotification::class, mappedBy="tvCompany", cascade={"persist", "refresh", "remove"})
*/
private $userNotifications;
/**
* @ORM\OneToMany(targetEntity=Slide::class, mappedBy="tvCompany", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $slides;
/**
* @ORM\OneToMany(targetEntity=AwardConfig::class, mappedBy="tvCompany", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $awardConfigs;
/**
* @ORM\OneToOne(targetEntity=Company::class, inversedBy="tvCompany")
*/
private $company;
public function __construct()
{
$this->tvUsers = new ArrayCollection();
$this->restrictions = new ArrayCollection();
$this->orders = new ArrayCollection();
$this->updatedAt = new \DateTime();
$this->createdAt = new \DateTime();
$this->categories = new ArrayCollection();
$this->channels = new ArrayCollection();
$this->exclusionsChannels = new ArrayCollection();
$this->exclusionsCategories = new ArrayCollection();
$this->exclusionsVideos = new ArrayCollection();
$this->departments = new ArrayCollection();
$this->logEmails = new ArrayCollection();
$this->awards = new ArrayCollection();
$this->associations = new ArrayCollection();
$this->programs = new ArrayCollection();
$this->teams = new ArrayCollection();
$this->teamplays = new ArrayCollection();
$this->teamplayChallenges = new ArrayCollection();
$this->teamplayLogs = new ArrayCollection();
$this->pedometerLogs = new ArrayCollection();
$this->logs = new ArrayCollection();
$this->userNotifications = new ArrayCollection();
$this->slides = new ArrayCollection();
$this->awardConfigs = new ArrayCollection();
}
/**
* Gets the active order no more than an order can be active at a time for a tvCompany
* @return Order|null
*/
public function getActiveOrder(): ?Order
{
foreach ($this->orders as $order) {
if ($order instanceof Order && $order->getActive()) {
return $order;
}
}
return null;
}
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 getAddressLine(): ?string
{
return $this->addressLine;
}
public function setAddressLine(string $addressLine): self
{
$this->addressLine = $addressLine;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(string $city): self
{
$this->city = $city;
return $this;
}
public function getZipCode(): ?string
{
return $this->zipCode;
}
public function setZipCode(string $zipCode): self
{
$this->zipCode = $zipCode;
return $this;
}
public function getCountry(): ?string
{
return $this->country;
}
public function setCountry(string $country): self
{
$this->country = $country;
return $this;
}
public function getManagerFirstName(): ?string
{
return $this->managerFirstName;
}
public function setManagerFirstName(string $managerFirstName): self
{
$this->managerFirstName = $managerFirstName;
return $this;
}
public function getManagerLastName(): ?string
{
return $this->managerLastName;
}
public function setManagerLastName(string $managerLastName): self
{
$this->managerLastName = $managerLastName;
return $this;
}
public function getManagerFunction(): ?string
{
return $this->managerFunction;
}
public function setManagerFunction(string $managerFunction): self
{
$this->managerFunction = $managerFunction;
return $this;
}
public function getManagerPhone(): ?string
{
return $this->managerPhone;
}
public function setManagerPhone(string $managerPhone): self
{
$this->managerPhone = $managerPhone;
return $this;
}
public function getManagerEmail(): ?string
{
return $this->managerEmail;
}
public function setManagerEmail(string $managerEmail): self
{
$this->managerEmail = $managerEmail;
return $this;
}
public function getSiren(): ?string
{
return $this->siren;
}
public function setSiren(string $siren): self
{
$this->siren = $siren;
return $this;
}
public function getActive(): ?bool
{
return $this->active;
}
public function setActive(bool $active): self
{
$this->active = $active;
return $this;
}
/**
* @return Collection|TvUser[]
*/
public function getTvUsers(): Collection
{
return $this->tvUsers;
}
public function addUser(TvUser $tvUser): self
{
if (!$this->tvUsers->contains($tvUser)) {
$this->tvUsers[] = $tvUser;
$tvUser->setTvCompany($this);
}
return $this;
}
public function removeUser(TvUser $tvUser): self
{
if ($this->tvUsers->removeElement($tvUser)) {
// set the owning side to null (unless already changed)
if ($tvUser->getTvCompany() === $this) {
$tvUser->setTvCompany(null);
}
}
return $this;
}
/**
* @return Collection|Restriction[]
*/
public function getRestrictions(): Collection
{
return $this->restrictions;
}
public function addRestriction(Restriction $restriction): self
{
if (!$this->restrictions->contains($restriction)) {
$this->restrictions[] = $restriction;
$restriction->setTvCompany($this);
}
return $this;
}
public function removeRestriction(Restriction $restriction): self
{
if ($this->restrictions->removeElement($restriction)) {
// set the owning side to null (unless already changed)
if ($restriction->getTvCompany() === $this) {
$restriction->setTvCompany(null);
}
}
return $this;
}
/**
* @return Collection|Order[]
*/
public function getOrders(): Collection
{
return $this->orders;
}
public function addOrder(Order $order): self
{
if (!$this->orders->contains($order)) {
$this->orders[] = $order;
$order->setTvCompany($this);
}
return $this;
}
public function removeOrder(Order $order): self
{
if ($this->orders->removeElement($order)) {
// set the owning side to null (unless already changed)
if ($order->getTvCompany() === $this) {
$order->setTvCompany(null);
}
}
return $this;
}
/**
* Updates the entity including users count, created at and updated at elements
* and the start and the end of the subscription
* @return TvCompany
* @ORM\PrePersist
*/
public function updateEntity(): self
{
$this->updateSubscription();
$this->updateStatus();
$this->updateTvUsersCount();
$this->updatedAt = new \DateTime();
return $this;
}
/**
* Updates the count of the tvCompany users
*/
private function updateTvUsersCount()
{
$this->tvUsersCount = $this->tvUsers->count();
}
/**
* Updates subscription dates
*/
private function updateSubscription()
{
$order = $this->getActiveOrder();
if ($order instanceof Order) {
$this->subscriptionEnd = $order->getEnd();
$this->subscriptionStart = $order->getStart();
}
}
/**
* Updates the status of the tvCompany
*/
private function updateStatus()
{
$ret = self::STATUS_ACTIVE;
if ($this->subscriptionEnd < (new \DateTime())) {
$ret = self::STATUS_EXPIRED;
}
if (!$this->active) {
$ret = self::STATUS_SUSPENDED;
}
$this->status = $ret;
}
public function getLogo(): ?MediaObject
{
return $this->logo;
}
public function setLogo(?MediaObject $logo): self
{
$this->logo = $logo;
return $this;
}
/**
* @param mixed $status
* @return TvCompany
*/
public function setStatus(?string $status): TvCompany
{
$this->status = $status;
if (in_array($this->status, [self::STATUS_SUSPENDED, self::STATUS_EXPIRED, self::STATUS_INACTIVE])) {
$this->active = false;
} else {
$this->active = true;
}
return $this;
}
/**
* @return string
*/
public function getStatus(): string
{
return $this->status;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getSubscriptionStart(): ?\DateTimeInterface
{
return $this->subscriptionStart;
}
public function setSubscriptionStart(?\DateTimeInterface $subscriptionStart): self
{
$this->subscriptionStart = $subscriptionStart;
return $this;
}
public function getSubscriptionEnd(): ?\DateTimeInterface
{
return $this->subscriptionEnd;
}
public function setSubscriptionEnd(?\DateTimeInterface $subscriptionEnd): self
{
$this->subscriptionEnd = $subscriptionEnd;
return $this;
}
public function getTvUsersCount(): ?int
{
return $this->tvUsersCount;
}
public function setTvUsersCount(int $tvUsersCount): self
{
$this->tvUsersCount = $tvUsersCount;
return $this;
}
public function getMessages(): ?array
{
if (!is_array($this->messages)) {
$this->messages = [];
}
return $this->messages;
}
/**
* Gets a message if it exists
* @param string $key
* @return string|null
*/
public function getMessage(string $key): ?string
{
$_messages = $this->getMessages();
return (!empty($_messages[$key])) ? $_messages[$key] : null;
}
public function setMessages(array $messages): self
{
$this->messages = $messages;
return $this;
}
/**
* Indicates if a tvUser is restricted according to general tvCompany restrictions
*
* @param \DateTime $time
* @return bool
*/
public function isRestricted(\DateTime $time): bool
{
foreach ($this->restrictions as $restriction) {
if ($restriction instanceof Restriction && $restriction->isRestricted($time)) {
return true;
}
}
return false;
}
/**
* Gets the start of the next restriction on a given interval
* @param \DateTime $start
* @param \DateTime $end
* @return \DateTime|null
*/
public function getNextRestriction(\DateTime $start, \DateTime $end): ?\DateTime
{
foreach ($this->restrictions as $restriction) {
if ($restriction instanceof Restriction) {
$startRestriction = $restriction->getStart($start);
if ($startRestriction <= $end) {
return $startRestriction;
}
}
}
return null;
}
/**
* Gets the end of a restriction
* @return string
*/
public function getEndRestriction(\DateTime $day): string
{
foreach ($this->restrictions as $restriction) {
if (
$restriction instanceof Restriction && $restriction->isRestricted($day)
&& $restriction->getCode() == Restriction::WEEKLY
) {
return $restriction->getEnd($day)->format('H:i');
}
}
return '';
}
/**
* Gets the end of a restriction
* @return string
*/
public function getStartRestriction(\DateTime $day): string
{
foreach ($this->restrictions as $restriction) {
if (
$restriction instanceof Restriction && $restriction->isRestricted($day)
&& $restriction->getCode() == Restriction::WEEKLY
) {
return $restriction->getStart($day)->format('H:i');
}
}
return '';
}
public function getMaxUsers(): ?int
{
return $this->maxUsers;
}
public function setMaxUsers(?int $maxUsers): self
{
$this->maxUsers = $maxUsers;
return $this;
}
public function getPlan(): ?string
{
return $this->plan;
}
public function setPlan(?string $plan): self
{
$this->plan = $plan;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getIps(): ?array
{
return $this->ips;
}
public function setIps(?array $ips): self
{
$this->ips = $ips;
return $this;
}
public function getDomain(): ?array
{
return $this->domain;
}
public function setDomain(?array $domain): self
{
$this->domain = $domain;
return $this;
}
public function getHourlyRestriction(): ?int
{
return $this->hourlyRestriction;
}
public function setHourlyRestriction($hourlyRestriction): self
{
if (is_bool($hourlyRestriction)) {
if ($hourlyRestriction) {
$hourlyRestriction = 5;
} else {
$hourlyRestriction = 0;
}
}
$this->hourlyRestriction = $hourlyRestriction;
return $this;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(?string $code): self
{
$this->code = $code;
return $this;
}
/**
* @return Collection|Category[]
*/
public function getCategories(): Collection
{
return $this->categories;
}
public function addCategory(Category $category): self
{
if (!$this->categories->contains($category)) {
$this->categories[] = $category;
$category->setTvCompany($this);
}
return $this;
}
public function removeCategory(Category $category): self
{
if ($this->categories->removeElement($category)) {
// set the owning side to null (unless already changed)
if ($category->getTvCompany() === $this) {
$category->setTvCompany(null);
}
}
return $this;
}
/**
* @return Collection|Channel[]
*/
public function getChannels(): Collection
{
return $this->channels;
}
public function addChannel(Channel $channel): self
{
if (!$this->channels->contains($channel)) {
$this->channels[] = $channel;
$channel->setTvCompany($this);
}
return $this;
}
public function removeChannel(Channel $channel): self
{
if ($this->channels->removeElement($channel)) {
// set the owning side to null (unless already changed)
if ($channel->getTvCompany() === $this) {
$channel->setTvCompany(null);
}
}
return $this;
}
public function getCustomizable(): ?bool
{
return $this->customizable;
}
public function isCustomizable(): bool
{
return boolval($this->customizable);
}
public function setCustomizable(bool $customizable): self
{
$this->customizable = $customizable;
return $this;
}
/**
* @return string
* @Groups({"tv_company_read"})
*/
public function getUrl(): string
{
return $this->getSlug() . 'ulteamtv.fr';
}
public function __toString(): string
{
return "TvCompany #{$this->getId()}#: {$this->getName()}";
}
/**
* @return Collection|Department[]
*/
public function getDepartments(): Collection
{
return $this->departments;
}
public function addDepartment(Department $department): self
{
if (!$this->departments->contains($department)) {
$this->departments[] = $department;
$department->setTvCompany($this);
}
return $this;
}
public function removeDepartment(Department $department): self
{
if ($this->departments->removeElement($department)) {
// set the owning side to null (unless already changed)
if ($department->getTvCompany() === $this) {
$department->setTvCompany(null);
}
}
return $this;
}
public function getCms(): ?string
{
return $this->cms;
}
public function setCms(?string $cms): self
{
$this->cms = $cms;
return $this;
}
public function getCmsTitle(): ?string
{
return $this->cmsTitle;
}
public function setCmsTitle(?string $cmsTitle): self
{
$this->cmsTitle = $cmsTitle;
return $this;
}
public function getCmsImg(): ?MediaObject
{
return $this->cmsImg;
}
public function setCmsImg(?MediaObject $cmsImg): self
{
$this->cmsImg = $cmsImg;
return $this;
}
public function getCmsText(): ?string
{
return $this->cmsText;
}
public function setCmsText(?string $cmsText): self
{
$this->cmsText = $cmsText;
return $this;
}
public function getCmsCtaText(): ?string
{
return $this->cmsCtaText;
}
public function setCmsCtaText(?string $cmsCtaText): self
{
$this->cmsCtaText = $cmsCtaText;
return $this;
}
public function getCmsCtaUrl(): ?string
{
return $this->cmsCtaUrl;
}
public function setCmsCtaUrl(?string $cmsCtaUrl): self
{
$this->cmsCtaUrl = $cmsCtaUrl;
return $this;
}
/**
* @return Collection|ExclusionsChannel[]
*/
public function getExclusionsChannels(): Collection
{
return $this->exclusionsChannels;
}
public function addExclusionsChannel(ExclusionsChannel $exclusionsChannel): self
{
if (!$this->exclusionsChannels->contains($exclusionsChannel)) {
$this->exclusionsChannels[] = $exclusionsChannel;
$exclusionsChannel->setTvCompany($this);
}
return $this;
}
public function removeExclusionsChannel(ExclusionsChannel $exclusionsChannel): self
{
if ($this->exclusionsChannels->removeElement($exclusionsChannel)) {
// set the owning side to null (unless already changed)
if ($exclusionsChannel->getTvCompany() === $this) {
$exclusionsChannel->setTvCompany(null);
}
}
return $this;
}
/**
* @return Collection|ExclusionsCategory[]
*/
public function getExclusionsCategories(): Collection
{
return $this->exclusionsCategories;
}
public function addExclusionsCategory(ExclusionsCategory $exclusionsCategory): self
{
if (!$this->exclusionsCategories->contains($exclusionsCategory)) {
$this->exclusionsCategories[] = $exclusionsCategory;
$exclusionsCategory->setTvCompany($this);
}
return $this;
}
public function removeExclusionsCategory(ExclusionsCategory $exclusionsCategory): self
{
if ($this->exclusionsCategories->removeElement($exclusionsCategory)) {
// set the owning side to null (unless already changed)
if ($exclusionsCategory->getTvCompany() === $this) {
$exclusionsCategory->setTvCompany(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->setTvCompany($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->getTvCompany() === $this) {
$exclusionsVideo->setTvCompany(null);
}
}
return $this;
}
public function checkSubscriptionsDates(\DateTime $today)
{
return $today >= $this->subscriptionStart && $today <= $this->getSubscriptionEnd();
}
/**
* @return Collection|LogEmail[]
*/
public function getLogEmails(): Collection
{
return $this->logEmails;
}
public function addLogEmail(LogEmail $logEmail): self
{
if (!$this->logEmails->contains($logEmail)) {
$this->logEmails[] = $logEmail;
$logEmail->setTvCompany($this);
}
return $this;
}
public function removeLogEmail(LogEmail $logEmail): self
{
if ($this->logEmails->removeElement($logEmail)) {
// set the owning side to null (unless already changed)
if ($logEmail->getTvCompany() === $this) {
$logEmail->setTvCompany(null);
}
}
return $this;
}
/**
* @return Collection|Award[]
*/
public function getAwards(): Collection
{
return $this->awards;
}
public function addAward(Award $award): self
{
if (!$this->awards->contains($award)) {
$this->awards[] = $award;
$award->addTvCompany($this);
}
return $this;
}
public function removeAward(Award $award): self
{
if ($this->awards->removeElement($award)) {
$award->removeTvCompany($this);
}
return $this;
}
/**
* @Groups({"tv_company_read"})
*/
public function getActiveAward()
{
$award = null;
$today = (new \DateTime("now"))->setTime(0, 0, 0);
foreach ($this->awards->toArray() as $value) {
if ($value->getActive() && $value->getDateStart() <= $today && $value->getDateEnd() >= $today) {
$award = $value;
}
}
return $award;
}
/**
* @return Collection|Association[]
*/
public function getAssociations(): Collection
{
return $this->associations;
}
public function addAssociation(Association $association): self
{
if (!$this->associations->contains($association)) {
$this->associations[] = $association;
}
return $this;
}
public function removeAssociation(Association $association): self
{
$this->associations->removeElement($association);
return $this;
}
/**
* @return Collection|Program[]
*/
public function getPrograms(): Collection
{
return $this->programs;
}
public function addProgram(Program $program): self
{
if (!$this->programs->contains($program)) {
$this->programs[] = $program;
$program->setTvCompany($this);
}
return $this;
}
public function removeProgram(Program $program): self
{
if ($this->programs->removeElement($program)) {
// set the owning side to null (unless already changed)
if ($program->getTvCompany() === $this) {
$program->setTvCompany(null);
}
}
return $this;
}
public function getResaLinkActive(): ?bool
{
return $this->resaLinkActive;
}
public function setResaLinkActive(?bool $resaLinkActive): self
{
$this->resaLinkActive = $resaLinkActive;
return $this;
}
/**
* @return Collection|Team[]
*/
public function getTeams(): Collection
{
return $this->teams;
}
public function addTeam(Team $team): self
{
if (!$this->teams->contains($team)) {
$this->teams[] = $team;
$team->setTvCompany($this);
}
return $this;
}
public function removeTeam(Team $team): self
{
if ($this->teams->removeElement($team)) {
// set the owning side to null (unless already changed)
if ($team->getTvCompany() === $this) {
$team->setTvCompany(null);
}
}
return $this;
}
/**
* Récupère un array de team de type = "teamplay"
* @return Team[]|null
*/
public function getTeamplayTeams(): ?array
{
$teamplayTeams = null;
if (!empty($this->teams->toArray())) {
$teamplayTeams = [];
foreach ($this->teams->toArray() as $team) {
if ($team->isTeamplay()) $teamplayTeams[] = $team;
}
}
return $teamplayTeams;
}
/**
* @return Collection|Teamplay[]
*/
public function getTeamplays(): Collection
{
return $this->teamplays;
}
public function addTeamplay(Teamplay $teamplay): self
{
if (!$this->teamplays->contains($teamplay)) {
$this->teamplays[] = $teamplay;
$teamplay->setTvCompany($this);
}
return $this;
}
public function removeTeamplay(Teamplay $teamplay): self
{
if ($this->teamplays->removeElement($teamplay)) {
// set the owning side to null (unless already changed)
if ($teamplay->getTvCompany() === $this) {
$teamplay->setTvCompany(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->setTvCompany($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->getTvCompany() === $this) {
$teamplayChallenge->setTvCompany(null);
}
}
return $this;
}
/**
* @return Collection|TeamplayLog[]
*/
public function getTeamplayLogs(): Collection
{
return $this->teamplayLogs;
}
public function addTeamplayLog(TeamplayLog $teamplayLog): self
{
if (!$this->teamplayLogs->contains($teamplayLog)) {
$this->teamplayLogs[] = $teamplayLog;
$teamplayLog->setTvCompany($this);
}
return $this;
}
public function removeTeamplayLog(TeamplayLog $teamplayLog): self
{
if ($this->teamplayLogs->removeElement($teamplayLog)) {
// set the owning side to null (unless already changed)
if ($teamplayLog->getTvCompany() === $this) {
$teamplayLog->setTvCompany(null);
}
}
return $this;
}
/**
* @return Collection|PedometerLog[]
*/
public function getPedometerLogs(): Collection
{
return $this->pedometerLogs;
}
public function addPedometerLog(PedometerLog $pedometerLog): self
{
if (!$this->pedometerLogs->contains($pedometerLog)) {
$this->pedometerLogs[] = $pedometerLog;
$pedometerLog->setTvCompany($this);
}
return $this;
}
public function removePedometerLog(PedometerLog $pedometerLog): self
{
if ($this->pedometerLogs->removeElement($pedometerLog)) {
// set the owning side to null (unless already changed)
if ($pedometerLog->getTvCompany() === $this) {
$pedometerLog->setTvCompany(null);
}
}
return $this;
}
/**
* @return Collection|Log[]
*/
public function getLogs(): Collection
{
return $this->logs;
}
public function addLog(Log $log): self
{
if (!$this->logs->contains($log)) {
$this->logs[] = $log;
$log->setTvCompany($this);
}
return $this;
}
public function removeLog(Log $log): self
{
if ($this->logs->removeElement($log)) {
// set the owning side to null (unless already changed)
if ($log->getTvCompany() === $this) {
$log->setTvCompany(null);
}
}
return $this;
}
/**
* @return Collection<int, UserNotification>
*/
public function getUserNotifications(): Collection
{
return $this->userNotifications;
}
public function addUserNotification(UserNotification $userNotification): self
{
if (!$this->userNotifications->contains($userNotification)) {
$this->userNotifications[] = $userNotification;
$userNotification->setTvCompany($this);
}
return $this;
}
public function removeUserNotification(UserNotification $userNotification): self
{
if ($this->userNotifications->removeElement($userNotification)) {
// set the owning side to null (unless already changed)
if ($userNotification->getTvCompany() === $this) {
$userNotification->setTvCompany(null);
}
}
return $this;
}
/**
* @return Collection<int, Slide>
*/
public function getSlides(): Collection
{
return $this->slides;
}
public function addSlide(Slide $slide): self
{
if (!$this->slides->contains($slide)) {
$this->slides[] = $slide;
$slide->setTvCompany($this);
}
return $this;
}
public function removeSlide(Slide $slide): self
{
if ($this->slides->removeElement($slide)) {
// set the owning side to null (unless already changed)
if ($slide->getTvCompany() === $this) {
$slide->setTvCompany(null);
}
}
return $this;
}
/**
* @return Collection<int, AwardConfig>
*/
public function getAwardConfigs(): Collection
{
return $this->awardConfigs;
}
public function addAwardConfig(AwardConfig $awardConfig): self
{
if (!$this->awardConfigs->contains($awardConfig)) {
$this->awardConfigs[] = $awardConfig;
$awardConfig->setTvCompany($this);
}
return $this;
}
public function removeAwardConfig(AwardConfig $awardConfig): self
{
if ($this->awardConfigs->removeElement($awardConfig)) {
// set the owning side to null (unless already changed)
if ($awardConfig->getTvCompany() === $this) {
$awardConfig->setTvCompany(null);
}
}
return $this;
}
public function getCompany(): ?Company
{
return $this->company;
}
public function setCompany(?Company $company): self
{
$this->company = $company;
return $this;
}
}