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