src/Entity/Tutorial.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use DateTime;
  4. use DateTimeImmutable;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  8. /**
  9.  * @ORM\Entity(repositoryClass="App\Repository\TutorialRepository")
  10.  * @ORM\Table(name="malys_tutorial")
  11.  * @ORM\HasLifecycleCallbacks()
  12.  * @Assert\Expression(expression="this.getText() != '' || this.getUrl() != ''", message="Renseigner le champ Texte et/ou l'URL")
  13.  * @Vich\Uploadable
  14.  */
  15. class Tutorial
  16. {
  17.     /**
  18.      * @var integer
  19.      *
  20.      * @ORM\Column(name="id", type="integer")
  21.      * @ORM\Id
  22.      * @ORM\GeneratedValue(strategy="AUTO")
  23.      */
  24.     private $id;
  25.     /**
  26.      * @var string $title
  27.      *
  28.      * @ORM\Column(name="title", type="string", length=255, nullable=false)
  29.      */
  30.     private $title;
  31.     /**
  32.      * @var string $text
  33.      *
  34.      * @ORM\Column(name="text", type="text", nullable=true)
  35.      */
  36.     private $text;
  37.     /**
  38.      * @var string $url
  39.      *
  40.      * @ORM\Column(name="url", type="string", length=255, nullable=true)
  41.      */
  42.     private $url;
  43.     /**
  44.      * @var string
  45.      *
  46.      * @ORM\Column(name="picture", type="string", nullable=true)
  47.      */
  48.     protected $picture;
  49.     /**
  50.      * Not persisted
  51.      * @Vich\UploadableField(mapping="tutorial_picture", fileNameProperty="picture")
  52.      */
  53.     private $pictureFile;
  54.     /**
  55.      * @var integer $position
  56.      *
  57.      * @ORM\Column(name="position", type="integer", nullable=false)
  58.      */
  59.     private $position;
  60.     /**
  61.      * @var DateTime
  62.      *
  63.      * @ORM\Column(name="createdAt", type="datetime", nullable=false)
  64.      */
  65.     protected $createdAt;
  66.     /**
  67.      * @var DateTime
  68.      *
  69.      * @ORM\Column(name="updatedAt", type="datetime", nullable=true)
  70.      */
  71.     protected $updatedAt;
  72.     /** GETTERS & SETTERS */
  73.     /**
  74.      * @return int
  75.      */
  76.     public function getId(): int
  77.     {
  78.         return $this->id;
  79.     }
  80.     /**
  81.      * @param int $id
  82.      */
  83.     public function setId(int $id): void
  84.     {
  85.         $this->id $id;
  86.     }
  87.     /**
  88.      * @return mixed
  89.      */
  90.     public function getTitle()
  91.     {
  92.         return $this->title;
  93.     }
  94.     /**
  95.      * @param mixed $title
  96.      */
  97.     public function setTitle($title): void
  98.     {
  99.         $this->title $title;
  100.     }
  101.     /**
  102.      * @return mixed
  103.      */
  104.     public function getText()
  105.     {
  106.         return $this->text;
  107.     }
  108.     /**
  109.      * @param mixed $text
  110.      */
  111.     public function setText($text): void
  112.     {
  113.         $this->text $text;
  114.     }
  115.     /**
  116.      * @return mixed
  117.      */
  118.     public function getUrl()
  119.     {
  120.         return $this->url;
  121.     }
  122.     /**
  123.      * @param mixed $url
  124.      */
  125.     public function setUrl($url): void
  126.     {
  127.         $this->url $url;
  128.     }
  129.     /**
  130.      * @return int
  131.      */
  132.     public function getPosition(): ?int
  133.     {
  134.         return $this->position;
  135.     }
  136.     /**
  137.      * @param int $position
  138.      */
  139.     public function setPosition(int $position): void
  140.     {
  141.         $this->position $position;
  142.     }
  143.     /**
  144.      * @ORM\PrePersist
  145.      */
  146.     public function setCreatedAt()
  147.     {
  148.         $this->createdAt = new DateTime();
  149.         $this->updatedAt = new DateTime();
  150.         return $this;
  151.     }
  152.     /**
  153.      * Get createdAt
  154.      *
  155.      * @return DateTime
  156.      */
  157.     public function getCreatedAt(): DateTime
  158.     {
  159.         return $this->createdAt;
  160.     }
  161.     /**
  162.      * Set updatedAt
  163.      * @ORM\PreUpdate
  164.      */
  165.     public function setUpdatedAt()
  166.     {
  167.         $this->updatedAt = new DateTime();
  168.         return $this;
  169.     }
  170.     /**
  171.      * Get updatedAt
  172.      *
  173.      * @return DateTime
  174.      */
  175.     public function getUpdatedAt()
  176.     {
  177.         return $this->updatedAt;
  178.     }
  179.     /**
  180.      * @return string
  181.      */
  182.     public function getPicture()
  183.     {
  184.         return $this->picture;
  185.     }
  186.     /**
  187.      * @param string $picture
  188.      */
  189.     public function setPicture(string $picture)
  190.     {
  191.         $this->picture $picture;
  192.     }
  193.     public function setPictureFile($pictureFile null)
  194.     {
  195.         $this->pictureFile $pictureFile;
  196.         if (null !== $pictureFile) {
  197.             $this->updatedAt = new DateTimeImmutable();
  198.         }
  199.     }
  200.     public function getPictureFile()
  201.     {
  202.         return $this->pictureFile;
  203.     }
  204. }