<?php
namespace App\Entity;
use DateTime;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass="App\Repository\TutorialRepository")
* @ORM\Table(name="malys_tutorial")
* @ORM\HasLifecycleCallbacks()
* @Assert\Expression(expression="this.getText() != '' || this.getUrl() != ''", message="Renseigner le champ Texte et/ou l'URL")
* @Vich\Uploadable
*/
class Tutorial
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string $title
*
* @ORM\Column(name="title", type="string", length=255, nullable=false)
*/
private $title;
/**
* @var string $text
*
* @ORM\Column(name="text", type="text", nullable=true)
*/
private $text;
/**
* @var string $url
*
* @ORM\Column(name="url", type="string", length=255, nullable=true)
*/
private $url;
/**
* @var string
*
* @ORM\Column(name="picture", type="string", nullable=true)
*/
protected $picture;
/**
* Not persisted
* @Vich\UploadableField(mapping="tutorial_picture", fileNameProperty="picture")
*/
private $pictureFile;
/**
* @var integer $position
*
* @ORM\Column(name="position", type="integer", nullable=false)
*/
private $position;
/**
* @var DateTime
*
* @ORM\Column(name="createdAt", type="datetime", nullable=false)
*/
protected $createdAt;
/**
* @var DateTime
*
* @ORM\Column(name="updatedAt", type="datetime", nullable=true)
*/
protected $updatedAt;
/** GETTERS & SETTERS */
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param int $id
*/
public function setId(int $id): void
{
$this->id = $id;
}
/**
* @return mixed
*/
public function getTitle()
{
return $this->title;
}
/**
* @param mixed $title
*/
public function setTitle($title): void
{
$this->title = $title;
}
/**
* @return mixed
*/
public function getText()
{
return $this->text;
}
/**
* @param mixed $text
*/
public function setText($text): void
{
$this->text = $text;
}
/**
* @return mixed
*/
public function getUrl()
{
return $this->url;
}
/**
* @param mixed $url
*/
public function setUrl($url): void
{
$this->url = $url;
}
/**
* @return int
*/
public function getPosition(): ?int
{
return $this->position;
}
/**
* @param int $position
*/
public function setPosition(int $position): void
{
$this->position = $position;
}
/**
* @ORM\PrePersist
*/
public function setCreatedAt()
{
$this->createdAt = new DateTime();
$this->updatedAt = new DateTime();
return $this;
}
/**
* Get createdAt
*
* @return DateTime
*/
public function getCreatedAt(): DateTime
{
return $this->createdAt;
}
/**
* Set updatedAt
* @ORM\PreUpdate
*/
public function setUpdatedAt()
{
$this->updatedAt = new DateTime();
return $this;
}
/**
* Get updatedAt
*
* @return DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* @return string
*/
public function getPicture()
{
return $this->picture;
}
/**
* @param string $picture
*/
public function setPicture(string $picture)
{
$this->picture = $picture;
}
public function setPictureFile($pictureFile = null)
{
$this->pictureFile = $pictureFile;
if (null !== $pictureFile) {
$this->updatedAt = new DateTimeImmutable();
}
}
public function getPictureFile()
{
return $this->pictureFile;
}
}