From 4aa6f8234fb3752a9dde343033b896e9160661f9 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 12 Jul 2024 21:37:05 +0200 Subject: [PATCH] Extract method for the base authors route key --- .../Features/Blogging/DynamicBlogPostPageHelper.php | 7 +++++++ .../Features/Blogging/DynamicPages/PostAuthorPage.php | 3 ++- .../Features/Blogging/DynamicPages/PostAuthorsPage.php | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/framework/src/Framework/Features/Blogging/DynamicBlogPostPageHelper.php b/packages/framework/src/Framework/Features/Blogging/DynamicBlogPostPageHelper.php index f057fa6cf36..c231ecf8fe6 100644 --- a/packages/framework/src/Framework/Features/Blogging/DynamicBlogPostPageHelper.php +++ b/packages/framework/src/Framework/Features/Blogging/DynamicBlogPostPageHelper.php @@ -43,4 +43,11 @@ public static function generateAuthorPages(): array ->prepend(new PostAuthorsPage($authors)) ->all(); } + + public static function authorBaseRouteKey(): string + { + // Todo: Allow customizing this + + return 'authors'; + } } diff --git a/packages/framework/src/Framework/Features/Blogging/DynamicPages/PostAuthorPage.php b/packages/framework/src/Framework/Features/Blogging/DynamicPages/PostAuthorPage.php index 1729126072a..4f2f372303a 100644 --- a/packages/framework/src/Framework/Features/Blogging/DynamicPages/PostAuthorPage.php +++ b/packages/framework/src/Framework/Features/Blogging/DynamicPages/PostAuthorPage.php @@ -6,6 +6,7 @@ use Hyde\Pages\InMemoryPage; use Hyde\Framework\Features\Blogging\Models\PostAuthor; +use Hyde\Framework\Features\Blogging\DynamicBlogPostPageHelper; /** * @experimental @@ -18,7 +19,7 @@ class PostAuthorPage extends InMemoryPage public function __construct(PostAuthor $author) { - parent::__construct("authors/$author->username"); + parent::__construct(DynamicBlogPostPageHelper::authorBaseRouteKey()."/$author->username"); } public function getBladeView(): string diff --git a/packages/framework/src/Framework/Features/Blogging/DynamicPages/PostAuthorsPage.php b/packages/framework/src/Framework/Features/Blogging/DynamicPages/PostAuthorsPage.php index a4815b2e249..f06c388a62d 100644 --- a/packages/framework/src/Framework/Features/Blogging/DynamicPages/PostAuthorsPage.php +++ b/packages/framework/src/Framework/Features/Blogging/DynamicPages/PostAuthorsPage.php @@ -6,6 +6,7 @@ use Hyde\Pages\InMemoryPage; use Illuminate\Support\Collection; +use Hyde\Framework\Features\Blogging\DynamicBlogPostPageHelper; /** * @experimental @@ -19,7 +20,7 @@ class PostAuthorsPage extends InMemoryPage public function __construct(Collection $authors) { - parent::__construct('authors'); + parent::__construct(DynamicBlogPostPageHelper::authorBaseRouteKey()); $this->authors = $authors; }