コントローラーでワードプレスの記事一覧を取得
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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