<?php
namespace App\Entity\Event;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Filesystem\Filesystem;
/**
* EventClub
*
* @ORM\Table(name="tam_event_club")
* @ORM\Entity(repositoryClass="App\Repository\Event\EventClubRepository")
*/
class EventClub
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var \App\Entity\Club\Club
*
* @ORM\ManyToOne(targetEntity="\App\Entity\Club\Club", fetch="EAGER", inversedBy="events")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="club", referencedColumnName="id", onDelete="SET NULL")
* })
*/
private $club;
/**
* @var \App\Entity\Event\EventType
*
* @ORM\ManyToOne(targetEntity="\App\Entity\Event\EventType", fetch="EAGER", inversedBy="clubEvents")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="event_type", referencedColumnName="id", onDelete="SET NULL")
* })
*/
private $eventType;
/**
* @var string
*
* @ORM\Column(name="title", type="string", length=255, nullable=true)
*/
private $title;
/**
* @var string
*
* @ORM\Column(name="description", type="text", nullable=true)
*/
private $description;
/**
* @var \DateTime
*
* @ORM\Column(name="date_begin", type="datetime", nullable=false)
*/
private $dateBegin;
/**
* @var \DateTime
*
* @ORM\Column(name="date_end", type="datetime", nullable=false)
*/
private $dateEnd;
/**
* @var string
*
* @ORM\Column(name="place_name", type="string", length=255, nullable=true)
*/
private $placeName;
/**
* @var string
*
* @ORM\Column(name="place_address", type="string", length=255, nullable=true)
*/
private $placeAddress;
/**
* @var string
*
* @ORM\Column(name="place_zipcode", type="string", length=255, nullable=true)
*/
private $placeZipcode;
/**
* @var string
*
* @ORM\Column(name="place_city", type="string", length=255, nullable=true)
*/
private $placeCity;
/**
* @var string
*
* @ORM\Column(name="place_country", type="string", length=255, nullable=true)
*/
private $placeCountry;
/**
* @var string
*
* @ORM\Column(name="lat", type="decimal", precision=10, scale=0, nullable=true)
*/
private $lat;
/**
* @var string
*
* @ORM\Column(name="lng", type="decimal", precision=10, scale=0, nullable=true)
*/
private $lng;
/**
* @var \App\Entity\Surface
*
* @ORM\ManyToOne(targetEntity="\App\Entity\Surface", fetch="EAGER", inversedBy="events")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="surface", referencedColumnName="id", onDelete="SET NULL")
* })
*/
private $surface;
/**
* @var boolean
*
* @ORM\Column(name="clubhouse", type="boolean", options={"default": FALSE})
*/
private $clubhouse;
/**
* @var boolean
*
* @ORM\Column(name="lockerroom", type="boolean", options={"default": FALSE})
*/
private $lockerroom;
/**
* @var string
*
* @ORM\Column(name="contact_name", type="string", length=255, nullable=true)
*/
private $contactName;
/**
* @var string
*
* @ORM\Column(name="contact_address", type="string", length=255, nullable=true)
*/
private $contactAddress;
/**
* @var string
*
* @ORM\Column(name="contact_zipcode", type="string", length=255, nullable=true)
*/
private $contactZipcode;
/**
* @var string
*
* @ORM\Column(name="contact_city", type="string", length=255, nullable=true)
*/
private $contactCity;
/**
* @var string
*
* @ORM\Column(name="contact_country", type="string", length=255, nullable=true)
*/
private $contactCountry;
/**
* @var string
*
* @ORM\Column(name="contact_phone", type="string", length=255, nullable=true)
*/
private $contactPhone;
/**
* @var string
*
* @ORM\Column(name="contact_mobile", type="string", length=255, nullable=true)
*/
private $contactMobile;
/**
* @var string
*
* @ORM\Column(name="contact_email", type="string", length=255, nullable=true)
*/
private $contactEmail;
/**
* @var \DateTime
*
* @ORM\Column(name="date_created", type="datetime", nullable=false)
*/
private $dateCreated;
/**
* @var \DateTime
*
* @ORM\Column(name="date_updated", type="datetime", nullable=true)
*/
private $dateUpdated;
/**
* @var boolean
*
* @ORM\Column(name="active", type="boolean", options={"default": FALSE})
*/
private $active;
/**
* @var string
*
* @ORM\Column(name="illustration", type="string", length=255, nullable=true)
*/
private $illustration;
/**
* Image illustrationFile
*
* @var File
*
* @Assert\File(
* maxSize = "5M",
* mimeTypes = {"image/jpeg", "image/gif", "image/png", "image/tiff"},
* maxSizeMessage = "The maxmimum allowed file size is 5MB.",
* mimeTypesMessage = "Only the filetypes image are allowed."
* )
*/
protected $illustrationFile;
public function __construct()
{
$this->active = true;
$this->dateCreated = new \DateTime();
$this->dateUpdated = new \DateTime();
$this->illustrationFile = null;
}
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set club
*
* @param RankingSystem $club
*
* @return EventClub
*/
public function setClub($club)
{
$this->club = $club;
return $this;
}
/**
* Get club
*
* @return Club
*/
public function getClub()
{
return $this->club;
}
/**
* Set eventType
*
* @param RankingSystem $eventType
*
* @return EventClub
*/
public function setEventType($eventType)
{
$this->eventType = $eventType;
return $this;
}
/**
* Get eventType
*
* @return EventType
*/
public function getEventType()
{
return $this->eventType;
}
/**
* Set title
*
* @param string $title
*
* @return EventClub
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set description
*
* @param string $description
*
* @return EventClub
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Set dateBegin
*
* @param \DateTime $dateBegin
*
* @return EventClub
*/
public function setDateBegin($dateBegin)
{
$this->dateBegin = $dateBegin;
return $this;
}
/**
* Get dateBegin
*
* @return \DateTime
*/
public function getDateBegin()
{
return $this->dateBegin;
}
/**
* Set dateEnd
*
* @param \DateTime $dateEnd
*
* @return EventClub
*/
public function setDateEnd($dateEnd)
{
$this->dateEnd = $dateEnd;
return $this;
}
/**
* Get dateEnd
*
* @return \DateTime
*/
public function getDateEnd()
{
return $this->dateEnd;
}
/**
* Set placeName
*
* @param string $placeName
*
* @return EventClub
*/
public function setPlaceName($placeName)
{
$this->placeName = $placeName;
return $this;
}
/**
* Get placeName
*
* @return string
*/
public function getPlaceName()
{
return $this->placeName;
}
/**
* Set placeAddress
*
* @param string $placeAddress
*
* @return EventClub
*/
public function setPlaceAddress($placeAddress)
{
$this->placeAddress = $placeAddress;
return $this;
}
/**
* Get placeAddress
*
* @return string
*/
public function getPlaceAddress()
{
return $this->placeAddress;
}
/**
* Set placeZipcode
*
* @param string $placeZipcode
*
* @return EventClub
*/
public function setPlaceZipcode($placeZipcode)
{
$this->placeZipcode = $placeZipcode;
return $this;
}
/**
* Get placeZipcode
*
* @return string
*/
public function getPlaceZipcode()
{
return $this->placeZipcode;
}
/**
* Set placeCity
*
* @param string $placeCity
*
* @return EventClub
*/
public function setPlaceCity($placeCity)
{
$this->placeCity = $placeCity;
return $this;
}
/**
* Get placeCity
*
* @return string
*/
public function getPlaceCity()
{
return $this->placeCity;
}
/**
* Set placeCountry
*
* @param string $placeCountry
*
* @return EventClub
*/
public function setPlaceCountry($placeCountry)
{
$this->placeCountry = $placeCountry;
return $this;
}
/**
* Get placeCountry
*
* @return string
*/
public function getPlaceCountry()
{
return $this->placeCountry;
}
/**
* Set lat
*
* @param string $lat
* @return EventClub
*/
public function setLat($lat)
{
$this->lat = $lat;
return $this;
}
/**
* Get lat
*
* @return string
*/
public function getLat()
{
return $this->lat;
}
/**
* Set lng
*
* @param string $lng
* @return EventClub
*/
public function setLng($lng)
{
$this->lng = $lng;
return $this;
}
/**
* Get lng
*
* @return string
*/
public function getLng()
{
return $this->lng;
}
/**
* Set surface
*
* @param Surface $surface
*
* @return EventClub
*/
public function setSurface($surface)
{
$this->surface = $surface;
return $this;
}
/**
* Get surface
*
* @return Surface
*/
public function getSurface()
{
return $this->surface;
}
/**
* Set clubhouse
*
* @param boolean $clubhouse
*
* @return EventClub
*/
public function setClubhouse($clubhouse)
{
$this->clubhouse = $clubhouse;
return $this;
}
/**
* Get clubhouse
*
* @return boolean
*/
public function getClubhouse()
{
return $this->clubhouse;
}
/**
* Set lockerroom
*
* @param boolean $lockerroom
*
* @return EventClub
*/
public function setLockerroom($lockerroom)
{
$this->lockerroom = $lockerroom;
return $this;
}
/**
* Get lockerroom
*
* @return boolean
*/
public function getLockerroom()
{
return $this->lockerroom;
}
/**
* Set contactName
*
* @param string $contactName
*
* @return EventClub
*/
public function setContactName($contactName)
{
$this->contactName = $contactName;
return $this;
}
/**
* Get contactName
*
* @return string
*/
public function getContactName()
{
return $this->contactName;
}
/**
* Set contactAddress
*
* @param string $contactAddress
*
* @return EventClub
*/
public function setContactAddress($contactAddress)
{
$this->contactAddress = $contactAddress;
return $this;
}
/**
* Get contactAddress
*
* @return string
*/
public function getContactAddress()
{
return $this->contactAddress;
}
/**
* Set contactZipcode
*
* @param string $contactZipcode
*
* @return EventClub
*/
public function setContactZipcode($contactZipcode)
{
$this->contactZipcode = $contactZipcode;
return $this;
}
/**
* Get contactZipcode
*
* @return string
*/
public function getContactZipcode()
{
return $this->contactZipcode;
}
/**
* Set contactCity
*
* @param string $contactCity
*
* @return EventClub
*/
public function setContactCity($contactCity)
{
$this->contactCity = $contactCity;
return $this;
}
/**
* Get contactCity
*
* @return string
*/
public function getContactCity()
{
return $this->contactCity;
}
/**
* Set contactCountry
*
* @param string $contactCountry
*
* @return EventClub
*/
public function setContactCountry($contactCountry)
{
$this->contactCountry = $contactCountry;
return $this;
}
/**
* Get contactCountry
*
* @return string
*/
public function getContactCountry()
{
return $this->contactCountry;
}
/**
* Set contactPhone
*
* @param string $contactPhone
*
* @return EventClub
*/
public function setContactPhone($contactPhone)
{
$this->contactPhone = $contactPhone;
return $this;
}
/**
* Get contactPhone
*
* @return string
*/
public function getContactPhone()
{
return $this->contactPhone;
}
/**
* Set contactMobile
*
* @param string $contactMobile
*
* @return EventClub
*/
public function setContactMobile($contactMobile)
{
$this->contactMobile = $contactMobile;
return $this;
}
/**
* Get contactMobile
*
* @return string
*/
public function getContactMobile()
{
return $this->contactMobile;
}
/**
* Set contactEmail
*
* @param string $contactEmail
*
* @return EventClub
*/
public function setContactEmail($contactEmail)
{
$this->contactEmail = $contactEmail;
return $this;
}
/**
* Get contactEmail
*
* @return string
*/
public function getContactEmail()
{
return $this->contactEmail;
}
/**
* Set dateCreated
*
* @param \DateTime $dateCreated
*
* @return EventClub
*/
public function setDateCreated($dateCreated)
{
$this->dateCreated = $dateCreated;
return $this;
}
/**
* Get dateCreated
*
* @return \DateTime
*/
public function getDateCreated()
{
return $this->dateCreated;
}
/**
* Set dateUpdated
*
* @param \DateTime $dateUpdated
*
* @return EventClub
*/
public function setDateUpdated($dateUpdated)
{
$this->dateUpdated = $dateUpdated;
return $this;
}
/**
* Get dateUpdated
*
* @return \DateTime
*/
public function getDateUpdated()
{
return $this->dateUpdated;
}
/**
* Set active
*
* @param boolean $active
*
* @return EventClub
*/
public function setActive($active)
{
$this->active = $active;
return $this;
}
/**
* Get active
*
* @return boolean
*/
public function getActive()
{
return $this->active;
}
/**
* Set illustration
*
* @param string $illustration
*
* @return EventClub
*/
public function setIllustration($illustration)
{
$this->illustration = $illustration;
return $this;
}
/**
* Get illustration
*
* @return string
*/
public function getIllustration()
{
return $this->illustration;
}
public function getLinkIllustration()
{
if($this->getIllustration()){
if(file_exists($this->getUploadIllustrationRootDir().$this->getIllustration()))
return $this->getIllustrationDir().$this->getIllustration();
else
return null;
}else{
return null;
}
}
public function getAbsolutePathIllustration()
{
if($this->getIllustration()){
if(file_exists($this->getUploadIllustrationRootDir().$this->getIllustration()))
return $this->getUploadIllustrationRootDir().$this->getIllustrationPath();
else
return null;
}else{
return null;
}
}
/**
* Sets avatarFile.
*
* @param UploadedFile $file
*/
public function setIllustrationFile(UploadedFile $file = null)
{
$this->illustrationFile = $file;
}
/**
* Get illustrationFile.
*
* @return UploadedFile
*/
public function getIllustrationFile()
{
return $this->IllustrationFile;
}
/***********************
* Lifecycle Callbacks
***********************/
/**
*
* @ORM\PrePersist()
* @ORM\PreUpdate()
*/
public function UpdateDate()
{
$this->setDateUpdated(new \DateTime());
}
/**
* Called before saving the entity
*
* @ORM\PrePersist()
* @ORM\PreUpdate()
*/
public function preUpload()
{
if (null !== $this->avatarFile) {
// do whatever you want to generate a unique name
$filename = sha1(uniqid(mt_rand(), true));
$this->illustration = $filename.'.'.$this->illustrationFile->guessExtension();
$this->setDateUpdated(new \DateTime());
}
}
/**
* Called before entity removal
*
* @ORM\PreRemove()
*/
public function removeUpload()
{
if ($file = $this->getAbsolutePathAvatar()) {
unlink($file);
}
}
/**
* Called after entity persistence
*
* @ORM\PostPersist()
* @ORM\PostUpdate()
*/
public function upload()
{
// The file property can be empty if the field is not required
if (null === $this->illustrationFile) {
return;
}
// Use the original file name here but you should
// sanitize it at least to avoid any security issues
// move takes the target directory and then the
// target filename to move to
$this->illustrationFile->move(
$this->getUploadAvatarRootDir(),
$this->illustration
);
// Set the path property to the filename where you've saved the file
//$this->path = $this->file->getClientOriginalName();
// Clean up the file property as you won't need it anymore
$this->illustrationFile = null;
}
/***********************
* OTHER FUNCTION
***********************/
public function getUploadIllustrationRootDir(){
$logoDir = __DIR__ . '/../../../web/club/'.$this->getClub()->getId().'/events/';
$fs = new Filesystem();
if ($fs->exists($logoDir) == false) {
$fs->mkdir($logoDir);
}
return $logoDir;
}
public function getIllustrationDir()
{
return 'club/'.$this->getClub()->getId().'/events/';
}
}