Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NTR: add domainID to compatiblity service #774

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/Compatibility/Gateway/CompatibilityGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,25 @@ public function getSalesChannelID(SalesChannelContext $context): string
return $context->getSalesChannel()->getId();
}

/**
* @param SalesChannelContext $context
* @return string
*/
public function getDomainId(SalesChannelContext $context): ?string
{
return $context->getDomainId();
}

/**
* @param string $salesChannelID
* @param ?string $domainID
* @param string $token
* @return SalesChannelContext
*/
public function getSalesChannelContext(string $salesChannelID, string $token): SalesChannelContext
public function getSalesChannelContext(string $salesChannelID, ?string $domainID, string $token): SalesChannelContext
{
if ($this->versionGTE('6.4')) {
$params = new SalesChannelContextServiceParameters($salesChannelID, $token);
$params = new SalesChannelContextServiceParameters($salesChannelID, $token, null, null, $domainID, null, null);
return $this->contextService->get($params);
}

Expand Down Expand Up @@ -79,12 +89,12 @@ public function getLineItemPromotionType(): string
public function getChargebackOrderTransactionState(): string
{
// In progress state did not exist before 6.2, so set to open instead.
if (!$this->versionGTE('6.2')) {
if (! $this->versionGTE('6.2')) {
return OrderTransactionStates::STATE_OPEN;
}

// Chargeback state did not exist before 6.2.3, so set to in progress instead.
if (!$this->versionGTE('6.2.3')) {
if (! $this->versionGTE('6.2.3')) {
return OrderTransactionStates::STATE_IN_PROGRESS;
}

Expand Down
9 changes: 8 additions & 1 deletion src/Compatibility/Gateway/CompatibilityGatewayInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,17 @@ public function getSalesChannelID(SalesChannelContext $context): string;

/**
* @param string $salesChannelID
* @param ?string $domainID
* @param string $token
* @return SalesChannelContext
*/
public function getSalesChannelContext(string $salesChannelID, string $token): SalesChannelContext;
public function getSalesChannelContext(string $salesChannelID, ?string $domainID, string $token): SalesChannelContext;

/**
* @param SalesChannelContext $context
* @return ?string
*/
public function getDomainId(SalesChannelContext $context): ?string;

/**
* @return string
Expand Down
9 changes: 6 additions & 3 deletions src/Service/CartService.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ public function updateCountry(SalesChannelContext $context, string $countryID):
$this->contextSwitcher->update($dataBag, $context);

$scID = $this->compatibilityGateway->getSalesChannelID($context);
$dID = $this->compatibilityGateway->getDomainId($context);

return $this->compatibilityGateway->getSalesChannelContext($scID, $context->getToken());
return $this->compatibilityGateway->getSalesChannelContext($scID, $dID, $context->getToken());
}

/**
Expand All @@ -134,8 +135,9 @@ public function updateShippingMethod(SalesChannelContext $context, string $shipp
$this->contextSwitcher->update($dataBag, $context);

$scID = $this->compatibilityGateway->getSalesChannelID($context);
$dID = $this->compatibilityGateway->getDomainId($context);

return $this->compatibilityGateway->getSalesChannelContext($scID, $context->getToken());
return $this->compatibilityGateway->getSalesChannelContext($scID, $dID, $context->getToken());
}


Expand All @@ -155,7 +157,8 @@ public function updatePaymentMethod(SalesChannelContext $context, string $paymen
$this->contextSwitcher->update($dataBag, $context);

$scID = $this->compatibilityGateway->getSalesChannelID($context);
$dID = $this->compatibilityGateway->getDomainId($context);

return $this->compatibilityGateway->getSalesChannelContext($scID, $context->getToken());
return $this->compatibilityGateway->getSalesChannelContext($scID, $dID, $context->getToken());
}
}
9 changes: 8 additions & 1 deletion tests/PHPUnit/Fakes/FakeCompatibilityGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,19 @@ public function getSalesChannelID(SalesChannelContext $context): string
/**
* @param string $salesChannelID
* @param string $token
* @param ?string $domainID
* @return SalesChannelContext
*/
public function getSalesChannelContext(string $salesChannelID, string $token): SalesChannelContext
public function getSalesChannelContext(string $salesChannelID, ?string $domainID, string $token): SalesChannelContext
{
}

public function getDomainId(SalesChannelContext $context): ?string
{
return '';
}


/**
* @return string
*/
Expand Down
Loading