Skip to content

Instantly share code, notes, and snippets.

@treetop1500
Created September 12, 2016 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save treetop1500/f51f5e24d20804a92a08225dc6fa4ea9 to your computer and use it in GitHub Desktop.
Save treetop1500/f51f5e24d20804a92a08225dc6fa4ea9 to your computer and use it in GitHub Desktop.
Page Entity for Symfony 3 Projects (Extends BaseContent)
<?php
namespace Common\ContentBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\Common\Collections\ArrayCollection;
use Common\ContentBundle\Entity\BaseContent;
/**
* Page
*
* @ORM\Table(name="pages")
* @ORM\Entity(repositoryClass="Common\ContentBundle\Repository\PageRepository")
* @Vich\Uploadable
*/
class Page extends BaseContent
{
/**
* @var string
*
* @ORM\Column(name="excerpt", type="text", nullable=true)
*/
private $excerpt;
/**
* @var int
*
* @ORM\Column(name="template_id", type="integer")
* @Assert\NotBlank(message="Please select a Template.")
*/
private $templateId;
/**
* @ORM\OneToMany(targetEntity="Page", mappedBy="parent")
*/
private $children;
/**
* @ORM\ManyToOne(targetEntity="Page", inversedBy="children")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id", nullable=true)
*/
private $parent;
/**
* @var int
*
* @ORM\Column(name="menu", type="text", nullable=false)
* @Assert\NotBlank(message="Please choose a menu for this page, or choose 'Do Not place in menu'")
*/
private $menu;
/**
* @var int
*
* @ORM\Column(name="menu_name", type="text", nullable=false)
* @Assert\NotBlank(message="Please enter the display name for your menu item.")
*/
private $menuName;
/**
* @ORM\ManyToOne(targetEntity="Domain", inversedBy="pages", cascade={"persist"})
* @ORM\JoinColumn(name="domain_id", referencedColumnName="id")
* @Assert\NotBlank(message="This is a required field.")
*/
private $domain;
public function __construct() {
parent::__construct();
$this->children = new ArrayCollection();
}
/**
* Set excerpt
*
* @param string $excerpt
*
* @return Page
*/
public function setExcerpt($excerpt)
{
$this->excerpt = $excerpt;
return $this;
}
/**
* Get excerpt
*
* @return string
*/
public function getExcerpt()
{
return $this->excerpt;
}
/**
* Set templateId
*
* @param integer $templateId
*
* @return Page
*/
public function setTemplateId($templateId)
{
$this->templateId = $templateId;
return $this;
}
/**
* Get templateId
*
* @return int
*/
public function getTemplateId()
{
return $this->templateId;
}
/**
* @return mixed
*/
public function getChildren()
{
return $this->children;
}
/**
* @param mixed $children
*/
public function setChildren($children)
{
$this->children = $children;
}
/**
* @return mixed
*/
public function getParent()
{
return $this->parent;
}
/**
* @param mixed $parent
*/
public function setParent($parent)
{
$this->parent = $parent;
}
/**
* Get domain
*
* @return int
*/
public function getDomain()
{
return $this->domain;
}
/**
* @param mixed $domain
*/
public function setDomain($domain)
{
$this->domain = $domain;
}
/**
* @return mixed
*/
public function getMenu()
{
return $this->menu;
}
/**
* @param mixed $menu
*/
public function setMenu($menu)
{
$this->menu = $menu;
}
/**
* @return mixed
*/
public function getMenuName()
{
return $this->menuName;
}
/**
* @param mixed $menuName
*/
public function setMenuName($menuName)
{
$this->menuName = $menuName;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment