Skip to content

Instantly share code, notes, and snippets.

@Arky9782
Last active July 4, 2018 12:21
Show Gist options
  • Save Arky9782/96b7cc0fe54ddd920e49c35489dceeaa to your computer and use it in GitHub Desktop.
Save Arky9782/96b7cc0fe54ddd920e49c35489dceeaa to your computer and use it in GitHub Desktop.
<? /**
* @Route("/{page}", name="index", requirements={"page"="\d+"})
*/
public function index(PostManager $pm, Request $request, $page = 0)
{
$rateRepository = $this->getDoctrine()->getRepository(ExchangeRate::class);
$rates = $rateRepository->getRates();
$locale = $request->getLocale();
$posts = $pm->loadAllLatestPostsByLocaleAndPage($locale, $page);
$uzbPosts = $pm->loadUZBPostsByLocale($locale);
if ($request->isXmlHttpRequest()){
if($posts) {
return $this->render('default/posts.html.twig', [
'posts' => $posts,
'locale' => $locale,
]);
}
else {
return new Response(null, 404);
}
}
return $this->render('default/index.html.twig', [
'posts' => $posts,
'uzbPosts' => $uzbPosts,
'locale' => $locale,
'rates' => $rates,
]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment