<?php
namespace App\CasinoBundle\Entity;
use App\CasinoBundle\Enum\AuthorTypeEnum;
use App\CmsBundle\Entity\Page;
use App\CmsBundle\Entity\Route;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use App\CmsBundle\Entity\TimeStampedTrait;
use App\CmsBundle\Entity\ContentTrait;
/**
* @ORM\Entity(repositoryClass="App\CasinoBundle\Repository\AuthorRepository")
* @ORM\Table(
* name="author",
* indexes={
* @ORM\Index(name="author_role_index", columns={"author_role"}),
* }
* )
* @ORM\HasLifecycleCallbacks()
*/
class Author
{
use TimeStampedTrait,
ContentTrait,
PriorityTrait;
const WEBPATH = '/cdn/team/';
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $location;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $role;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $email;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $facebook;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $twitter;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $linkedIn;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $photo;
/**
* Unmapped property to handle file uploads
*/
private $file;
/**
* @ORM\OneToMany(targetEntity="App\CasinoBundle\Entity\Article", mappedBy="author")
*/
public $articles;
/**
* @ORM\ManyToOne(targetEntity="App\CasinoBundle\Entity\Team", inversedBy="members")
*/
public $team;
/**
* @ORM\Column(name="favorite_games", type="string", nullable=true)
*/
private ?string $favoriteGames = null;
/**
* @ORM\Column(name="area_of_expertise", type="text", nullable=true)
*/
private ?string $areaOfExpertise = null;
/**
* @ORM\Column(name="author_role", type="integer", nullable=false, options={"default": 0})
*/
private int $authorRole = 0;
public function __toString(): string
{
return $this->getName();
}
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 getLocation(): ?string
{
return $this->location;
}
public function setLocation(?string $Location): self
{
$this->location = $Location;
return $this;
}
/**
* @return string|null
*/
public function getFavoriteGames(): ?string
{
return $this->favoriteGames;
}
/**
* @param string|null $favoriteGames
* @return $this
*/
public function setFavoriteGames(?string $favoriteGames): self
{
$this->favoriteGames = $favoriteGames;
return $this;
}
/**
* @return string|null
*/
public function getAreaOfExpertise(): ?string
{
return $this->areaOfExpertise;
}
/**
* @param string|null $areaOfExpertise
* @return $this
*/
public function setAreaOfExpertise(?string $areaOfExpertise): self
{
$this->areaOfExpertise = $areaOfExpertise;
return $this;
}
/**
* @return int
*/
public function getAuthorRole(): int
{
return $this->authorRole;
}
/**
* @param int $authorRole
* @return $this
*/
public function setAuthorRole(int $authorRole): self
{
AuthorTypeEnum::assertExists($authorRole);
$this->authorRole = $authorRole;
return $this;
}
public function getRole(): ?string
{
return $this->role;
}
public function setRole(?string $role): self
{
$this->role = $role;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getFacebook(): ?string
{
return $this->facebook;
}
public function setFacebook(?string $facebook): self
{
$this->facebook = $facebook;
return $this;
}
public function getTwitter(): ?string
{
return $this->twitter;
}
public function setTwitter(?string $twitter): self
{
$this->twitter = $twitter;
return $this;
}
public function getLinkedIn(): ?string
{
return $this->linkedIn;
}
public function setLinkedIn(?string $linkedIn): self
{
$this->linkedIn = $linkedIn;
return $this;
}
public function getTeam(): ?Team
{
return $this->team;
}
public function setTeam(?Team $team): self
{
$this->team = $team;
return $this;
}
public function getPhoto(): ?string
{
return $this->photo;
}
public function setPhoto(?string $photo): self
{
$this->photo = $photo;
return $this;
}
/**
* @param UploadedFile $file
*/
public function setFile(UploadedFile $file = null)
{
$this->file = $file;
}
/**
* @return UploadedFile
*/
public function getFile()
{
return $this->file;
}
/**
* Manages the copying of the file to the relevant place on the server
* @ORM\PrePersist()
* @ORM\PreUpdate()
*/
public function upload()
{
if (null === $this->getFile()) {
return;
}
$filename = $this->getFile()->getClientOriginalName();
$this->photo = self::WEBPATH . $filename;
$this->setFile(null);
}
/**
* Lifecycle callback to upload the file to the server.
*/
public function lifecycleFileUpload()
{
$this->upload();
}
/**
* Updates the hash value to force the preUpdate and postUpdate events to fire.
*/
public function refreshUpdated()
{
$this->setUpdated(new \DateTime());
}
}