Skip to content

Commit

Permalink
Add compatibility mode constant to disable new global helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Feb 26, 2024
1 parent 6cea109 commit 0195d1d
Showing 1 changed file with 31 additions and 27 deletions.
58 changes: 31 additions & 27 deletions packages/framework/src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,37 @@ function unslash(string $string): string
}
}

if (! function_exists('asset')) {
/**
* Get a relative link or URL to an asset in the media directory.
*/
function asset(string $name, bool $preferQualifiedUrl = false): string
{
return hyde()->asset($name, $preferQualifiedUrl);
}
}

if (! function_exists('route')) {
/**
* Get a page route by its key.
*/
function route(string $key): ?Hyde\Support\Models\Route
{
return hyde()->route($key);
}
}

if (! function_exists('url')) {
/**
* Get a qualified URL to the supplied path if a base URL is set.
*/
function url(string $path = ''): string
{
return hyde()->url($path);
if (defined('HYDE_COMPATIBILITY_MODE') && HYDE_COMPATIBILITY_MODE === true) {
// Don't declare these functions when running in compatibility mode.
} else {
if (! function_exists('asset')) {
/**
* Get a relative link or URL to an asset in the media directory.
*/
function asset(string $name, bool $preferQualifiedUrl = false): string
{
return hyde()->asset($name, $preferQualifiedUrl);
}
}

if (! function_exists('route')) {
/**
* Get a page route by its key.
*/
function route(string $key): ?Hyde\Support\Models\Route
{
return hyde()->route($key);
}
}

if (! function_exists('url')) {
/**
* Get a qualified URL to the supplied path if a base URL is set.
*/
function url(string $path = ''): string
{
return hyde()->url($path);
}
}
}
}
Expand Down

0 comments on commit 0195d1d

Please sign in to comment.