aboutsummaryrefslogtreecommitdiff
path: root/app/controllers/studip_controller.php
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+studip@gmail.com>2022-02-21 11:42:06 +0000
committerJan-Hendrik Willms <tleilax+studip@gmail.com>2022-02-21 11:42:06 +0000
commit2c384d9cb5b59432772747ec85a86bd86eecbb11 (patch)
treeb313c43a71773b9bfbde51a7716e2c578e9b6eeb /app/controllers/studip_controller.php
parent462a4673c3d2402d643f2dc5bedaf6a6230ec8b1 (diff)
allow no parameters for url_for(), fixes #642
Diffstat (limited to 'app/controllers/studip_controller.php')
-rw-r--r--app/controllers/studip_controller.php24
1 files changed, 12 insertions, 12 deletions
diff --git a/app/controllers/studip_controller.php b/app/controllers/studip_controller.php
index 7c0991e..fd52034 100644
--- a/app/controllers/studip_controller.php
+++ b/app/controllers/studip_controller.php
@@ -252,6 +252,14 @@ abstract class StudipController extends Trails_Controller
{
$args = func_get_args();
+ // Try to create route if none given
+ if ($to === '') {
+ $to = $this->parent_controller
+ ? $this->parent_controller->current_action
+ : $this->current_action;
+ return $this->action_url($to);
+ }
+
// Create url for a specific action
// TODO: This seems odd. You kinda specify an absolute path
// to receive a relative url. Meh...
@@ -287,14 +295,6 @@ abstract class StudipController extends Trails_Controller
//preserve fragment
[$to, $fragment] = explode('#', $to);
- // Try to create route if none given
- if (!$to) {
- $to = '/';
- $to .= $this->parent_controller
- ? $this->parent_controller->current_action
- : $this->current_action;
- }
-
$url = parent::url_for($to);
if ($fragment) {
@@ -365,15 +365,15 @@ abstract class StudipController extends Trails_Controller
*/
private function adjustToArguments(...$args): string
{
- if ($this->isURL($args[0]) && count($args) > 1) {
+ if (count($args) > 1 && $this->isURL($args[0])) {
throw new InvalidArgumentException('Method may not be used with a URL and multiple parameters');
}
- if (count($args) > 1 || !$this->isURL($args[0])) {
- return $this->url_for(...$args);
+ if (count($args) === 1 && $this->isURL($args[0])) {
+ return $args[0];
}
- return $args[0];
+ return $this->url_for(...$args);
}
/**