diff --git a/app/DoctrineMigrations/Version20120819121254.php b/app/DoctrineMigrations/Version20120819121254.php new file mode 100644 index 0000000..9ace30c --- /dev/null +++ b/app/DoctrineMigrations/Version20120819121254.php @@ -0,0 +1,29 @@ +abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); + + $this->addSql("ALTER TABLE news ADD sticky TINYINT(1) NOT NULL"); + $this->addSql("UPDATE news SET sticky = FALSE"); + } + + 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 sticky"); + } +} diff --git a/src/KekRozsak/FrontBundle/Controller/NewsController.php b/src/KekRozsak/FrontBundle/Controller/NewsController.php index 1560f4f..edd9a8d 100644 --- a/src/KekRozsak/FrontBundle/Controller/NewsController.php +++ b/src/KekRozsak/FrontBundle/Controller/NewsController.php @@ -30,7 +30,7 @@ class NewsController extends Controller $searchCriteria['public'] = true; } - $news = $newsRepo->findBy($searchCriteria, array('createdAt' => 'DESC'), 4); + $news = $newsRepo->findBy($searchCriteria, array('sticky' => 'DESC', 'createdAt' => 'DESC'), 4); return array( 'recentNews' => $news, diff --git a/src/KekRozsak/FrontBundle/Entity/News.php b/src/KekRozsak/FrontBundle/Entity/News.php index 4367a73..575eae9 100644 --- a/src/KekRozsak/FrontBundle/Entity/News.php +++ b/src/KekRozsak/FrontBundle/Entity/News.php @@ -197,4 +197,35 @@ class News { return $this->public; } + + /** + * TRUE if this News is "sticky" (it should be visible all the time) + * + * @var boolean $sticky + * + * @ORM\Column(type="boolean", nullable=false) + */ + protected $sticky; + + /** + * Set sticky + * + * @param boolean $sticky + * @return News + */ + public function setSticky($sticky) + { + $this->sticky = $sticky; + return $this; + } + + /** + * Get sticky + * + * @return boolean + */ + public function isSticky() + { + return $this->sticky; + } }