src/Entity/Page.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5.  * @ORM\Entity
  6.  * @ORM\Entity(repositoryClass="App\Repository\PageRepository")
  7.  * @ORM\Table(indexes={@ORM\Index(name="url_idx", columns={"url"})})
  8.  */
  9. class Page implements EntityInterface
  10. {
  11.     const STATUS_DRAFT "draft";
  12.     const STATUS_PUBLISHED "published";
  13.     /**
  14.      * @var int|null
  15.      * @ORM\Id
  16.      * @ORM\Column(type="integer")
  17.      * @ORM\GeneratedValue
  18.      */
  19.     private $id;
  20.     /**
  21.      * @var string
  22.      * @ORM\Column(type="string")
  23.      */
  24.     private $title;
  25.     /**
  26.      * @var string
  27.      * @ORM\Column(type="text")
  28.      */
  29.     private $content;
  30.     /**
  31.      * @var string
  32.      * @ORM\Column(type="string")
  33.      */
  34.     private $url;
  35.     /**
  36.      * @var string
  37.      * @ORM\Column(name="status", type="string", options={"default" : Page::STATUS_DRAFT})
  38.      */
  39.     private $status self::STATUS_DRAFT;
  40.     /**
  41.      * @var string
  42.      * @ORM\Column(type="string", name="restricted_to")
  43.      */
  44.     private $restrictedTo;
  45.     public function __construct(
  46.         string $title '',
  47.         string $content '',
  48.         string $url '',
  49.         string $status '',
  50.         string $restrictedTo ''
  51.     )
  52.     {
  53.         $this->title $title;
  54.         $this->content $content;
  55.         $this->url $url;
  56.         $this->status $status;
  57.         $this->restrictedTo $restrictedTo;
  58.     }
  59.     /**
  60.      * @return string
  61.      */
  62.     public function __toString(): string
  63.     {
  64.         return (string)$this->title " (" $this->id ")";
  65.     }
  66.     public function toString(): string
  67.     {
  68.         return "{id=" $this->id ",title=" $this->title "}";
  69.     }
  70.     /**
  71.      * @return int|null
  72.      */
  73.     public function getId(): ?int
  74.     {
  75.         return $this->id;
  76.     }
  77.     /**
  78.      * @return string
  79.      */
  80.     public function getTitle(): ?string
  81.     {
  82.         return $this->title;
  83.     }
  84.     /**
  85.      * @param string $title
  86.      *
  87.      * @return self
  88.      */
  89.     public function setTitle(string $title): self
  90.     {
  91.         $this->title $title;
  92.         return $this;
  93.     }
  94.     /**
  95.      * @return string
  96.      */
  97.     public function getContent(): ?string
  98.     {
  99.         return $this->content;
  100.     }
  101.     /**
  102.      * @param string $content
  103.      *
  104.      * @return self
  105.      */
  106.     public function setContent(string $content): self
  107.     {
  108.         $this->content $content;
  109.         return $this;
  110.     }
  111.     /**
  112.      * @return string
  113.      */
  114.     public function getUrl()
  115.     {
  116.         return $this->url;
  117.     }
  118.     /**
  119.      * @param string $url
  120.      */
  121.     public function setUrl($url)
  122.     {
  123.         $this->url $url;
  124.     }
  125.     /**
  126.      * @return string
  127.      */
  128.     public function getRestrictedTo(): ?string
  129.     {
  130.         return $this->restrictedTo;
  131.     }
  132.     /**
  133.      * @param string $restrictedTo
  134.      */
  135.     public function setRestrictedTo($restrictedTo)
  136.     {
  137.         $this->restrictedTo $restrictedTo;
  138.     }
  139.     /**
  140.      * @return string
  141.      */
  142.     public function getStatus(): ?string
  143.     {
  144.         return $this->status;
  145.     }
  146.     /**
  147.      * @param string $status
  148.      */
  149.     public function setStatus($status)
  150.     {
  151.         $this->status $status;
  152.     }
  153. }