feat: parse travel guide per date
This commit is contained in:
@@ -2,8 +2,13 @@
|
||||
|
||||
namespace App\BusProNet\Model;
|
||||
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
|
||||
class Guide
|
||||
{
|
||||
#[Groups(['api:single'])]
|
||||
public ?string $name = null;
|
||||
|
||||
#[Groups(['api:single'])]
|
||||
public ?string $phone = null;
|
||||
}
|
||||
|
||||
@@ -73,6 +73,9 @@ class Travel
|
||||
#[Groups(['api:single'])]
|
||||
public bool $participantCountMutable = true;
|
||||
|
||||
#[Groups(['api:single'])]
|
||||
public ?Guide $guide = null;
|
||||
|
||||
public function getAdditionalServicesByGroup(mixed $group, bool $availableOnly = true): array
|
||||
{
|
||||
$group = (array) $group;
|
||||
|
||||
@@ -132,7 +132,7 @@ class TravelLoader extends AbstractLoader
|
||||
|
||||
$travel = new Travel();
|
||||
$travel->id = (int) $node->attr('idbuspro');
|
||||
$travel->hotelId = $hotelId;
|
||||
$travel->hotelId = (int) $hotelNode->attr('idbuspro');
|
||||
$travel->label = $this->getStringOrNullValue($node->filterXPath('//text'));
|
||||
$travel->dateFrom = $this->stringToDate($node->attr('termin'));
|
||||
$travel->dateTo = $this->stringToDate($node->attr('bis'));
|
||||
@@ -147,6 +147,7 @@ class TravelLoader extends AbstractLoader
|
||||
$travel->rooms = $this->getRooms($hotelNode);
|
||||
$travel->pickupsTo = $this->getPickups($node->filterXPath('//zustiege/zustieg'));
|
||||
$travel->pickupsFro = $this->getPickups($node->filterXPath('//zustiege_rueck/zustieg_rueck'));
|
||||
$travel->guide = $this->getGuide($node);
|
||||
|
||||
return $travel;
|
||||
}
|
||||
@@ -205,17 +206,22 @@ class TravelLoader extends AbstractLoader
|
||||
return $additionalServices;
|
||||
}
|
||||
|
||||
public function getGuideForTransportationService(\SimpleXMLElement $xmlTransportationService): ?Guide
|
||||
public function getGuide(Crawler $travelNode): ?Guide
|
||||
{
|
||||
if (null === $xmlTransportationService->reiseleiter) {
|
||||
return null;
|
||||
$guideNodes = $travelNode
|
||||
->filterXPath('//lei_befoerderung/leistung[@unterart="BUS"]/zustiegsplanung/reiseleiter');
|
||||
|
||||
if (0 < $guideNodes->count()) {
|
||||
$guideNode = $guideNodes->first();
|
||||
|
||||
$guide = new Guide();
|
||||
$guide->name = $this->getStringOrNullValue($guideNode->filterXPath('//name'));
|
||||
$guide->phone = $this->getStringOrNullValue($guideNode->filterXPath('//telefon'));
|
||||
|
||||
return $guide;
|
||||
}
|
||||
|
||||
$guide = new Guide();
|
||||
$guide->name = $xmlTransportationService->reiseleiter->name;
|
||||
$guide->phone = $xmlTransportationService->reiseleiter->telefon;
|
||||
|
||||
return $guide;
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getTransportationServices(Crawler $node): array
|
||||
|
||||
Reference in New Issue
Block a user