feat: multiple hotelcodes assignable to users

This commit is contained in:
Björn Fromme
2025-01-08 10:07:19 +01:00
parent 5a07d95837
commit c15188c43c
16 changed files with 256 additions and 67 deletions
@@ -9,7 +9,7 @@ class CrmAttributesResponse
private bool $manager = false;
private bool $houseManager = false;
private bool $teamer = false;
private ?string $hotelCode = null;
private array $hotelCodes = [];
public function getAttributeGroups(): ?array
{
@@ -70,14 +70,14 @@ class CrmAttributesResponse
return $this;
}
public function getHotelCode(): ?string
public function getHotelCodes(): array
{
return $this->hotelCode;
return $this->hotelCodes;
}
public function setHotelCode(?string $hotelCode): static
public function setHotelCodes(array $hotelCodes): static
{
$this->hotelCode = $hotelCode;
$this->hotelCodes = $hotelCodes;
return $this;
}
+4 -4
View File
@@ -142,7 +142,7 @@ class ResponseParser
{
$groups = [];
$isAdmin = $isManager = $isHouseManager = $isTeamer = false;
$hotelCode = null;
$hotelCodes = [];
foreach ($xml->selektionsmerkmale->selektionsgruppe as $item) {
$group = new CrmAttributeGroup();
@@ -164,7 +164,7 @@ class ResponseParser
if (1 === preg_match('/^Hausleitung ([A-Z0-9]+)$/', $attributeLabel, $matches) && true === $attribute->isSelected()) {
$isHouseManager = true;
$hotelCode = $matches[1];
$hotelCodes[] = $matches[1];
}
if ($this->config['bpn_crm_id_admin'] === $attribute->getId() && true === $attribute->isSelected()) {
$isAdmin = true;
@@ -183,7 +183,7 @@ class ResponseParser
// Apply additional role and hotel code for testing purposes when provided
if ($isAdmin && null !== $this->config['bpn_default_hotel_code']) {
$isHouseManager = true;
$hotelCode = $this->config['bpn_default_hotel_code'];
$hotelCodes[] = $this->config['bpn_default_hotel_code'];
}
$response = new CrmAttributesResponse();
@@ -193,7 +193,7 @@ class ResponseParser
->setManager($isManager)
->setTeamer($isTeamer)
->setHouseManager($isHouseManager)
->setHotelCode($hotelCode)
->setHotelCodes($hotelCodes)
;
return $response;
+4 -4
View File
@@ -55,7 +55,7 @@ class UserDataHandler
array $roles,
bool $isTeamer = false,
array $crmSelections = [],
?string $hotelCode = null
array $hotelCodes = []
): User {
$user = new User();
$user
@@ -64,7 +64,7 @@ class UserDataHandler
->setEmail($profileResponse->getCommunication()->getEmail())
->setBusProPersonId($profileResponse->getPersonId())
->setBusProAddressId($profileResponse->getAddressId())
->setHotelCode($hotelCode)
->setHotelCodes($hotelCodes)
->setRoles($roles)
;
@@ -95,12 +95,12 @@ class UserDataHandler
array $roles,
bool $isTeamer = false,
array $crmSelections = [],
?string $hotelCode = null
array $hotelCodes = []
): void {
$user
->setEmail($profileResponse->getCommunication()->getEmail())
->setRoles($roles)
->setHotelCode($hotelCode)
->setHotelCodes($hotelCodes)
;
if (true === $isTeamer) {