Skip to content
Snippets Groups Projects
Commit 454180e9 authored by Sebastian Kehr's avatar Sebastian Kehr :rowboat_tone2: Committed by Dorian Merz
Browse files

refs #16552 [fid] enable Alpha debugging for FIDIS

* add xdebug related headers to fidis requests
* update composer.lock
parent edcb51e8
No related merge requests found
......@@ -7,6 +7,7 @@
"require": {
"finc/symfony-serializer-zend-bridge": "^0.0.1",
"phpdocumentor/reflection-docblock": "^4.3",
"symfony/http-foundation": "^3.4",
"zendframework/zend-i18n-resources": "^2.6"
}
}
\ No newline at end of file
......@@ -2360,6 +2360,60 @@
"homepage": "https://symfony.com",
"time": "2019-01-01T13:45:19+00:00"
},
{
"name": "symfony/http-foundation",
"version": "v3.4.36",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-foundation.git",
"reference": "d2d0cfe8e319d9df44c4cca570710fcf221d4593"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/d2d0cfe8e319d9df44c4cca570710fcf221d4593",
"reference": "d2d0cfe8e319d9df44c4cca570710fcf221d4593",
"shasum": ""
},
"require": {
"php": "^5.5.9|>=7.0.8",
"symfony/polyfill-mbstring": "~1.1",
"symfony/polyfill-php70": "~1.6"
},
"require-dev": {
"symfony/expression-language": "~2.8|~3.0|~4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.4-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\HttpFoundation\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony HttpFoundation Component",
"homepage": "https://symfony.com",
"time": "2019-11-28T12:52:59+00:00"
},
{
"name": "symfony/inflector",
"version": "v3.4.21",
......
......@@ -33,6 +33,7 @@ use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\UriFactoryInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Serializer\SerializerInterface;
use VuFind\Cookie\CookieManager;
use Zend\Session\Container as Session;
......@@ -48,7 +49,7 @@ class Client
/**
* @var string
*/
protected $baseUrl;
protected $config;
/**
* @var Session
......@@ -82,7 +83,7 @@ class Client
protected $streamFactory;
/**
* @var RequestInterface
* @var RequestFactoryInterface
*/
protected $requestFactory;
......@@ -94,7 +95,7 @@ class Client
/**
* Client constructor.
*
* @param string $baseUrl
* @param array $config
* @param Session $session
* @param CookieManager $cookies
* @param SerializerInterface $serializer
......@@ -104,7 +105,7 @@ class Client
* @param RequestFactoryInterface $requestFactory
*/
public function __construct(
string $baseUrl,
array $config,
Session $session,
CookieManager $cookies,
SerializerInterface $serializer,
......@@ -113,7 +114,7 @@ class Client
StreamFactoryInterface $streamFactory,
RequestFactoryInterface $requestFactory
) {
$this->baseUrl = $baseUrl;
$this->config = $config;
$this->session = $session;
$this->cookies = $cookies;
$this->serializer = $serializer;
......@@ -644,14 +645,27 @@ class Client
string $body = '',
array $query = []
): RequestInterface {
$uri = $this->uriFactory->createUri("$this->baseUrl/$path")
$baseUrl = $this->config['baseUrl'];
$uri = $this->uriFactory->createUri("$baseUrl/$path")
->withQuery(http_build_query($query));
return $this->requestFactory->createRequest($verb, $uri)
$request = $this->requestFactory->createRequest($verb, $uri)
->withBody($this->streamFactory->createStream($body))
->withHeader('Content-type', 'application/json')
->withHeader('Accept', 'application/json')
->withHeader('Accept-language', $this->locale);
if (APPLICATION_ENV === 'production') {
return $request;
}
$xdebugSession = $this->config['xdebug_session'] ?? 'fidis';
$xdebugRemoteAddr = $this->config['xdebug_remote_addr']
?? Request::createFromGlobals()->getClientIp();
return APPLICATION_ENV === 'production' ? $request
: $request->withHeader('Cookie', "XDEBUG_SESSION=$xdebugSession")
->withHeader('X-xdebug-remote-addr', $xdebugRemoteAddr);
}
/**
......
......@@ -71,7 +71,7 @@ class ClientFactory
/** @var RequestFactoryInterface $requestFactory */
$requestFactory = $container->get(RequestFactoryInterface::class);
return new Client($config->baseUrl, $session, $cookies, $serializer,
return new Client($config->toArray(), $session, $cookies, $serializer,
$httpClient, $uriFactory, $streamFactory, $requestFactory);
}
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment