From baa775dd7466344758708bcf553a3bf4e8656e79 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Fri, 5 Sep 2014 11:40:43 +0200 Subject: [PATCH] Web\Url: document with() method --- library/Icinga/Web/Url.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Web/Url.php b/library/Icinga/Web/Url.php index f4d622af3..a3af4a338 100644 --- a/library/Icinga/Web/Url.php +++ b/library/Icinga/Web/Url.php @@ -5,6 +5,7 @@ namespace Icinga\Web; use Icinga\Application\Icinga; +use Icinga\Cli\FakeRequest; use Icinga\Exception\ProgrammingError; use Icinga\Web\UrlParams; @@ -98,7 +99,12 @@ class Url */ protected static function getRequest() { - return Icinga::app()->getFrontController()->getRequest(); + $app = Icinga::app(); + if ($app->isCli()) { + return new FakeRequest(); + } else { + return $app->getFrontController()->getRequest(); + } } /** @@ -424,6 +430,17 @@ class Url return $url; } + /** + * Return a copy of this url with the given parameter(s) + * + * The argument can be either a single query parameter name or an array of parameter names to + * remove from the query list + * + * @param string|array $param A single string or an array containing parameter names + * @param array $values an optional values array + * + * @return Url + */ public function with($param, $values = null) { $url = clone($this);