From eb07152ae1cdece442145fd5f44808d74234e912 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Mon, 18 Dec 2023 11:12:23 +0100 Subject: [PATCH] Revert "Remove internal `DocumentationSearchPage::routeKey()` method" This reverts commit 0838ab4f25f75299f28495dcb9191e03a1ea0f3a as the class is internal it doesn't bog up the public API, but we can still use it to reduce overlapping logic in our codebase. --- .../Documentation/DocumentationSearchPage.php | 3 ++- .../tests/Feature/DocumentationSearchPageTest.php | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php index e3070f59897..d5d90690c25 100644 --- a/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php +++ b/packages/framework/src/Framework/Features/Documentation/DocumentationSearchPage.php @@ -54,7 +54,8 @@ protected static function anotherSearchPageExists(): bool return Hyde::pages()->first(fn (HydePage $file): bool => $file->getRouteKey() === static::routeKey()) !== null; } - protected static function routeKey(): string + /** @deprecated Can be removed by https://github.com/hydephp/develop/pull/1498 */ + public static function routeKey(): string { return ltrim(DocumentationPage::outputDirectory().'/search'); } diff --git a/packages/framework/tests/Feature/DocumentationSearchPageTest.php b/packages/framework/tests/Feature/DocumentationSearchPageTest.php index 9f1d2546bec..cfb45b76a0c 100644 --- a/packages/framework/tests/Feature/DocumentationSearchPageTest.php +++ b/packages/framework/tests/Feature/DocumentationSearchPageTest.php @@ -59,4 +59,15 @@ public function testEnabledIsFalseWhenDisabledAndRouteExists() Hyde::pages()->put('docs/search', new InMemoryPage('docs/search')); $this->assertFalse(DocumentationSearchPage::enabled()); } + + public function testStaticRouteKeyHelper() + { + $this->assertSame('docs/search', DocumentationSearchPage::routeKey()); + } + + public function testStaticRouteKeyHelperWithCustomOutputDirectory() + { + DocumentationPage::setOutputDirectory('foo'); + $this->assertSame('foo/search', DocumentationSearchPage::routeKey()); + } }