<?php
namespace Customize\Controller;
use Customize\Service\WordPressService;
use Eccube\Controller\AbstractController;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
class SpecialController extends AbstractController
{
/** @var WordPressService */
protected $wordPressService;
public function __construct(
WordPressService $wordPressService
) {
$this->wordPressService = $wordPressService;
}
/**
* @Route("/special", name="special_posts", methods={"GET"})
* @Template("Special/index.twig")
*/
public function index(Request $request)
{
$category_id = $request->get('category', null);
$special_posts = $this->wordPressService->getItsukushiPosts(
'itsukushi_special',
$request->get('pageno', 1),
$category_id
);
return [
'special_posts' => $special_posts,
'category_id' => $category_id,
];
}
/**
* @Route("/special/{id}", name="special_post", methods={"GET"})
* @Template("Special/detail.twig")
*/
public function detail(Request $request, $id)
{
$special_post = $this->wordPressService->getItsukushiPost('itsukushi_special', $id);
return [
'post' => $special_post,
];
}
}