diff --git a/Resources/config/router.xml b/Resources/config/router.xml index 2ae0b0f..0b4f3c3 100644 --- a/Resources/config/router.xml +++ b/Resources/config/router.xml @@ -10,7 +10,7 @@ - + %forum.paginator.posts_per_page% diff --git a/Router/ForumUrlGenerator.php b/Router/ForumUrlGenerator.php index 6a973f3..95869a2 100644 --- a/Router/ForumUrlGenerator.php +++ b/Router/ForumUrlGenerator.php @@ -2,32 +2,32 @@ namespace Bundle\ForumBundle\Router; -use Symfony\Component\Routing\Router; +use Symfony\Component\DependencyInjection\ContainerInterface; use Bundle\ForumBundle\Model\Category; use Bundle\ForumBundle\Model\Topic; use Bundle\ForumBundle\Model\Post; class ForumUrlGenerator { - protected $generator; + protected $container; protected $nbPostsPerPage; - public function __construct(Router $router, $nbPostsPerPage) + public function __construct(ContainerInterface $container, $nbPostsPerPage) { - $this->generator = $router->getGenerator(); + $this->container = $container; $this->nbPostsPerPage = $nbPostsPerPage; } public function urlForCategory(Category $category, $absolute = false) { - return $this->generator->generate('forum_category_show', array( + return $this->container->get('router')->generate('forum_category_show', array( 'slug' => $category->getSlug() ), $absolute); } public function urlForCategoryAtomFeed(Category $category, $absolute = false) { - return $this->generator->generate('forum_category_show', array( + return $this->container->get('router')->generate('forum_category_show', array( 'slug' => $category->getSlug(), '_format' => 'xml' ), $absolute); @@ -35,7 +35,7 @@ public function urlForCategoryAtomFeed(Category $category, $absolute = false) public function urlForTopic(Topic $topic, $absolute = false) { - return $this->generator->generate('forum_topic_show', array( + return $this->container->get('router')->generate('forum_topic_show', array( 'categorySlug' => $topic->getCategory()->getSlug(), 'slug' => $topic->getSlug() ), $absolute); @@ -43,7 +43,7 @@ public function urlForTopic(Topic $topic, $absolute = false) public function urlForTopicAtomFeed(Topic $topic, $absolute = false) { - return $this->generator->generate('forum_topic_show', array( + return $this->container->get('router')->generate('forum_topic_show', array( 'categorySlug' => $topic->getCategory()->getSlug(), 'slug' => $topic->getSlug(), '_format' => 'xml' @@ -52,7 +52,7 @@ public function urlForTopicAtomFeed(Topic $topic, $absolute = false) public function urlForTopicReply(Topic $topic, $absolute = false) { - return $this->generator->generate('forum_topic_post_new', array( + return $this->container->get('router')->generate('forum_topic_post_new', array( 'categorySlug' => $topic->getCategory()->getSlug(), 'slug' => $topic->getSlug() ));