Skip to content

Commit 5076934

Browse files
bug symfony#54 Fix symfony#51 (compatability issue with zendframework/zend-diactoros ^2.0) (uphlewis)
This PR was merged into the 1.1-dev branch. Discussion ---------- Fix symfony#51 (compatability issue with zendframework/zend-diactoros ^2.0) Uses method_exists to check whether the object has the required method, and uses the new namespaced function(s) if not. Commits ------- 8ff61e5 Fix compatability issue with "zendframework/zend-diactoros": "^2.0." (symfony#51)
2 parents 53c15a6 + 8ff61e5 commit 5076934

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Factory/DiactorosFactory.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ public function __construct()
4343
*/
4444
public function createRequest(Request $symfonyRequest)
4545
{
46-
$server = DiactorosRequestFactory::normalizeServer($symfonyRequest->server->all());
46+
$server = method_exists('Zend\Diactoros\ServerRequestFactory', 'normalizeServer')
47+
? DiactorosRequestFactory::normalizeServer($symfonyRequest->server->all())
48+
: \Zend\Diactoros\normalizeServer($symfonyRequest->server->all());
4749
$headers = $symfonyRequest->headers->all();
4850

4951
if (PHP_VERSION_ID < 50600) {
@@ -53,9 +55,13 @@ public function createRequest(Request $symfonyRequest)
5355
$body = new DiactorosStream($symfonyRequest->getContent(true));
5456
}
5557

58+
$files = method_exists('Zend\Diactoros\ServerRequestFactory', 'normalizeFiles')
59+
? DiactorosRequestFactory::normalizeFiles($this->getFiles($symfonyRequest->files->all()))
60+
: \Zend\Diactoros\normalizeUploadedFiles($this->getFiles($symfonyRequest->files->all()));
61+
5662
$request = new ServerRequest(
5763
$server,
58-
DiactorosRequestFactory::normalizeFiles($this->getFiles($symfonyRequest->files->all())),
64+
$files,
5965
$symfonyRequest->getSchemeAndHttpHost().$symfonyRequest->getRequestUri(),
6066
$symfonyRequest->getMethod(),
6167
$body,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy