Skip to content

Instantly share code, notes, and snippets.

@kurozumi
Created December 4, 2020 06:32
Show Gist options
  • Save kurozumi/81377d044d9625f31b0429b9b30abe84 to your computer and use it in GitHub Desktop.
Save kurozumi/81377d044d9625f31b0429b9b30abe84 to your computer and use it in GitHub Desktop.
コントローラーでワードプレスの記事一覧を取得
<?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