I’ve read the paragraph about permalinks (hide primary keys and replace them with significant strings) but I can’t understand how it works this code:
public function executePermalink($request)
{
$article = ArticlePeer::retrieveBySlug($request->getParameter('slug');
$this->forward404Unless($article); // Display 404 if no article matches slug
$this->article = $article; // Pass the object to the template
}
This code is typical of propel, is it right? there is something like it for doctrine? I’ve to write the retrieveBySlug() function? do you have an example where I can understand how to write it?
Thanks a lot
In Doctrine you have an extension called “Sluggable” you can use.
To make it work you have to change your schema.yml and add the “Sluggable” extension:
Set up a DoctrineRoute in your routing.yml
Then in your code for the action you can do something like this :
Don’t forget to run a doctrine:build to recreate the database after you alter your schema.