Skip to content

Commit

Permalink
[5-7] ブログ記事一覧をデータベースから読み込む
Browse files Browse the repository at this point in the history
  • Loading branch information
hidenorigoto committed Nov 4, 2015
1 parent dbb324a commit 7c08d92
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
10 changes: 10 additions & 0 deletions docs/lists/ch05/05-07.txt
@@ -0,0 +1,10 @@
public function latestListAction()
{
$em = $this->getDoctrine()->getManager();
$blogArticleRepository = $em->getRepository('AppBundle:BlogArticle');
$blogList = $blogArticleRepository->findBy([], ['targetDate' => 'DESC']);

return $this->render('Blog/latestList.html.twig',
['blogList' => $blogList]
);
}
17 changes: 3 additions & 14 deletions src/AppBundle/Controller/BlogController.php
Expand Up @@ -8,20 +8,9 @@ class BlogController extends Controller
{
public function latestListAction()
{
$blogList = [
[
'targetDate' => '2015年3月10日',
'title' => '東京公演レポート',
],
[
'targetDate' => '2015年2月8日',
'title' => '最近の練習風景',
],
[
'targetDate' => '2015年1月3日',
'title' => '本年もよろしくお願い致します',
],
];
$em = $this->getDoctrine()->getManager();
$blogArticleRepository = $em->getRepository('AppBundle:BlogArticle');
$blogList = $blogArticleRepository->findBy([], ['targetDate' => 'DESC']);

return $this->render('Blog/latestList.html.twig',
['blogList' => $blogList]
Expand Down

0 comments on commit 7c08d92

Please sign in to comment.