From 6c9819204dbdd9ccd138733ac88ca7ebce5b0886 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 21 Jul 2015 16:33:24 +0200 Subject: [PATCH] Form: Only work with a single type when handling redirect urls $form->setRedirectUrl('some/url') still works, but $form->getRedirectUrl() will only return instances of Icinga\Web\Url now. --- library/Icinga/Web/Form.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index 1e5487f7c..78ae1f587 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -84,7 +84,7 @@ class Form extends Zend_Form /** * The url to redirect to upon success * - * @var string|Url + * @var Url */ protected $redirectUrl; @@ -262,9 +262,17 @@ class Form extends Zend_Form * @param string|Url $url The url to redirect to * * @return $this + * + * @throws ProgrammingError In case $url is neither a string nor a instance of Icinga\Web\Url */ public function setRedirectUrl($url) { + if (is_string($url)) { + $url = Url::fromPath($url, array(), $this->getRequest()); + } elseif (! $url instanceof Url) { + throw new ProgrammingError('$url must be a string or instance of Icinga\Web\Url'); + } + $this->redirectUrl = $url; return $this; } @@ -272,7 +280,7 @@ class Form extends Zend_Form /** * Return the url to redirect to upon success * - * @return string|Url + * @return Url */ public function getRedirectUrl() {