Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.x] Deprecate Hyde::mediaLink being replaced by Hyde::asset() in v2 #1993

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -23,8 +24,14 @@ public function relativeLink(string $destination): string
return $this->hyperlinks->relativeLink($destination);
}

/**
* @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');

return $this->hyperlinks->mediaLink($destination, $validate);
}

Expand Down
4 changes: 4 additions & 0 deletions packages/framework/src/Foundation/Kernel/Hyperlinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -92,7 +93,10 @@ 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.
*/
#[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")) {
Expand Down