Added a draft flag to the News Entity
Solves issue #11 Signed-off-by: Gergely Polonkai <polesz@w00d5t0ck.info>
This commit is contained in:
parent
9db5619180
commit
faf99b627e
28
app/DoctrineMigrations/Version20120829193604.php
Normal file
28
app/DoctrineMigrations/Version20120829193604.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Application\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Migrations\AbstractMigration,
|
||||
Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your need!
|
||||
*/
|
||||
class Version20120829193604 extends AbstractMigration
|
||||
{
|
||||
public function up(Schema $schema)
|
||||
{
|
||||
// this up() migration is autogenerated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql");
|
||||
|
||||
$this->addSql("ALTER TABLE news ADD draft TINYINT(1) NOT NULL");
|
||||
}
|
||||
|
||||
public function down(Schema $schema)
|
||||
{
|
||||
// this down() migration is autogenerated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql");
|
||||
|
||||
$this->addSql("ALTER TABLE news DROP draft");
|
||||
}
|
||||
}
|
@ -24,7 +24,9 @@ class NewsController extends Controller
|
||||
public function sideListAction()
|
||||
{
|
||||
$newsRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:News');
|
||||
$searchCriteria = array();
|
||||
$searchCriteria = array(
|
||||
'draft' => false;
|
||||
);
|
||||
if (
|
||||
!is_object($this->get('security.context')->getToken())
|
||||
|| !is_object($this->get('security.context')->getToken()->getUser())
|
||||
|
@ -12,6 +12,12 @@ use KekRozsak\SecurityBundle\Entity\User;
|
||||
*/
|
||||
class News
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->public = false;
|
||||
$this->draft = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* The ID of this News
|
||||
*
|
||||
@ -228,4 +234,38 @@ class News
|
||||
{
|
||||
return $this->sticky;
|
||||
}
|
||||
|
||||
/**
|
||||
* True if the News item is just a draft. Drafts can onlz be seen by the
|
||||
* creator and the administrators
|
||||
*
|
||||
* @var boolean $draft
|
||||
*
|
||||
* @ORM\Column(type="boolean", nullable=false)
|
||||
*/
|
||||
protected $draft;
|
||||
|
||||
/**
|
||||
* Set draft
|
||||
*
|
||||
* @param boolean $draft
|
||||
* @return News
|
||||
*/
|
||||
public function setDraft($draft)
|
||||
{
|
||||
// TODO: Check if parameter is boolean!
|
||||
$this->draft = $draft;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get draft
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getDraft()
|
||||
{
|
||||
return $this->draft;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user