From dfeed19fa7f74afdd8967d0ee7e782cb5007da5c Mon Sep 17 00:00:00 2001 From: "Gergely POLONKAI (W00d5t0ck)" Date: Sat, 1 Sep 2012 23:45:02 +0200 Subject: [PATCH] Added a slug property to the News entity Signed-off-by: Gergely POLONKAI (W00d5t0ck) --- .../Version20120901231931.php | 30 ++++++++++++++++++ src/KekRozsak/FrontBundle/Entity/News.php | 31 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 app/DoctrineMigrations/Version20120901231931.php diff --git a/app/DoctrineMigrations/Version20120901231931.php b/app/DoctrineMigrations/Version20120901231931.php new file mode 100644 index 0000000..62860be --- /dev/null +++ b/app/DoctrineMigrations/Version20120901231931.php @@ -0,0 +1,30 @@ +abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); + + $this->addSql("ALTER TABLE news ADD slug VARCHAR(100) NOT NULL"); + $this->addSql("UPDATE news SET slug = title"); + $this->addSql("CREATE UNIQUE INDEX UNIQ_1DD39950989D9B62 ON news (slug)"); + } + + 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 slug"); + } +} diff --git a/src/KekRozsak/FrontBundle/Entity/News.php b/src/KekRozsak/FrontBundle/Entity/News.php index 5bd1025..14c41c6 100644 --- a/src/KekRozsak/FrontBundle/Entity/News.php +++ b/src/KekRozsak/FrontBundle/Entity/News.php @@ -72,6 +72,37 @@ class News return $this->title; } + /** + * The slugified title of this News + * + * @var string $slug + * + * @ORM\Column(type="string", length=100, nullable=false, unique=true) + */ + protected $slug; + + /** + * Set slug + * + * @param string $slug + * @return News + */ + public function setSlug($slug) + { + $this->slug = $slug; + return $this; + } + + /** + * Get slug + * + * @return string + */ + public function getSlug() + { + return $this->slug; + } + /** * The contents of this News *