<?php
use CodeIgniter\Router\Exceptions\RouterException;
function url_to(string $controller, ...$args): string
{
if(empty($_GET['ref'])){
return original_url_to($controller, ...$args);
}
/* EXTRA CODE */
}
//This is a copy of the original CI4 url_to function
function original_url_to(string $controller, ...$args): string
{
if(!$route = route_to($controller, ...$args)){
$explode = explode('::', $controller);
if(isset($explode[1])){
throw RouterException::forControllerNotFound($explode[0], $explode[1]);
}
throw RouterException::forInvalidRoute($controller);
}
return site_url($route);
}