88use Symfony \Component \HttpKernel \Exception \NotFoundHttpException ;
99use Symfony \Component \PropertyAccess \PropertyAccess ;
1010use Doctrine \ORM \Query ;
11+ use Doctrine \ORM \Query \Expr \Comparison ;
1112
1213use Bigfoot \Bundle \CoreBundle \Controller \AdminControllerInterface ;
1314use Bigfoot \Bundle \CoreBundle \Controller \BaseController ;
15+ use Bigfoot \Bundle \CoreBundle \Event \FormEvent ;
1416use Bigfoot \Bundle \UserBundle \Entity \User ;
1517
1618/**
@@ -87,6 +89,7 @@ protected function getBundleName()
8789 $ names = $ this ->getBundleAndEntityName ();
8890 $ this ->bundleName = $ names ['bundle ' ];
8991 }
92+
9093 return $ this ->bundleName ;
9194 }
9295
@@ -134,6 +137,7 @@ protected function getFormType()
134137 protected function getEntityClass ()
135138 {
136139 $ namespace = $ this ->get ('kernel ' )->getBundle ($ this ->getBundleName ())->getNamespace ();
140+
137141 return sprintf ('\\%s \\Entity \\%s ' , $ namespace , $ this ->getEntityName ());
138142 }
139143
@@ -143,6 +147,7 @@ protected function getEntityClass()
143147 protected function getEntityTypeClass ()
144148 {
145149 $ namespace = $ this ->container ->get ('kernel ' )->getBundle ($ this ->getBundleName ())->getNamespace ();
150+
146151 return sprintf ('\\%s \\Form \\%sType ' , $ namespace , $ this ->getEntityName ());
147152 }
148153
@@ -261,14 +266,17 @@ protected function getGlobalActions()
261266 */
262267 protected function doIndex ()
263268 {
269+ $ entityClass = ltrim ($ this ->getEntityClass (), '\\' );
270+
264271 $ query = $ this
265- ->getRepository ( $ this -> getEntity () )
266- ->createQueryBuilder ( ' e ' )
272+ ->getContextRepository ( )
273+ ->createContextQueryBuilder ( $ entityClass )
267274 ->getQuery ()
268275 ->setHint (
269276 Query::HINT_CUSTOM_OUTPUT_WALKER ,
270- 'Gedmo \\Translatable \\Query \\TreeWalker \\TranslationWalker '
271- );
277+ 'Gedmo\Translatable\Query\TreeWalker\TranslationWalker '
278+ )
279+ ->getResult ();
272280
273281 return $ this ->renderIndex ($ query );
274282 }
@@ -295,6 +303,8 @@ protected function doNew(Request $request)
295303
296304 $ this ->persistAndFlush ($ entity );
297305
306+ $ this ->postFlush ($ entity , 'new ' );
307+
298308 if (!$ request ->isXmlHttpRequest ()) {
299309 $ action = $ this ->generateUrl ($ this ->getRouteNameForAction ('edit ' ), array ('id ' => $ entity ->getId ()));
300310
@@ -342,6 +352,8 @@ protected function doEdit(Request $request, $id)
342352
343353 $ this ->persistAndFlush ($ entity );
344354
355+ $ this ->postFlush ($ entity , 'edit ' );
356+
345357 if (!$ request ->isXmlHttpRequest ()) {
346358 $ this ->addSuccessFlash ('The %entity% has been updated. ' );
347359
@@ -485,4 +497,11 @@ protected function handleSuccessResponse($action, $entity = null)
485497 * @param object $entity entity
486498 */
487499 protected function prePersist ($ entity , $ action ) {}
500+
501+ /**
502+ * Post flush entity
503+ *
504+ * @param object $entity entity
505+ */
506+ protected function postFlush ($ entity , $ action ) {}
488507}
0 commit comments