public function generateURL($url, $class, $method, array $parameters = [])
{
// check if the class is a service
if (Model::getContainer()->has($class)) {
$class = Model::getContainer()->get($class);
}
// validate (check if the function exists)
if (!is_callable([$class, $method])) {
throw new Exception('The callback-method doesn\'t exist.');
}
// when using ->getValue() in SpoonFormText fields the function is using htmlentities(),
// so we must decode it again first!
$url = SpoonFilter::htmlentitiesDecode($url);
$actualParameters = [];
// build parameters for use in the callback
$actualParameters[] = Uri::getUrl($url);
// add parameters set by user
if (!empty($parameters)) {
foreach ($parameters as $parameter) {
$actualParameters[] = $parameter;
}
}
// get the real url
return call_user_func_array([$class, $method], $actualParameters);
}