<?php
namespace Customize\Controller;
use Eccube\Repository\NewsRepository;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Response;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
class NewsController extends BaseController
{
/**
* @var NewsRepository
*/
protected $newsRepository;
public function __construct(
NewsRepository $newsRepository
) {
$this->newsRepository = $newsRepository;
}
/**
* @Method("GET")
* @Route("/news")
* @Template("@user_data/news.twig")
*/
public function news()
{
$newsList = $this->newsRepository->findPublishedNews();
return ['newsList' => $newsList];
}
/**
* @Method("GET")
* @Route("/news_article/{id}", name="news_article")
* @Template("@user_data/news_article.twig")
*/
public function news_article($id)
{
$news = $this->newsRepository->find($id);
return ['news' => $news];
}
}