Added a draft property to Post entity

Signed-off-by: Gergely Polonkai (W00d5t0ck) <polesz@w00d5t0ck.info>
This commit is contained in:
Gergely Polonkai (W00d5t0ck)
2012-09-05 13:23:03 +02:00
parent 773ea55e3d
commit f16e4c4244
5 changed files with 63 additions and 1 deletions

View File

@@ -62,6 +62,7 @@ class AdminController extends Controller
}
} else {
$post = new Post();
$post->setDraft(true);
}
$form = $this->createForm(new PostType(), $post);
$request = $this->getRequest();

View File

@@ -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();

View File

@@ -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;
}
}

View File

@@ -12,6 +12,7 @@ class PostType extends AbstractType
{
$builder
->add('title')
->add('draft')
->add('content', 'ckeditor')
;
}