mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 02:14:13 +00:00
Create a helper to read in a optional local_url to bypass the need to access the application using the external url.
This commit is contained in:
@@ -88,7 +88,7 @@ class cron extends CI_Controller {
|
||||
echo "CRON: " . $cron->id . " -> is due: " . $isdue_result . "\n";
|
||||
echo "CRON: " . $cron->id . " -> RUNNING...\n";
|
||||
|
||||
$url = base_url() . $cron->function;
|
||||
$url = local_url() . $cron->function;
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
|
||||
@@ -88,6 +88,28 @@ if ( ! function_exists('base_url'))
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('local_url'))
|
||||
{
|
||||
/**
|
||||
* Local URL
|
||||
*
|
||||
* For cornercases where you have no access to the base_url from
|
||||
* within e.g. the docker container to the base_url use this url
|
||||
* for cron jobs.
|
||||
*
|
||||
* If local_url is not defined return base_url instead.
|
||||
*
|
||||
* @param string $uri
|
||||
* @param string $protocol
|
||||
* @return string
|
||||
*/
|
||||
|
||||
function local_url($uri = '', $protocol = NULL)
|
||||
{
|
||||
return get_instance()->config->local_url($uri, $protocol) ?? get_instance()->config->base_url($uri, $protocol);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if ( ! function_exists('current_url'))
|
||||
|
||||
Reference in New Issue
Block a user