<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Greg0ire\Enum\Bridge\Symfony\Validator\Constraint\Enum as EnumAssert;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\UserShareRepository")
*/
class UserShare
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User")
* @ORM\JoinColumn(nullable=true)
*/
private $user;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Article", inversedBy="userShares")
* @ORM\JoinColumn(onDelete="CASCADE")
*/
private $article;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Blog", inversedBy="userShares")
* @ORM\JoinColumn(onDelete="CASCADE")
*/
private $blog;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Newsroom", inversedBy="userShares")
* @ORM\JoinColumn(onDelete="CASCADE")
*/
private $newsroom;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Review", inversedBy="userShares")
* @ORM\JoinColumn(onDelete="CASCADE")
*/
private $review;
/**
* @var string
*
* @ORM\Column(type="string", length=64, nullable=false)
* @Assert\Length(max=64)
* @EnumAssert(class="App\Enum\UserShareType")
* @Assert\NotBlank()
*/
private $type;
/**
* @var string
*
* @ORM\Column(type="string", length=64, nullable=false)
* @Assert\Length(max=64)
* @EnumAssert(class="App\Enum\ShareProviderType")
* @Assert\NotBlank()
*/
private $provider;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* UserShare constructor.
*
* @throws \Exception
*/
public function __construct()
{
$this->createdAt = new \DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getArticle(): ?Article
{
return $this->article;
}
public function setArticle(?Article $article): self
{
$this->article = $article;
return $this;
}
public function getBlog(): ?Blog
{
return $this->blog;
}
public function setBlog(?Blog $blog): self
{
$this->blog = $blog;
return $this;
}
public function getReview(): ?Review
{
return $this->review;
}
public function setReview(?Review $review): self
{
$this->review = $review;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
public function getNewsroom(): ?Newsroom
{
return $this->newsroom;
}
public function setNewsroom(?Newsroom $newsroom): self
{
$this->newsroom = $newsroom;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getProvider(): ?string
{
return $this->provider;
}
public function setProvider(string $provider): self
{
$this->provider = $provider;
return $this;
}
}