lithium\net\http\Router::_persist()
Copies persistent parameters (parameters in the request which have been designated to
persist) to the current URL, unless the parameter has been explicitly disabled from
persisting by setting the value in the URL to null
, or by assigning some other value.
For example:
Router::connect('/{:controller}/{:action}/{:id:[0-9]+}', array(), array(
'persist' => array('controller', 'id')
));
// URLs generated with $request will now have the 'controller' and 'id'
// parameters copied to new URLs.
$request = Router::process(new Request(array('url' => 'posts/view/1138')));
$params = array('action' => 'edit');
$url = Router::match($params, $request); // Returns: '/posts/edit/1138'
Parameters
-
array
$url
The parameters that define the URL to be matched.
-
\lithium\action\Request
$context
A request object, which contains a
$persist
property, which is an array of keys to be persisted in URLs between requests.
Returns
arrayReturns the modified URL array.
Source
protected static function _persist($url, $context) {
if (!$context || !isset($context->persist)) {
return $url;
}
foreach ($context->persist as $key) {
$url += [$key => $context->params[$key]];
if ($url[$key] === null) {
unset($url[$key]);
}
}
return $url;
}