optimize duplication of Request objects
This commit is contained in:
parent
06e2c01e76
commit
5d87d83a10
@ -223,14 +223,34 @@ class Request
|
||||
public function duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null)
|
||||
{
|
||||
$dup = clone $this;
|
||||
$dup->initialize(
|
||||
null !== $query ? $query : $this->query->all(),
|
||||
null !== $request ? $request : $this->request->all(),
|
||||
null !== $attributes ? $attributes : $this->attributes->all(),
|
||||
null !== $cookies ? $cookies : $this->cookies->all(),
|
||||
null !== $files ? $files : $this->files->all(),
|
||||
null !== $server ? $server : $this->server->all()
|
||||
);
|
||||
if ($query !== null) {
|
||||
$dup->query = new ParameterBag($query);
|
||||
}
|
||||
if ($request !== null) {
|
||||
$dup->request = new ParameterBag($request);
|
||||
}
|
||||
if ($attributes !== null) {
|
||||
$dup->attributes = new ParameterBag($attributes);
|
||||
}
|
||||
if ($cookies !== null) {
|
||||
$dup->cookies = new ParameterBag($cookies);
|
||||
}
|
||||
if ($files !== null) {
|
||||
$dup->files = new FileBag($files);
|
||||
}
|
||||
if ($server !== null) {
|
||||
$dup->server = new ServerBag($server);
|
||||
$dup->headers = new HeaderBag($dup->server->getHeaders());
|
||||
}
|
||||
$this->languages = null;
|
||||
$this->charsets = null;
|
||||
$this->acceptableContentTypes = null;
|
||||
$this->pathInfo = null;
|
||||
$this->requestUri = null;
|
||||
$this->baseUrl = null;
|
||||
$this->basePath = null;
|
||||
$this->method = null;
|
||||
$this->format = null;
|
||||
|
||||
return $dup;
|
||||
}
|
||||
|
@ -1243,14 +1243,34 @@ class Request
|
||||
public function duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null)
|
||||
{
|
||||
$dup = clone $this;
|
||||
$dup->initialize(
|
||||
null !== $query ? $query : $this->query->all(),
|
||||
null !== $request ? $request : $this->request->all(),
|
||||
null !== $attributes ? $attributes : $this->attributes->all(),
|
||||
null !== $cookies ? $cookies : $this->cookies->all(),
|
||||
null !== $files ? $files : $this->files->all(),
|
||||
null !== $server ? $server : $this->server->all()
|
||||
);
|
||||
if ($query !== null) {
|
||||
$dup->query = new ParameterBag($query);
|
||||
}
|
||||
if ($request !== null) {
|
||||
$dup->request = new ParameterBag($request);
|
||||
}
|
||||
if ($attributes !== null) {
|
||||
$dup->attributes = new ParameterBag($attributes);
|
||||
}
|
||||
if ($cookies !== null) {
|
||||
$dup->cookies = new ParameterBag($cookies);
|
||||
}
|
||||
if ($files !== null) {
|
||||
$dup->files = new FileBag($files);
|
||||
}
|
||||
if ($server !== null) {
|
||||
$dup->server = new ServerBag($server);
|
||||
$dup->headers = new HeaderBag($dup->server->getHeaders());
|
||||
}
|
||||
$this->languages = null;
|
||||
$this->charsets = null;
|
||||
$this->acceptableContentTypes = null;
|
||||
$this->pathInfo = null;
|
||||
$this->requestUri = null;
|
||||
$this->baseUrl = null;
|
||||
$this->basePath = null;
|
||||
$this->method = null;
|
||||
$this->format = null;
|
||||
return $dup;
|
||||
}
|
||||
public function __clone()
|
||||
|
Reference in New Issue
Block a user