<?php
namespace App\Entity\Site;
use App\Entity\Federation\Race;
use App\Entity\Federation\Team;
use App\Entity\Media\DocumentType;
use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use App\Entity\User\Alert;
/**
* @ORM\Entity(repositoryClass="App\Repository\Site\SiteRepository")
* @ORM\Table(name="sites")
* @UniqueEntity("name")
*/
class Site
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @Gedmo\Slug(fields={"name"})
* @ORM\Column(length=255, unique=true)
*/
private $url;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Assert\NotBlank()
*/
private $domain;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Assert\NotBlank()
*/
private $email;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Assert\NotBlank()
*/
private $name;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $favicon;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $logo;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $cover;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $firstColor;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $secondColor;
/**
* @ORM\Column(type="datetime", nullable=true)
* @Assert\NotBlank()
*/
private $startDate;
/**
* @ORM\Column(type="datetime", nullable=true)
* @Assert\NotBlank()
*/
private $endDate;
/**
* @ORM\Column(type="datetime", nullable=false, name="created_date")
* @Gedmo\Timestampable(on="create")
*/
private $createdDate;
/**
* @ORM\Column(type="datetime", nullable=true, name="updated_date")
* @Gedmo\Timestampable(on="update")
*/
private $updatedDate;
/**
* @ORM\Column(type="integer", nullable=false, name="status")
*/
private $status = 1;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Site\AccessSite", mappedBy="site", cascade={"remove"})
*/
private $accessSites;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Federation\Race", inversedBy="sites")
* @ORM\JoinColumn(name="race_id", referencedColumnName="id")
*/
private $race;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Federation\Team", inversedBy="sites")
* @ORM\JoinColumn(name="team_id", referencedColumnName="id")
*/
private $team;
/**
* @ORM\OneToMany(targetEntity="App\Entity\User\Alert", mappedBy="site", cascade={"remove"})
*/
private $alerts;
/**
* @var array
*
* @ORM\Column(name="notification_settings", type="json", nullable=true)
*/
private $notificationSettings = [];
public function __construct()
{
$this->accessSites = new ArrayCollection();
$this->alerts = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getUrl(): ?string
{
return $this->url;
}
public function getDomain(): ?string
{
return $this->domain;
}
public function setDomain(?string $domain): self
{
$this->domain = $domain;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getFavicon(): ?string
{
return $this->favicon;
}
public function setFavicon(?string $favicon): self
{
$this->favicon = $favicon;
return $this;
}
public function getLogo(): ?string
{
return $this->logo;
}
public function setLogo(?string $logo): self
{
$this->logo = $logo;
return $this;
}
public function getCover(): ?string
{
return $this->cover;
}
public function setCover(?string $cover): self
{
$this->cover = $cover;
return $this;
}
public function getFirstColor(): ?string
{
return $this->firstColor;
}
public function setFirstColor(?string $firstColor): self
{
$this->firstColor = $firstColor;
return $this;
}
public function getSecondColor(): ?string
{
return $this->secondColor;
}
public function setSecondColor(?string $secondColor): self
{
$this->secondColor = $secondColor;
return $this;
}
public function getCreatedDate(): ?\DateTimeInterface
{
return $this->createdDate;
}
public function getUpdatedDate(): ?\DateTimeInterface
{
return $this->updatedDate;
}
public function getStartDate(): ?\DateTimeInterface
{
return $this->startDate;
}
public function setStartDate(?\DateTimeInterface $startDate): self
{
$this->startDate = $startDate;
return $this;
}
public function getEndDate(): ?\DateTimeInterface
{
return $this->endDate;
}
public function setEndDate(?\DateTimeInterface $endDate): self
{
$this->endDate = $endDate;
return $this;
}
public function getStatus(): ?int
{
return $this->status;
}
public function setStatus(int $status): self
{
$this->status = $status;
return $this;
}
/**
* @return Collection|AccessSite[]
*/
public function getAccessSites(): Collection
{
return $this->accessSites;
}
public function addAccessSite(AccessSite $accessSite): self
{
if (!$this->accessSites->contains($accessSite)) {
$this->accessSites[] = $accessSite;
$accessSite->setSite($this);
}
return $this;
}
public function removeAccessSite(AccessSite $accessSite): self
{
if ($this->accessSites->contains($accessSite)) {
$this->accessSites->removeElement($accessSite);
// set the owning side to null (unless already changed)
if ($accessSite->getSite() === $this) {
$accessSite->setSite(null);
}
}
return $this;
}
/**
* @return Collection|Alert[]
*/
public function getAlerts(): Collection
{
return $this->alerts;
}
public function addAlert(Alert $alert): self
{
if (!$this->alerts->contains($alert)) {
$this->alerts[] = $alert;
}
return $this;
}
public function removeAlert(Alert $alert): self
{
if ($this->alerts->contains($alert)) {
$this->alerts->removeElement($alert);
}
return $this;
}
public function getRace(): ?Race
{
return $this->race;
}
public function setRace(?Race $race): self
{
$this->race = $race;
return $this;
}
public function getTeam(): ?Team
{
return $this->team;
}
public function setTeam(?Team $team): self
{
$this->team = $team;
return $this;
}
public function getNotificationSettings(): array
{
return $this->notificationSettings;
}
public function setNotificationSettings(array $notificationSettings): void
{
$this->notificationSettings = $notificationSettings;
}
public function __toString(): string
{
return $this->name;
}
}