Added a draft property to Post entity
Signed-off-by: Gergely Polonkai (W00d5t0ck) <polesz@w00d5t0ck.info>
This commit is contained in:
@@ -62,6 +62,7 @@ class AdminController extends Controller
|
||||
}
|
||||
} else {
|
||||
$post = new Post();
|
||||
$post->setDraft(true);
|
||||
}
|
||||
$form = $this->createForm(new PostType(), $post);
|
||||
$request = $this->getRequest();
|
||||
|
@@ -20,7 +20,7 @@ class DefaultController extends Controller
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
$query = $this->getDoctrine()->getEntityManager()->createQuery("SELECT p FROM GergelyPolonkaiFrontBundle:Post p ORDER BY p.createdAt DESC");
|
||||
$query = $this->getDoctrine()->getEntityManager()->createQuery("SELECT p FROM GergelyPolonkaiFrontBundle:Post p WHERE p.draft = FALSE ORDER BY p.createdAt DESC");
|
||||
$query->setMaxResults(4);
|
||||
$posts = $query->getResult();
|
||||
|
||||
|
@@ -65,6 +65,14 @@ class Post
|
||||
*/
|
||||
private $createdAt;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var boolean $draft
|
||||
*
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
private $draft;
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
@@ -189,4 +197,27 @@ class Post
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set draft
|
||||
*
|
||||
* @param boolean $draft
|
||||
* @return Post
|
||||
*/
|
||||
public function setDraft($draft)
|
||||
{
|
||||
$this->draft = $draft;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get draft
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getDraft()
|
||||
{
|
||||
return $this->draft;
|
||||
}
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@ class PostType extends AbstractType
|
||||
{
|
||||
$builder
|
||||
->add('title')
|
||||
->add('draft')
|
||||
->add('content', 'ckeditor')
|
||||
;
|
||||
}
|
||||
|
Reference in New Issue
Block a user