Skip to content

Commit

Permalink
ENH Provide hook for updating absoluteBaseURL
Browse files Browse the repository at this point in the history
One use case for this that I've run into a few times is for sending emails using a queued job from the CLI.
  • Loading branch information
GuySartorelli authored Dec 6, 2021
1 parent e63b73a commit 4960e8c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Control/Director.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,12 +460,14 @@ public static function absoluteURL($url, $relativeParent = self::BASE)
if ($relativeParent === self::ROOT || self::is_root_relative_url($url)) {
// Root relative urls always should be evaluated relative to the root
$parent = self::protocolAndHost();
static::singleton()->extend('updateAbsoluteBaseURL', $parent);
} elseif ($relativeParent === self::REQUEST) {
// Request relative urls rely on the REQUEST_URI param (old default behaviour)
if (!isset($_SERVER['REQUEST_URI'])) {
return false;
}
$parent = dirname($_SERVER['REQUEST_URI'] . 'x');
static::singleton()->extend('updateAbsoluteBaseURL', $parent);
} else {
// Default to respecting site base_url
$parent = self::absoluteBaseURL();
Expand Down Expand Up @@ -932,10 +934,12 @@ public static function fileExists($file)
*/
public static function absoluteBaseURL()
{
return self::absoluteURL(
$absolute = self::absoluteURL(
self::baseURL(),
self::ROOT
);
static::singleton()->extend('updateAbsoluteBaseURL', $absolute);
return $absolute;
}

/**
Expand Down

0 comments on commit 4960e8c

Please sign in to comment.