1212
1313namespace Symfony \Cmf \Bundle \BlogBundle \Controller ;
1414
15- use Doctrine \ODM \PHPCR \DocumentManager ;
1615use Symfony \Cmf \Bundle \BlogBundle \Document \Post ;
16+ use Symfony \Cmf \Bundle \BlogBundle \Repository \PostRepository ;
1717use Symfony \Cmf \Bundle \CoreBundle \PublishWorkflow \PublishWorkflowChecker ;
1818use Symfony \Component \HttpFoundation \Request ;
1919use Symfony \Component \HttpKernel \Exception \NotFoundHttpException ;
2020use Symfony \Component \Security \Core \SecurityContextInterface ;
21- use Symfony \Component \Templating \EngineInterface ;
21+ use Symfony \Bundle \ FrameworkBundle \Templating \EngineInterface ;
2222use FOS \RestBundle \View \ViewHandlerInterface ;
2323use FOS \RestBundle \View \View ;
2424
@@ -40,14 +40,14 @@ class BlogController
4040 protected $ viewHandler ;
4141
4242 /**
43- * @var DocumentManager
43+ * @var SecurityContextInterface
4444 */
45- protected $ dm ;
45+ protected $ securityContext ;
4646
4747 /**
48- * @var SecurityContextInterface
48+ * @var PostRepository
4949 */
50- protected $ securityContext ;
50+ protected $ postRepository ;
5151
5252 /**
5353 * The permission to check for when doing the publish workflow check.
@@ -56,17 +56,16 @@ class BlogController
5656 */
5757 private $ publishWorkflowPermission = PublishWorkflowChecker::VIEW_ATTRIBUTE ;
5858
59-
6059 public function __construct (
6160 EngineInterface $ templating ,
6261 ViewHandlerInterface $ viewHandler = null ,
63- DocumentManager $ dm ,
64- SecurityContextInterface $ securityContext
62+ SecurityContextInterface $ securityContext ,
63+ PostRepository $ postRepository
6564 ) {
6665 $ this ->templating = $ templating ;
6766 $ this ->viewHandler = $ viewHandler ;
68- $ this ->dm = $ dm ;
6967 $ this ->securityContext = $ securityContext ;
68+ $ this ->postRepository = $ postRepository ;
7069 }
7170
7271 /**
@@ -91,11 +90,6 @@ protected function renderResponse($contentTemplate, $params)
9190 return $ this ->templating ->renderResponse ($ contentTemplate , $ params );
9291 }
9392
94- protected function getPostRepo ()
95- {
96- return $ this ->dm ->getRepository ('Symfony\Cmf\Bundle\BlogBundle\Document\Post ' );
97- }
98-
9993 public function viewPostAction (Post $ contentDocument , $ contentTemplate = null )
10094 {
10195 $ post = $ contentDocument ;
@@ -119,7 +113,7 @@ public function listAction(Request $request, $contentDocument, $contentTemplate
119113 $ tag = $ request ->get ('tag ' , null );
120114
121115 // @todo: Pagination
122- $ posts = $ this ->getPostRepo () ->search (array (
116+ $ posts = $ this ->postRepository ->search (array (
123117 'tag ' => $ tag ,
124118 'blog_id ' => $ blog ->getId (),
125119 ));
0 commit comments