mirror of
https://github.com/werkraum-media/events.git
synced 2024-11-10 08:16:09 +01:00
Daniel Siepmann
0e5cd38176
The test ensures import runs with a small example set of events. We needed to alter fetching of images, in order to properly mock responses.
55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Wrm\Events\Service\DestinationDataImportService;
|
|
|
|
use GuzzleHttp\ClientInterface as GuzzleClientInterface;
|
|
use Psr\Http\Client\ClientInterface;
|
|
use Psr\Http\Message\RequestFactoryInterface;
|
|
use Psr\Http\Message\ResponseInterface;
|
|
|
|
/**
|
|
* Provides API to fetch data from remote.
|
|
*
|
|
* Only partially migrated from service to here.
|
|
* Further calls need to be migrated.
|
|
*/
|
|
class DataFetcher
|
|
{
|
|
/**
|
|
* @var RequestFactoryInterface
|
|
*/
|
|
private $requestFactory;
|
|
|
|
/**
|
|
* @var GuzzleClientInterface
|
|
*/
|
|
private $client;
|
|
|
|
public function __construct(
|
|
RequestFactoryInterface $requestFactory,
|
|
GuzzleClientInterface $client
|
|
) {
|
|
$this->requestFactory = $requestFactory;
|
|
$this->client = $client;
|
|
}
|
|
|
|
public function fetchImage(string $url): ResponseInterface
|
|
{
|
|
// Keep after TYPO3 10 was dropped
|
|
if ($this->client instanceof ClientInterface) {
|
|
return $this->client->sendRequest(
|
|
$this->requestFactory->createRequest(
|
|
'GET',
|
|
$url
|
|
)
|
|
);
|
|
}
|
|
|
|
// Drop once TYPO3 10 support was dropped
|
|
return $this->client->request(
|
|
'GET',
|
|
$url,
|
|
[]
|
|
);
|
|
}
|
|
}
|