From 5a1a58107c9325df71966cd9d46bd31e7e87dcb4 Mon Sep 17 00:00:00 2001 From: kato Date: Wed, 21 May 2025 12:30:17 +0900 Subject: [PATCH 1/7] =?UTF-8?q?fix=20#4176=20=E3=80=90=E3=83=95=E3=82=A3?= =?UTF-8?q?=E3=83=BC=E3=83=89=20=E3=80=91index.rss=E3=81=8CError=E3=81=AB?= =?UTF-8?q?=E3=81=AA=E3=82=8B=E5=95=8F=E9=A1=8C=E3=82=92=E8=A7=A3=E6=B1=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../baser-core/src/Controller/AppController.php | 14 ++++++++++++-- .../bc-blog/src/Service/Front/BlogFrontService.php | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) 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..fed7138b5a 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|ResultSet $posts * @return array * * @checked * @noTodo * @unitTest */ - public function getViewVarsForIndexRss(ServerRequest $request, BlogContent $blogContent, ResultSet $posts): array + public function getViewVarsForIndexRss(ServerRequest $request, BlogContent $blogContent, PaginatedResultSet|ResultSet $posts): array { $site = $request->getAttribute('currentSite'); return [ From 16de8a5988a9da015a5cc7fce11e4a58876ddce4 Mon Sep 17 00:00:00 2001 From: kato Date: Wed, 21 May 2025 19:48:24 +0900 Subject: [PATCH 2/7] =?UTF-8?q?PaginatedResultSet=E3=81=AE=E3=81=BF?= =?UTF-8?q?=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/bc-blog/src/Service/Front/BlogFrontService.php | 4 ++-- .../tests/TestCase/Service/Front/BlogFrontServiceTest.php | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/bc-blog/src/Service/Front/BlogFrontService.php b/plugins/bc-blog/src/Service/Front/BlogFrontService.php index fed7138b5a..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 PaginatedResultSet|ResultSet $posts + * @param PaginatedResultSet $posts * @return array * * @checked * @noTodo * @unitTest */ - public function getViewVarsForIndexRss(ServerRequest $request, BlogContent $blogContent, PaginatedResultSet|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..5d29bb5b32 100755 --- a/plugins/bc-blog/tests/TestCase/Service/Front/BlogFrontServiceTest.php +++ b/plugins/bc-blog/tests/TestCase/Service/Front/BlogFrontServiceTest.php @@ -139,11 +139,13 @@ public function test_getViewVarsForIndexRss() // データ生成 $this->loadFixtureScenario(InitAppScenario::class); $this->loadFixtureScenario(BlogContentScenario::class, 1, 1, null, 'test', '/'); + $limit = $blogContentService->get(1)->feed_count; BlogPostFactory::make([ 'id' => 1, 'blog_content_id' => 1, 'no' => 1, 'title' => 'blog post title', + 'limit' => $listCount, 'status' => true ])->persist(); From 8ee51e47abd4ab4777162d89ec61c5a6199358a0 Mon Sep 17 00:00:00 2001 From: kato Date: Wed, 21 May 2025 20:15:38 +0900 Subject: [PATCH 3/7] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E8=AA=BF?= =?UTF-8?q?=E6=95=B4=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests/TestCase/Service/Front/BlogFrontServiceTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/bc-blog/tests/TestCase/Service/Front/BlogFrontServiceTest.php b/plugins/bc-blog/tests/TestCase/Service/Front/BlogFrontServiceTest.php index 5d29bb5b32..b7556fdcc7 100755 --- a/plugins/bc-blog/tests/TestCase/Service/Front/BlogFrontServiceTest.php +++ b/plugins/bc-blog/tests/TestCase/Service/Front/BlogFrontServiceTest.php @@ -157,7 +157,7 @@ public function test_getViewVarsForIndexRss() $this->loginAdmin($request); //対象メソッドをコル - $rs = $this->BlogFrontService->getViewVarsForIndexRss($request, $blogContentService->get(1), $blogPostsService->getIndex([])->all()); + $rs = $this->BlogFrontService->getViewVarsForIndexRss($request, $blogContentService->get(1), $blogPostsService->getIndex([])); //戻る値を確認 $this->assertArrayHasKey('blogContent', $rs); From 65171c4acac99b7e7c98b3320cfab150f476ae0d Mon Sep 17 00:00:00 2001 From: kato Date: Wed, 21 May 2025 20:54:21 +0900 Subject: [PATCH 4/7] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E8=AA=BF?= =?UTF-8?q?=E6=95=B4=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests/TestCase/Service/Front/BlogFrontServiceTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/bc-blog/tests/TestCase/Service/Front/BlogFrontServiceTest.php b/plugins/bc-blog/tests/TestCase/Service/Front/BlogFrontServiceTest.php index b7556fdcc7..59cb43e26e 100755 --- a/plugins/bc-blog/tests/TestCase/Service/Front/BlogFrontServiceTest.php +++ b/plugins/bc-blog/tests/TestCase/Service/Front/BlogFrontServiceTest.php @@ -155,9 +155,10 @@ public function test_getViewVarsForIndexRss() 'Content' => ContentFactory::get(1) ]); $this->loginAdmin($request); + $this->setRequest()->is('rss'); //対象メソッドをコル - $rs = $this->BlogFrontService->getViewVarsForIndexRss($request, $blogContentService->get(1), $blogPostsService->getIndex([])); + $rs = $this->BlogFrontService->getViewVarsForIndexRss($request, $blogContentService->get(1), $blogPostsService->getIndex([])->all()); //戻る値を確認 $this->assertArrayHasKey('blogContent', $rs); From 7ad2a29095936da2eb4310751b8527b2406e2963 Mon Sep 17 00:00:00 2001 From: kato Date: Wed, 21 May 2025 21:21:34 +0900 Subject: [PATCH 5/7] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E8=AA=BF?= =?UTF-8?q?=E6=95=B4=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests/TestCase/Service/Front/BlogFrontServiceTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/bc-blog/tests/TestCase/Service/Front/BlogFrontServiceTest.php b/plugins/bc-blog/tests/TestCase/Service/Front/BlogFrontServiceTest.php index 59cb43e26e..a0a701c903 100755 --- a/plugins/bc-blog/tests/TestCase/Service/Front/BlogFrontServiceTest.php +++ b/plugins/bc-blog/tests/TestCase/Service/Front/BlogFrontServiceTest.php @@ -152,10 +152,10 @@ public function test_getViewVarsForIndexRss() //パラメーターの準備 $request = $this->getRequest()->withQueryParams([ 'Site' => SiteFactory::get(1), - 'Content' => ContentFactory::get(1) + 'Content' => ContentFactory::get(1), + 'type' => 'rss', ]); $this->loginAdmin($request); - $this->setRequest()->is('rss'); //対象メソッドをコル $rs = $this->BlogFrontService->getViewVarsForIndexRss($request, $blogContentService->get(1), $blogPostsService->getIndex([])->all()); From a5fc8c1a4cae12772786dce1f2d3253dd42e7d0a Mon Sep 17 00:00:00 2001 From: ryuring Date: Thu, 22 May 2025 15:18:28 +0900 Subject: [PATCH 6/7] Update BlogFrontServiceTest.php --- .../tests/TestCase/Service/Front/BlogFrontServiceTest.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/bc-blog/tests/TestCase/Service/Front/BlogFrontServiceTest.php b/plugins/bc-blog/tests/TestCase/Service/Front/BlogFrontServiceTest.php index a0a701c903..445963fe84 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 @@ -139,13 +140,11 @@ public function test_getViewVarsForIndexRss() // データ生成 $this->loadFixtureScenario(InitAppScenario::class); $this->loadFixtureScenario(BlogContentScenario::class, 1, 1, null, 'test', '/'); - $limit = $blogContentService->get(1)->feed_count; BlogPostFactory::make([ 'id' => 1, 'blog_content_id' => 1, 'no' => 1, 'title' => 'blog post title', - 'limit' => $listCount, 'status' => true ])->persist(); @@ -158,7 +157,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); From 35216bad7b0e4f053852e87b45e69fafca74f717 Mon Sep 17 00:00:00 2001 From: ryuring Date: Thu, 22 May 2025 15:19:18 +0900 Subject: [PATCH 7/7] Update BlogFrontServiceTest.php --- .../tests/TestCase/Service/Front/BlogFrontServiceTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/bc-blog/tests/TestCase/Service/Front/BlogFrontServiceTest.php b/plugins/bc-blog/tests/TestCase/Service/Front/BlogFrontServiceTest.php index 445963fe84..5b450cf8ab 100755 --- a/plugins/bc-blog/tests/TestCase/Service/Front/BlogFrontServiceTest.php +++ b/plugins/bc-blog/tests/TestCase/Service/Front/BlogFrontServiceTest.php @@ -151,8 +151,7 @@ public function test_getViewVarsForIndexRss() //パラメーターの準備 $request = $this->getRequest()->withQueryParams([ 'Site' => SiteFactory::get(1), - 'Content' => ContentFactory::get(1), - 'type' => 'rss', + 'Content' => ContentFactory::get(1) ]); $this->loginAdmin($request);