Skip to content

Commit

Permalink
Merge pull request #1993 from hydephp/deprecate-hyde-media-link-in-fa…
Browse files Browse the repository at this point in the history
…vour-of-hyde-asset

[1.x] Deprecate `Hyde::mediaLink` being replaced by `Hyde::asset()` in v2
  • Loading branch information
caendesilva authored Nov 5, 2024
2 parents ea8dcd0 + 8f7b543 commit ef7cce7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
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

0 comments on commit ef7cce7

Please sign in to comment.