Skip to content

Commit

Permalink
NTR: fix 6.4.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitalij Mik committed Mar 22, 2024
1 parent ec7de09 commit 8b76699
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<argument type="service" id="Kiener\MolliePayments\Service\SettingsService"/>
<argument>%kernel.shopware_version%</argument>
<argument type="service" id="Kiener\MolliePayments\Service\ConfigService"/>
<argument type="service" id="Shopware\Core\Checkout\Customer\SalesChannel\RegisterRoute"/>
<argument type="service" id="service_container"/>
</service>

<service id="Kiener\MolliePayments\Service\MandateService" class="Kiener\MolliePayments\Service\MandateService">
Expand Down
16 changes: 10 additions & 6 deletions src/Service/CustomerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
use Kiener\MolliePayments\Repository\Salutation\SalutationRepositoryInterface;
use Kiener\MolliePayments\Service\MollieApi\Customer;
use Kiener\MolliePayments\Struct\CustomerStruct;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
use Shopware\Core\Checkout\Customer\Aggregate\CustomerAddress\CustomerAddressEntity;
use Shopware\Core\Checkout\Customer\CustomerEntity;
use Shopware\Core\Checkout\Customer\Event\CustomerBeforeLoginEvent;
use Shopware\Core\Checkout\Customer\Event\CustomerLoginEvent;
use Shopware\Core\Checkout\Customer\SalesChannel\AbstractRegisterRoute;
use Shopware\Core\Checkout\Customer\SalesChannel\RegisterRoute;
use Shopware\Core\Checkout\Order\Aggregate\OrderAddress\OrderAddressEntity;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityWrittenContainerEvent;
Expand Down Expand Up @@ -76,9 +77,9 @@ class CustomerService implements CustomerServiceInterface


/**
* @var AbstractRegisterRoute
* @var ContainerInterface
*/
private $abstractRegisterRoute;
private $container;


/**
Expand All @@ -104,7 +105,7 @@ public function __construct(
SettingsService $settingsService,
string $shopwareVersion,
ConfigService $configService,
AbstractRegisterRoute $abstractRegisterRoute
ContainerInterface $container //we have to inject the container, because in SW 6.4.20.2 we have circular injection for the register route
) {
$this->countryRepository = $countryRepository;
$this->customerRepository = $customerRepository;
Expand All @@ -116,7 +117,7 @@ public function __construct(
$this->settingsService = $settingsService;
$this->shopwareVersion = $shopwareVersion;
$this->configService = $configService;
$this->abstractRegisterRoute = $abstractRegisterRoute;
$this->container = $container;
}

/**
Expand Down Expand Up @@ -465,8 +466,10 @@ public function getAddressArray($address, CustomerEntity $customer): array
public function createApplePayDirectCustomer(string $firstname, string $lastname, string $email, string $phone, string $street, string $zipCode, string $city, string $countryISO2, SalesChannelContext $context): ?CustomerEntity
{
$countryId = $this->getCountryId($countryISO2, $context->getContext());
$salutationId = $this->getSalutationId($context->getContext());

$data = new RequestDataBag();
$data->set('salutationId', $salutationId);
$data->set('guest', true);
$data->set('firstName', $firstname);
$data->set('lastName', $lastname);
Expand All @@ -482,7 +485,8 @@ public function createApplePayDirectCustomer(string $firstname, string $lastname
$data->set('billingAddress', $billingAddress);

try {
$response = $this->abstractRegisterRoute->register($data, $context, false);
$abstractRegisterRoute = $this->container->get(RegisterRoute::class);
$response = $abstractRegisterRoute->register($data, $context, false);
return $response->getCustomer();
} catch (ConstraintViolationException $e) {
$errors = [];
Expand Down
4 changes: 3 additions & 1 deletion tests/PHPUnit/Service/CustomerServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
use Kiener\MolliePayments\Service\MollieApi\Mandate;
use Kiener\MolliePayments\Service\SettingsService;
use Kiener\MolliePayments\Struct\CustomerStruct;
use MolliePayments\Tests\Fakes\FakeContainer;
use MolliePayments\Tests\Fakes\FakeEntityRepository;
use MolliePayments\Tests\Fakes\Repositories\FakeCustomerRepository;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;
use Psr\Log\NullLogger;
use Shopware\Core\Checkout\Customer\CustomerDefinition;
use Shopware\Core\Checkout\Customer\CustomerEntity;
Expand Down Expand Up @@ -53,7 +55,7 @@ public function setUp(): void
$this->settingsService,
'does.not.matter.here',
$this->createMock(ConfigService::class),
$this->createMock(AbstractRegisterRoute::class),
new FakeContainer(),
);
}

Expand Down

0 comments on commit 8b76699

Please sign in to comment.