src/Entity/Content/Pages/Block.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Content\Pages;
  3. use Symfony\Component\Validator\Constraints AS Constraints;
  4. use Symfony\Component\Validator\Constraints AS Assert;
  5. use Doctrine\ORM\Mapping AS ORM;
  6. use Ramsey\Uuid\Uuid;
  7. use App\Entity\BaseEntity;
  8. /**
  9.  * @ORM\Entity(repositoryClass="App\Repository\Content\Pages\BlockRepository")
  10.  * @ORM\Table(name="content_pages_block")
  11.  * @ORM\HasLifecycleCallbacks()
  12.  */
  13. class Block extends BaseEntity
  14. {
  15.     /**
  16.     * @ORM\Id
  17.     * @ORM\GeneratedValue(strategy="AUTO")
  18.     * @ORM\Column(type="integer")
  19.     */
  20.     private $id;
  21.     /**
  22.      * @ORM\Column(type="uuid")
  23.      * @Assert\Uuid
  24.      */
  25.      protected $uuid;
  26.     /**
  27.      * @var \DateTime
  28.      *
  29.      * @ORM\Column(type="datetime", nullable=false)
  30.      */
  31.     private $created;
  32.     /**
  33.      * @ORM\Column(type="string", length=60, nullable=false)
  34.      */
  35.     private $blockName;
  36.     /**
  37.      * @ORM\Column(type="array", nullable=false)
  38.      */
  39.     private $data;
  40.     /**
  41.      * @ORM\ManyToOne(targetEntity="Page", inversedBy="blocks")
  42.      * @ORM\JoinColumn(name="page_id", referencedColumnName="id")
  43.      **/
  44.     private $page;
  45.     public function __construct(array $defaults = array())
  46.     {
  47.          // Defaults
  48.         $this->setUuid(Uuid::uuid4());
  49.         $this->setCreated(new \DateTime());
  50.         $this->data = array();
  51.         parent::__construct($defaults);
  52.     }
  53.     public function __toString()
  54.     {
  55.         return $this->getId();
  56.     }
  57.     public function getId()
  58.     {
  59.         return $this->id;
  60.     }
  61.     public function setUuid($uuid)
  62.     {
  63.         $this->uuid $uuid;
  64.         return $this;
  65.     }
  66.     public function getUuid()
  67.     {
  68.         return $this->uuid;
  69.     }
  70.     public function setCreated(\DateTime $created)
  71.     {
  72.         $this->created $created;
  73.     }
  74.     public function getCreated()
  75.     {
  76.         return $this->created;
  77.     }
  78.     public function getBlockName()
  79.     {
  80.         return $this->blockName;
  81.     }
  82.     public function setBlockName(string $blockName)
  83.     {
  84.         $this->blockName $blockName;
  85.     }
  86.     public function setPage(\App\Entity\Content\Pages\Page $page)
  87.     {
  88.         $this->page $page;
  89.         if($page)
  90.             $page->addBlock($this);
  91.     }
  92.     public function getPage()
  93.     {
  94.         return $this->page;
  95.     }
  96.     public function setData(array $data = array())
  97.     {
  98.         $this->data $data;
  99.     }
  100.     public function getData()
  101.     {
  102.         return $this->data;
  103.     }
  104. }