2022-01-26 14:16:12 +01:00
|
|
|
<?php
|
|
|
|
|
2023-11-27 10:04:42 +01:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2023-11-09 10:27:43 +01:00
|
|
|
namespace WerkraumMedia\Events\Service\DestinationDataImportService;
|
2022-01-26 14:16:12 +01:00
|
|
|
|
|
|
|
use TYPO3\CMS\Core\Http\Uri;
|
2023-11-27 10:04:42 +01:00
|
|
|
use TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager;
|
2023-11-09 10:27:43 +01:00
|
|
|
use WerkraumMedia\Events\Domain\Model\Import;
|
2022-01-26 14:16:12 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Factory to create URLs used during import of Destination Data.
|
|
|
|
*/
|
2023-11-27 10:04:42 +01:00
|
|
|
final class UrlFactory
|
2022-01-26 14:16:12 +01:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
private $settings = [];
|
|
|
|
|
|
|
|
public function __construct(
|
2023-11-27 10:04:42 +01:00
|
|
|
BackendConfigurationManager $configurationManager
|
2022-01-26 14:16:12 +01:00
|
|
|
) {
|
|
|
|
$this->settings = $configurationManager->getConfiguration(
|
|
|
|
'Events',
|
|
|
|
'Pi1'
|
2023-11-27 10:04:42 +01:00
|
|
|
)['settings']['destinationData'] ?? [];
|
2022-01-26 14:16:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* URL used to fetch initial set of data.
|
|
|
|
*/
|
|
|
|
public function createSearchResultUrl(
|
|
|
|
Import $import
|
|
|
|
): string {
|
|
|
|
$parameter = [
|
|
|
|
'experience' => $import->getRestExperience(),
|
|
|
|
'licensekey' => $this->settings['license'] ?? '',
|
|
|
|
'type' => $this->settings['restType'] ?? '',
|
|
|
|
'mode' => $this->settings['restMode'] ?? '',
|
|
|
|
'limit' => $this->settings['restLimit'] ?? '',
|
|
|
|
'template' => $this->settings['restTemplate'] ?? '',
|
2023-06-07 08:56:42 +02:00
|
|
|
'q' => $import->getSearchQuery(),
|
2022-01-26 14:16:12 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
$parameter = array_filter($parameter);
|
|
|
|
|
|
|
|
$url = new Uri($this->settings['restUrl']);
|
|
|
|
$url = $url->withQuery(http_build_query($parameter));
|
2023-06-07 08:56:42 +02:00
|
|
|
return (string)$url;
|
2022-01-26 14:16:12 +01:00
|
|
|
}
|
|
|
|
}
|