Add actionUrl() helper to backend controller
Used for generating URLs to the current controller
This commit is contained in:
parent
46bfa78cef
commit
fc490b18e9
|
|
@ -298,6 +298,27 @@ class Controller extends Extendable
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a URL for this controller and supplied action.
|
||||
*/
|
||||
public function actionUrl($action = null, $path = null)
|
||||
{
|
||||
if ($action === null) {
|
||||
$action = $this->action;
|
||||
}
|
||||
|
||||
$class = get_called_class();
|
||||
$uriPath = dirname(dirname(strtolower(str_replace('\\', '/', $class))));
|
||||
$controllerName = strtolower(class_basename($class));
|
||||
|
||||
$url = $uriPath.'/'.$controllerName.'/'.$action;
|
||||
if ($path) {
|
||||
$url .= '/'.$path;
|
||||
}
|
||||
|
||||
return Backend::url($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes the current controller action without rendering a view,
|
||||
* used by AJAX handler that may rely on the logic inside the action.
|
||||
|
|
|
|||
Loading…
Reference in New Issue