}
/**
+ * Identical to add(), except the return value is a cloned object.
+ *
+ * @param mixed $parameters Either the name value or an array of
+ * name/value pairs.
+ * @param string $value If specified, the value part ($parameters is
+ * then assumed to just be the parameter name).
+ *
+ * @return Horde_Url Cloned object, to allow chaining.
+ */
+ public function cAdd($parameters, $value = null)
+ {
+ $url = clone $this;
+ return $url->add($parameters, $value);
+ }
+
+ /**
* Removes one ore more parameters.
*
* @param mixed $remove Either a single parameter to remove or an array
}
/**
+ * Identical to remove(), except the return value is a cloned object.
+ *
+ * @param mixed $remove Either a single parameter to remove or an array
+ * of parameters to remove.
+ *
+ * @return Horde_Url Cloned object, to allow chaining.
+ */
+ public function cRemove($parameters)
+ {
+ $url = clone $this;
+ return $url->remove($parameters);
+ }
+
+ /**
* Creates the full URL string.
*
* @return string The string representation of this object.
}
if ($url instanceof Horde_Url) {
- // In many places we re-use URLs assuming they are strings. With
- // Horde_Url objects, this can lead to reference problems and URLs
- // being mysteriously modified. For now, we have to clone any
- // objects to avoid modifying them.
- $url2 = clone($url);
+ $url2 = $url->cAdd($parameter, $value);
$url2->raw = !$encode;
- return $url2->add($parameter, $value);
+ return $url2;
}
$horde_url = new Horde_Url($url, !$encode);
static public function removeParameter($url, $remove)
{
if ($url instanceof Horde_Url) {
- // In many places we re-use URLs assuming they are strings. With
- // Horde_Url objects, this can lead to reference problems and URLs
- // being mysteriously modified. For now, we have to clone any
- // objects to avoid modifying them.
- $url2 = clone($url);
- return $url2->remove($remove);
+ return $url->cRemove($remove);
}
$horde_url = new Horde_Url($url);