src/Entity/UserShare.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Greg0ire\Enum\Bridge\Symfony\Validator\Constraint\Enum as EnumAssert;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. /**
  7.  * @ORM\Entity(repositoryClass="App\Repository\UserShareRepository")
  8.  */
  9. class UserShare
  10. {
  11.     /**
  12.      * @ORM\Id()
  13.      * @ORM\GeneratedValue()
  14.      * @ORM\Column(type="integer")
  15.      */
  16.     private $id;
  17.     /**
  18.      * @ORM\ManyToOne(targetEntity="App\Entity\User")
  19.      * @ORM\JoinColumn(nullable=true)
  20.      */
  21.     private $user;
  22.     /**
  23.      * @ORM\ManyToOne(targetEntity="App\Entity\Article", inversedBy="userShares")
  24.      * @ORM\JoinColumn(onDelete="CASCADE")
  25.      */
  26.     private $article;
  27.     /**
  28.      * @ORM\ManyToOne(targetEntity="App\Entity\Blog", inversedBy="userShares")
  29.      * @ORM\JoinColumn(onDelete="CASCADE")
  30.      */
  31.     private $blog;
  32.     /**
  33.      * @ORM\ManyToOne(targetEntity="App\Entity\Newsroom", inversedBy="userShares")
  34.      * @ORM\JoinColumn(onDelete="CASCADE")
  35.      */
  36.     private $newsroom;
  37.     /**
  38.      * @ORM\ManyToOne(targetEntity="App\Entity\Review", inversedBy="userShares")
  39.      * @ORM\JoinColumn(onDelete="CASCADE")
  40.      */
  41.     private $review;
  42.     /**
  43.      * @var string
  44.      *
  45.      * @ORM\Column(type="string", length=64, nullable=false)
  46.      * @Assert\Length(max=64)
  47.      * @EnumAssert(class="App\Enum\UserShareType")
  48.      * @Assert\NotBlank()
  49.      */
  50.     private $type;
  51.     /**
  52.      * @var string
  53.      *
  54.      * @ORM\Column(type="string", length=64, nullable=false)
  55.      * @Assert\Length(max=64)
  56.      * @EnumAssert(class="App\Enum\ShareProviderType")
  57.      * @Assert\NotBlank()
  58.      */
  59.     private $provider;
  60.     /**
  61.      * @ORM\Column(type="datetime")
  62.      */
  63.     private $createdAt;
  64.     /**
  65.      * UserShare constructor.
  66.      *
  67.      * @throws \Exception
  68.      */
  69.     public function __construct()
  70.     {
  71.         $this->createdAt = new \DateTime();
  72.     }
  73.     public function getId(): ?int
  74.     {
  75.         return $this->id;
  76.     }
  77.     public function getUser(): ?User
  78.     {
  79.         return $this->user;
  80.     }
  81.     public function setUser(?User $user): self
  82.     {
  83.         $this->user $user;
  84.         return $this;
  85.     }
  86.     public function getArticle(): ?Article
  87.     {
  88.         return $this->article;
  89.     }
  90.     public function setArticle(?Article $article): self
  91.     {
  92.         $this->article $article;
  93.         return $this;
  94.     }
  95.     public function getBlog(): ?Blog
  96.     {
  97.         return $this->blog;
  98.     }
  99.     public function setBlog(?Blog $blog): self
  100.     {
  101.         $this->blog $blog;
  102.         return $this;
  103.     }
  104.     public function getReview(): ?Review
  105.     {
  106.         return $this->review;
  107.     }
  108.     public function setReview(?Review $review): self
  109.     {
  110.         $this->review $review;
  111.         return $this;
  112.     }
  113.     public function getType(): ?string
  114.     {
  115.         return $this->type;
  116.     }
  117.     public function setType(string $type): self
  118.     {
  119.         $this->type $type;
  120.         return $this;
  121.     }
  122.     public function getNewsroom(): ?Newsroom
  123.     {
  124.         return $this->newsroom;
  125.     }
  126.     public function setNewsroom(?Newsroom $newsroom): self
  127.     {
  128.         $this->newsroom $newsroom;
  129.         return $this;
  130.     }
  131.     public function getCreatedAt(): ?\DateTimeInterface
  132.     {
  133.         return $this->createdAt;
  134.     }
  135.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  136.     {
  137.         $this->createdAt $createdAt;
  138.         return $this;
  139.     }
  140.     public function getProvider(): ?string
  141.     {
  142.         return $this->provider;
  143.     }
  144.     public function setProvider(string $provider): self
  145.     {
  146.         $this->provider $provider;
  147.         return $this;
  148.     }
  149. }