src/CasinoBundle/Entity/Author.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\CasinoBundle\Entity;
  3. use App\CasinoBundle\Enum\AuthorTypeEnum;
  4. use App\CmsBundle\Entity\Page;
  5. use App\CmsBundle\Entity\Route;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\HttpFoundation\File\UploadedFile;
  8. use App\CmsBundle\Entity\TimeStampedTrait;
  9. use App\CmsBundle\Entity\ContentTrait;
  10. /**
  11.  * @ORM\Entity(repositoryClass="App\CasinoBundle\Repository\AuthorRepository")
  12.  * @ORM\Table(
  13.  *      name="author",
  14.  *      indexes={
  15.  *          @ORM\Index(name="author_role_index", columns={"author_role"}),
  16.  *      }
  17.  *  )
  18.  * @ORM\HasLifecycleCallbacks()
  19.  */
  20. class Author
  21. {
  22.     use TimeStampedTrait,
  23.         ContentTrait,
  24.         PriorityTrait;
  25.     const WEBPATH '/cdn/team/';
  26.     /**
  27.      * @ORM\Id()
  28.      * @ORM\GeneratedValue()
  29.      * @ORM\Column(type="integer")
  30.      */
  31.     private $id;
  32.     /**
  33.      * @ORM\Column(type="string", length=255)
  34.      */
  35.     private $name;
  36.     /**
  37.      * @ORM\Column(type="string", length=255, nullable=true)
  38.      */
  39.     private $location;
  40.     /**
  41.      * @ORM\Column(type="string", length=255, nullable=true)
  42.      */
  43.     private $role;
  44.     /**
  45.      * @ORM\Column(type="string", length=255, nullable=true)
  46.      */
  47.     private $email;
  48.     /**
  49.      * @ORM\Column(type="string", length=255, nullable=true)
  50.      */
  51.     private $facebook;
  52.     /**
  53.      * @ORM\Column(type="string", length=255, nullable=true)
  54.      */
  55.     private $twitter;
  56.     /**
  57.      * @ORM\Column(type="string", length=255, nullable=true)
  58.      */
  59.     private $linkedIn;
  60.     /**
  61.      * @ORM\Column(type="string", length=255, nullable=true)
  62.      */
  63.     private $photo;
  64.     /**
  65.      * Unmapped property to handle file uploads
  66.      */
  67.     private $file;
  68.     /**
  69.      * @ORM\OneToMany(targetEntity="App\CasinoBundle\Entity\Article", mappedBy="author")
  70.      */
  71.     public $articles;
  72.     /**
  73.      * @ORM\ManyToOne(targetEntity="App\CasinoBundle\Entity\Team", inversedBy="members")
  74.      */
  75.     public $team;
  76.     /**
  77.      * @ORM\Column(name="favorite_games", type="string", nullable=true)
  78.      */
  79.     private ?string $favoriteGames null;
  80.     /**
  81.      * @ORM\Column(name="area_of_expertise", type="text", nullable=true)
  82.      */
  83.     private ?string $areaOfExpertise null;
  84.     /**
  85.      * @ORM\Column(name="author_role", type="integer", nullable=false, options={"default": 0})
  86.      */
  87.     private int $authorRole 0;
  88.     public function __toString(): string
  89.     {
  90.         return $this->getName();
  91.     }
  92.     public function getId(): ?int
  93.     {
  94.         return $this->id;
  95.     }
  96.     public function getName(): ?string
  97.     {
  98.         return $this->name;
  99.     }
  100.     public function setName(string $name): self
  101.     {
  102.         $this->name $name;
  103.         return $this;
  104.     }
  105.     public function getLocation(): ?string
  106.     {
  107.         return $this->location;
  108.     }
  109.     public function setLocation(?string $Location): self
  110.     {
  111.         $this->location $Location;
  112.         return $this;
  113.     }
  114.     /**
  115.      * @return string|null
  116.      */
  117.     public function getFavoriteGames(): ?string
  118.     {
  119.         return $this->favoriteGames;
  120.     }
  121.     /**
  122.      * @param string|null $favoriteGames
  123.      * @return $this
  124.      */
  125.     public function setFavoriteGames(?string $favoriteGames): self
  126.     {
  127.         $this->favoriteGames $favoriteGames;
  128.         return $this;
  129.     }
  130.     /**
  131.      * @return string|null
  132.      */
  133.     public function getAreaOfExpertise(): ?string
  134.     {
  135.         return $this->areaOfExpertise;
  136.     }
  137.     /**
  138.      * @param string|null $areaOfExpertise
  139.      * @return $this
  140.      */
  141.     public function setAreaOfExpertise(?string $areaOfExpertise): self
  142.     {
  143.         $this->areaOfExpertise $areaOfExpertise;
  144.         return $this;
  145.     }
  146.     /**
  147.      * @return int
  148.      */
  149.     public function getAuthorRole(): int
  150.     {
  151.         return $this->authorRole;
  152.     }
  153.     /**
  154.      * @param int $authorRole
  155.      * @return $this
  156.      */
  157.     public function setAuthorRole(int $authorRole): self
  158.     {
  159.         AuthorTypeEnum::assertExists($authorRole);
  160.         $this->authorRole $authorRole;
  161.         return $this;
  162.     }
  163.     public function getRole(): ?string
  164.     {
  165.         return $this->role;
  166.     }
  167.     public function setRole(?string $role): self
  168.     {
  169.         $this->role $role;
  170.         return $this;
  171.     }
  172.     public function getEmail(): ?string
  173.     {
  174.         return $this->email;
  175.     }
  176.     public function setEmail(?string $email): self
  177.     {
  178.         $this->email $email;
  179.         return $this;
  180.     }
  181.     public function getFacebook(): ?string
  182.     {
  183.         return $this->facebook;
  184.     }
  185.     public function setFacebook(?string $facebook): self
  186.     {
  187.         $this->facebook $facebook;
  188.         return $this;
  189.     }
  190.     public function getTwitter(): ?string
  191.     {
  192.         return $this->twitter;
  193.     }
  194.     public function setTwitter(?string $twitter): self
  195.     {
  196.         $this->twitter $twitter;
  197.         return $this;
  198.     }
  199.     public function getLinkedIn(): ?string
  200.     {
  201.         return $this->linkedIn;
  202.     }
  203.     public function setLinkedIn(?string $linkedIn): self
  204.     {
  205.         $this->linkedIn $linkedIn;
  206.         return $this;
  207.     }
  208.     public function getTeam(): ?Team
  209.     {
  210.         return $this->team;
  211.     }
  212.     public function setTeam(?Team $team): self
  213.     {
  214.         $this->team $team;
  215.         return $this;
  216.     }
  217.     public function getPhoto(): ?string
  218.     {
  219.         return $this->photo;
  220.     }
  221.     public function setPhoto(?string $photo): self
  222.     {
  223.         $this->photo $photo;
  224.         return $this;
  225.     }
  226.     /**
  227.      * @param UploadedFile $file
  228.      */
  229.     public function setFile(UploadedFile $file null)
  230.     {
  231.         $this->file $file;
  232.     }
  233.     /**
  234.      * @return UploadedFile
  235.      */
  236.     public function getFile()
  237.     {
  238.         return $this->file;
  239.     }
  240.     /**
  241.      * Manages the copying of the file to the relevant place on the server
  242.      * @ORM\PrePersist()
  243.      * @ORM\PreUpdate()
  244.      */
  245.     public function upload()
  246.     {
  247.         if (null === $this->getFile()) {
  248.             return;
  249.         }
  250.         $filename $this->getFile()->getClientOriginalName();
  251.         $this->photo self::WEBPATH $filename;
  252.         $this->setFile(null);
  253.     }
  254.     /**
  255.      * Lifecycle callback to upload the file to the server.
  256.      */
  257.     public function lifecycleFileUpload()
  258.     {
  259.         $this->upload();
  260.     }
  261.     /**
  262.      * Updates the hash value to force the preUpdate and postUpdate events to fire.
  263.      */
  264.     public function refreshUpdated()
  265.     {
  266.         $this->setUpdated(new \DateTime());
  267.     }
  268. }