Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
コントローラーでワードプレスの記事一覧を取得
<?php
namespace Customize\Controller;
use Customize\Service\WordPress\AzumiService;
use Eccube\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
/**
* Class PostController
* @package Customize\Controller
*
* @Route("/wp")
*/
class PostController extends AbstractController
{
/**
* @var AzumiService
*/
private $azumiService;
/**
* PostController constructor.
* @param AzumiService $azumiService
*/
public function __construct(AzumiService $azumiService)
{
$this->azumiService = $azumiService;
}
/**
* @return \Symfony\Component\HttpFoundation\JsonResponse
*
* @Route("/posts", name="wp_posts")
*/
public function index()
{
$posts = $this->azumiService->getPosts();
return $this->json($posts);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment