diff --git a/plugins/baser-core/src/Controller/AppController.php b/plugins/baser-core/src/Controller/AppController.php index 00e7f18e14..c47aef4cd1 100644 --- a/plugins/baser-core/src/Controller/AppController.php +++ b/plugins/baser-core/src/Controller/AppController.php @@ -255,8 +255,18 @@ public function beforeRender(EventInterface $event) */ public function setupFrontView(): void { - $this->viewBuilder()->setClassName('BaserCore.BcFrontApp'); - $this->viewBuilder()->setTheme(BcUtil::getCurrentTheme()); + $builder = $this->viewBuilder(); + $builder->setClassName('BaserCore.BcFrontApp'); + $builder->setTheme(BcUtil::getCurrentTheme()); + if($this->getRequest()->is('rss')) { + $response = $this->getResponse(); + $this->setResponse($response + ->withType($response->getMimeType('rss')) + ->withCharset(Configure::read('App.encoding')) + ); + $builder->setTemplatePath((string)$builder->getTemplatePath() . DS . 'rss'); + $builder->setLayoutPath('rss'); + } } /** diff --git a/plugins/bc-blog/src/Service/Front/BlogFrontService.php b/plugins/bc-blog/src/Service/Front/BlogFrontService.php index a4712a047a..a3c2b22cb9 100755 --- a/plugins/bc-blog/src/Service/Front/BlogFrontService.php +++ b/plugins/bc-blog/src/Service/Front/BlogFrontService.php @@ -115,14 +115,14 @@ public function getViewVarsForIndex(ServerRequest $request, BlogContent $blogCon * * @param ServerRequest $request * @param BlogContent $blogContent - * @param ResultSet $posts + * @param PaginatedResultSet $posts * @return array * * @checked * @noTodo * @unitTest */ - public function getViewVarsForIndexRss(ServerRequest $request, BlogContent $blogContent, ResultSet $posts): array + public function getViewVarsForIndexRss(ServerRequest $request, BlogContent $blogContent, PaginatedResultSet $posts): array { $site = $request->getAttribute('currentSite'); return [ diff --git a/plugins/bc-blog/tests/TestCase/Service/Front/BlogFrontServiceTest.php b/plugins/bc-blog/tests/TestCase/Service/Front/BlogFrontServiceTest.php index cdb34c6037..5b450cf8ab 100755 --- a/plugins/bc-blog/tests/TestCase/Service/Front/BlogFrontServiceTest.php +++ b/plugins/bc-blog/tests/TestCase/Service/Front/BlogFrontServiceTest.php @@ -34,6 +34,7 @@ use BcBlog\Test\Scenario\MultiSiteBlogPostScenario; use BcBlog\Test\Scenario\MultiSiteBlogScenario; use CakephpFixtureFactories\Scenario\ScenarioAwareTrait; +use Cake\Datasource\Paging\NumericPaginator; /** * BlogFrontServiceTest @@ -155,7 +156,9 @@ public function test_getViewVarsForIndexRss() $this->loginAdmin($request); //対象メソッドをコル - $rs = $this->BlogFrontService->getViewVarsForIndexRss($request, $blogContentService->get(1), $blogPostsService->getIndex([])->all()); + $paginator = new NumericPaginator(); + $posts = $paginator->paginate($blogPostsService->getIndex([])); + $rs = $this->BlogFrontService->getViewVarsForIndexRss($request, $blogContentService->get(1), $posts); //戻る値を確認 $this->assertArrayHasKey('blogContent', $rs);