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)
|
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 = clone $this;
|
||||||
$dup->initialize(
|
if ($query !== null) {
|
||||||
null !== $query ? $query : $this->query->all(),
|
$dup->query = new ParameterBag($query);
|
||||||
null !== $request ? $request : $this->request->all(),
|
}
|
||||||
null !== $attributes ? $attributes : $this->attributes->all(),
|
if ($request !== null) {
|
||||||
null !== $cookies ? $cookies : $this->cookies->all(),
|
$dup->request = new ParameterBag($request);
|
||||||
null !== $files ? $files : $this->files->all(),
|
}
|
||||||
null !== $server ? $server : $this->server->all()
|
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;
|
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)
|
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 = clone $this;
|
||||||
$dup->initialize(
|
if ($query !== null) {
|
||||||
null !== $query ? $query : $this->query->all(),
|
$dup->query = new ParameterBag($query);
|
||||||
null !== $request ? $request : $this->request->all(),
|
}
|
||||||
null !== $attributes ? $attributes : $this->attributes->all(),
|
if ($request !== null) {
|
||||||
null !== $cookies ? $cookies : $this->cookies->all(),
|
$dup->request = new ParameterBag($request);
|
||||||
null !== $files ? $files : $this->files->all(),
|
}
|
||||||
null !== $server ? $server : $this->server->all()
|
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;
|
return $dup;
|
||||||
}
|
}
|
||||||
public function __clone()
|
public function __clone()
|
||||||
|
Reference in New Issue
Block a user