From b28efc47b6871d016cb7a6f9d22ac60689511d68 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 5 Nov 2024 14:18:21 +0100 Subject: [PATCH 1/3] Deprecate `Hyde::mediaLink` being replaced in v2 --- .../framework/src/Foundation/Concerns/ForwardsHyperlinks.php | 5 +++++ packages/framework/src/Foundation/Kernel/Hyperlinks.php | 2 ++ 2 files changed, 7 insertions(+) diff --git a/packages/framework/src/Foundation/Concerns/ForwardsHyperlinks.php b/packages/framework/src/Foundation/Concerns/ForwardsHyperlinks.php index 9d194fd5f42..8b47096a028 100644 --- a/packages/framework/src/Foundation/Concerns/ForwardsHyperlinks.php +++ b/packages/framework/src/Foundation/Concerns/ForwardsHyperlinks.php @@ -23,8 +23,13 @@ public function relativeLink(string $destination): string return $this->hyperlinks->relativeLink($destination); } + /** + * @deprecated This method will be removed in v2.0. Please use `asset()` instead. + */ public function mediaLink(string $destination, bool $validate = false): string { + trigger_deprecation('hyde/framework', '1.8.0', 'The %s() method is deprecated, use %s() instead.', __METHOD__, 'asset'); + return $this->hyperlinks->mediaLink($destination, $validate); } diff --git a/packages/framework/src/Foundation/Kernel/Hyperlinks.php b/packages/framework/src/Foundation/Kernel/Hyperlinks.php index 1e352060001..77466834491 100644 --- a/packages/framework/src/Foundation/Kernel/Hyperlinks.php +++ b/packages/framework/src/Foundation/Kernel/Hyperlinks.php @@ -92,6 +92,8 @@ public function relativeLink(string $destination): string * * An exception will be thrown if the file does not exist in the _media directory, * and the second argument is set to true. + * + * @deprecated This method will be removed in v2.0. Please use `asset()` instead. */ public function mediaLink(string $destination, bool $validate = false): string { From bb63922c1d8d19fc070bdc57dc085bdf50747e60 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 5 Nov 2024 14:22:55 +0100 Subject: [PATCH 2/3] Add deprecated attributes --- .../framework/src/Foundation/Concerns/ForwardsHyperlinks.php | 2 ++ packages/framework/src/Foundation/Kernel/Hyperlinks.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/packages/framework/src/Foundation/Concerns/ForwardsHyperlinks.php b/packages/framework/src/Foundation/Concerns/ForwardsHyperlinks.php index 8b47096a028..7f5bef1d14e 100644 --- a/packages/framework/src/Foundation/Concerns/ForwardsHyperlinks.php +++ b/packages/framework/src/Foundation/Concerns/ForwardsHyperlinks.php @@ -5,6 +5,7 @@ namespace Hyde\Foundation\Concerns; use Hyde\Support\Models\Route; +use JetBrains\PhpStorm\Deprecated; /** * @internal Single-use trait for the HydeKernel class. @@ -26,6 +27,7 @@ public function relativeLink(string $destination): string /** * @deprecated This method will be removed in v2.0. Please use `asset()` instead. */ + #[Deprecated(reason: 'Use `asset` method instead.', replacement: '%class%::asset(%parameter0%)')] public function mediaLink(string $destination, bool $validate = false): string { trigger_deprecation('hyde/framework', '1.8.0', 'The %s() method is deprecated, use %s() instead.', __METHOD__, 'asset'); diff --git a/packages/framework/src/Foundation/Kernel/Hyperlinks.php b/packages/framework/src/Foundation/Kernel/Hyperlinks.php index 77466834491..2a94165d2c2 100644 --- a/packages/framework/src/Foundation/Kernel/Hyperlinks.php +++ b/packages/framework/src/Foundation/Kernel/Hyperlinks.php @@ -7,6 +7,7 @@ use Hyde\Facades\Config; use Hyde\Support\Models\Route; use Hyde\Foundation\HydeKernel; +use JetBrains\PhpStorm\Deprecated; use Hyde\Framework\Exceptions\BaseUrlNotSetException; use Hyde\Framework\Exceptions\FileNotFoundException; use Illuminate\Support\Str; @@ -95,6 +96,7 @@ public function relativeLink(string $destination): string * * @deprecated This method will be removed in v2.0. Please use `asset()` instead. */ + #[Deprecated(reason: 'Use `asset` method instead.', replacement: '%class%->asset(%parameter0%)')] public function mediaLink(string $destination, bool $validate = false): string { if ($validate && ! file_exists($sourcePath = "{$this->kernel->getMediaDirectory()}/$destination")) { From 8f7b5436bd0fe7788fb9a6ac174fd83680403571 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 5 Nov 2024 14:23:05 +0100 Subject: [PATCH 3/3] Update RELEASE_NOTES.md --- RELEASE_NOTES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index edc66d3f209..9b19d874a66 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -31,6 +31,7 @@ This serves two purposes: ### Deprecated - The `PostAuthor::getName()` method is now deprecated and will be removed in v2. (use `$author->name` instead) in https://github.com/hydephp/develop/pull/1794 - Deprecated the `FeaturedImage::isRemote()` method in favor of the new `Hyperlinks::isRemote()` method in https://github.com/hydephp/develop/pull/1882 +- Deprecated the `Hyde::mediaLink()` method in favor of the `Hyde::asset()` method in https://github.com/hydephp/develop/pull/1993 ### Removed - for now removed features.