src/Entity/BlogPost.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\HttpFoundation\File\File;
  5. use Symfony\Component\HttpFoundation\File\UploadedFile;
  6. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. /**
  11.  * @ORM\Entity(repositoryClass="App\Repository\BlogPostRepository")
  12.  * @Vich\Uploadable
  13.  * @UniqueEntity("slug")
  14.  */
  15. class BlogPost
  16. {
  17.     /**
  18.      * @ORM\Id()
  19.      * @ORM\GeneratedValue()
  20.      * @ORM\Column(type="integer")
  21.      */
  22.     private $id;
  23.     /**
  24.      * @var File|null
  25.      * @Assert\Image(
  26.      *     mimeTypes="image/jpeg"
  27.      * )
  28.      * @Vich\UploadableField(mapping="blogpost_image", fileNameProperty="filename")
  29.      */
  30.     private $imageFile;
  31.     /**
  32.      * @var string|null
  33.      * @ORM\Column(type="string", length=255, nullable=true)
  34.      */
  35.     private $filename;
  36.     /**
  37.      * @ORM\Column(type="string", length=255)
  38.      * @Assert\Length (
  39.      *      max = 50,
  40.      *      maxMessage = "Le titre ne peut pas faire plus de {{ limit }} charactères"
  41.      * )
  42.      */
  43.     private ?string $title null;
  44.     /**
  45.      * @ORM\Column(type="string", length=255, unique=true)
  46.      * @Gedmo\Slug(fields={"title"})
  47.      */
  48.     private ?string $slug null;
  49.     /**
  50.      * @ORM\Column(type="string", length=2000, nullable=true)
  51.      */
  52.     private ?string $description null;
  53.     /**
  54.      * @ORM\Column(type="text")
  55.      */
  56.     private ?string $body null;
  57.     /**
  58.      * @ORM\Column(type="text")
  59.      */
  60.     private $bodySecond;
  61.     /**
  62.      * @ORM\Column(type="string", length=255)
  63.      * @Assert\Length (
  64.      *       max = 50,
  65.      *       maxMessage = "Le meta-title ne peut pas faire plus de {{ limit }} charactères"
  66.      *  )
  67.      */
  68.     private $metaTitle;
  69.     /**
  70.      * @ORM\Column(type="string", length=255)
  71.      * @Assert\Length (
  72.      *       max = 150,
  73.      *       maxMessage = "La meta-description ne peut pas faire plus de {{ limit }} charactères"
  74.      *  )
  75.      */
  76.     private $metaDescription;
  77.     /**
  78.      * @ORM\Column(type="text", nullable=true)
  79.      */
  80.     private ?string $metaCustom null;
  81.     /**
  82.      * @ORM\Column(type="text", nullable=true)
  83.      * @Assert\Json(
  84.      *      message = "You've entered an invalid Json."
  85.      *  )
  86.      */
  87.     private ?string $metaSchema null;
  88.     /**
  89.      * @ORM\Column(type="string")
  90.      * @var string
  91.      */
  92.     private $ctaLinkPath;
  93.     /**
  94.      * @ORM\Column(type="string", nullable=true)
  95.      */
  96.     private $keyword;
  97.     /**
  98.      * @ORM\Column(type="datetime")
  99.      * @Gedmo\Timestampable(on="create")
  100.      */
  101.     private $createdAt;
  102.     /**
  103.      * @ORM\Column(type="datetime")
  104.      * @Gedmo\Timestampable(on="update")
  105.      */
  106.     private $updatedAt;
  107.     /**
  108.      * @ORM\ManyToOne(targetEntity="BlogAuthor", inversedBy="blogPosts")
  109.      * @Assert\NotNull
  110.      */
  111.     private ?BlogAuthor $blogAuthor null;
  112.     /**
  113.      * @ORM\Column(type="integer")
  114.      */
  115.     private $readingTime;
  116.     /**
  117.      * @ORM\Column(type="boolean")
  118.      */
  119.     private $isPillarPage;
  120.     /**
  121.      * @ORM\ManyToOne(targetEntity=BlogCategory::class, inversedBy="blogPosts")
  122.      */
  123.     private $blogCategory;
  124.     public function __construct()
  125.     {
  126.         $this->createdAt = new \DateTime('now');
  127.     }
  128.     public function getId(): ?int
  129.     {
  130.         return $this->id;
  131.     }
  132.     public function getTitle(): ?string
  133.     {
  134.         return $this->title;
  135.     }
  136.     public function setTitle(string $title): self
  137.     {
  138.         $this->title $title;
  139.         return $this;
  140.     }
  141.     public function getSlug(): ?string
  142.     {
  143.         return $this->slug;
  144.     }
  145.     public function setSlug(?string $slug): self
  146.     {
  147.         $this->slug strtolower($slug);
  148.         return $this;
  149.     }
  150.     public function getDescription(): ?string
  151.     {
  152.         return $this->description;
  153.     }
  154.     public function setDescription(?string $description): self
  155.     {
  156.         $this->description $description;
  157.         return $this;
  158.     }
  159.     public function getBody(): ?string
  160.     {
  161.         return $this->body;
  162.     }
  163.     public function setBody(string $body): self
  164.     {
  165.         $this->body $body;
  166.         return $this;
  167.     }
  168.     public function getCreatedAt(): ?\DateTimeInterface
  169.     {
  170.         return $this->createdAt;
  171.     }
  172.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  173.     {
  174.         $this->createdAt $createdAt;
  175.         return $this;
  176.     }
  177.     public function getUpdatedAt(): ?\DateTimeInterface
  178.     {
  179.         return $this->updatedAt;
  180.     }
  181.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  182.     {
  183.         $this->updatedAt $updatedAt;
  184.         return $this;
  185.     }
  186.     /**
  187.      * @return null|File
  188.      */
  189.     public function getImageFile()
  190.     {
  191.         return $this->imageFile;
  192.     }
  193.     /**
  194.      * @param null|File $imageFile
  195.      * @return BlogPost
  196.      */
  197.     public function setImageFile($imageFile)
  198.     {
  199.         $this->imageFile $imageFile;
  200.         if ($this->imageFile instanceof UploadedFile) {
  201.             $this->updatedAt = new \DateTime('now');
  202.         }
  203.         return $this;
  204.     }
  205.     /**
  206.      * @return null|string
  207.      */
  208.     public function getFilename()
  209.     {
  210.         return $this->filename;
  211.     }
  212.     /**
  213.      * @param null|string $filename
  214.      * @return BlogPost
  215.      */
  216.     public function setFilename($filename)
  217.     {
  218.         $this->filename $filename;
  219.         return $this;
  220.     }
  221.     /**
  222.      * @return mixed
  223.      */
  224.     public function getBodySecond()
  225.     {
  226.         return $this->bodySecond;
  227.     }
  228.     /**
  229.      * @param mixed $bodySecond
  230.      */
  231.     public function setBodySecond($bodySecond)
  232.     {
  233.         $this->bodySecond $bodySecond;
  234.     }
  235.     public function getMetaTitle(): ?string
  236.     {
  237.         return $this->metaTitle;
  238.     }
  239.     public function setMetaTitle(string $metaTitle): self
  240.     {
  241.         $this->metaTitle $metaTitle;
  242.         return $this;
  243.     }
  244.     public function getMetaDescription(): ?string
  245.     {
  246.         return $this->metaDescription;
  247.     }
  248.     public function setMetaDescription(string $metaDescription): self
  249.     {
  250.         $this->metaDescription $metaDescription;
  251.         return $this;
  252.     }
  253.     public function getMetaCustom(): ?string
  254.     {
  255.         return $this->metaCustom;
  256.     }
  257.     public function setMetaCustom(?string $metaCustom): self
  258.     {
  259.         $this->metaCustom $metaCustom;
  260.         return $this;
  261.     }
  262.     public function getBlogAuthor(): ?BlogAuthor
  263.     {
  264.         return $this->blogAuthor;
  265.     }
  266.     public function setBlogAuthor(?BlogAuthor $blogAuthor): self
  267.     {
  268.         $this->blogAuthor $blogAuthor;
  269.         return $this;
  270.     }
  271.     public function getReadingTime(): ?int
  272.     {
  273.         return $this->readingTime;
  274.     }
  275.     public function setReadingTime(int $readingTime): self
  276.     {
  277.         $this->readingTime $readingTime;
  278.         return $this;
  279.     }
  280.     public function getCtaLinkPath(): ?string
  281.     {
  282.         return $this->ctaLinkPath;
  283.     }
  284.     public function setCtaLinkPath(string $ctaLinkPath): self
  285.     {
  286.         $this->ctaLinkPath $ctaLinkPath;
  287.         return $this;
  288.     }
  289.     public function getKeyword(): ?string
  290.     {
  291.         return $this->keyword;
  292.     }
  293.     public function setKeyword(string $keyword): self
  294.     {
  295.         $this->keyword $keyword;
  296.         return $this;
  297.     }
  298.     public function isIsPillarPage(): ?bool
  299.     {
  300.         return $this->isPillarPage;
  301.     }
  302.     public function setIsPillarPage(bool $isPillarPage): self
  303.     {
  304.         $this->isPillarPage $isPillarPage;
  305.         return $this;
  306.     }
  307.     public function getBlogCategory(): ?BlogCategory
  308.     {
  309.         return $this->blogCategory;
  310.     }
  311.     public function setBlogCategory(?BlogCategory $blogCategory): self
  312.     {
  313.         $this->blogCategory $blogCategory;
  314.         return $this;
  315.     }
  316.     public function getMetaSchema(): ?string
  317.     {
  318.         return $this->metaSchema;
  319.     }
  320.     public function setMetaSchema(?string $metaSchema): void
  321.     {
  322.         $this->metaSchema $metaSchema;
  323.     }
  324. }