mirror of
https://github.com/werkraum-media/events.git
synced 2024-12-28 01:06:10 +01:00
Daniel Siepmann
a9f3f108e3
The vendor was renamed from `wrm` to `werkraummedia`. And the namespace vendor was renamed from `Wrm` to `WerkraumMedia`. That way all references to PHP classes as well as the package name itself need to be adjusted.
50 lines
1.2 KiB
PHP
50 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace WerkraumMedia\Events\Service\DestinationDataImportService;
|
|
|
|
use WerkraumMedia\Events\Domain\Model\Location;
|
|
use WerkraumMedia\Events\Domain\Repository\LocationRepository;
|
|
|
|
class LocationAssignment
|
|
{
|
|
/**
|
|
* @var LocationRepository
|
|
*/
|
|
private $repository;
|
|
|
|
public function __construct(
|
|
LocationRepository $repository
|
|
) {
|
|
$this->repository = $repository;
|
|
}
|
|
|
|
public function getLocation(array $event): ?Location
|
|
{
|
|
$newLocation = new Location(
|
|
$event['name'] ?? '',
|
|
$event['street'] ?? '',
|
|
$event['zip'] ?? '',
|
|
$event['city'] ?? '',
|
|
$event['district'] ?? '',
|
|
$event['country'] ?? '',
|
|
$event['phone'] ?? '',
|
|
$event['geo']['main']['latitude'] ?? '',
|
|
$event['geo']['main']['longitude'] ?? '',
|
|
-1
|
|
);
|
|
|
|
if ($newLocation->isValid() === false) {
|
|
return null;
|
|
}
|
|
|
|
$existingLocation = $this->repository->findOneByGlobalId($newLocation->getGlobalId());
|
|
|
|
if ($existingLocation === null) {
|
|
return $newLocation;
|
|
}
|
|
|
|
$existingLocation->updateFromLocation($newLocation);
|
|
|
|
return $existingLocation;
|
|
}
|
|
}
|