Skip to content

Commit

Permalink
MOL-1263: remove unused repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitalij Mik committed Nov 24, 2023
1 parent 9dccd1a commit 17428cc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
1 change: 0 additions & 1 deletion src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@
<argument type="service" id="Kiener\MolliePayments\Factory\MollieApiFactory"/>
<argument type="service" id="Kiener\MolliePayments\Service\SettingsService"/>
<argument type="service" id="Kiener\MolliePayments\Repository\Language\LanguageRepository"/>
<argument type="service" id="Kiener\MolliePayments\Repository\Locale\LocaleRepository"/>
<argument type="service" id="Kiener\MolliePayments\Service\MandateService"/>
<argument type="service" id="Kiener\MolliePayments\Gateway\Mollie\MollieGateway"/>
<tag name="kernel.event_subscriber"/>
Expand Down
35 changes: 15 additions & 20 deletions src/Subscriber/CheckoutConfirmPageSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Shopware\Core\Checkout\Payment\PaymentMethodEntity;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
use Shopware\Core\System\Language\LanguageEntity;
use Shopware\Storefront\Page\Account\Order\AccountEditOrderPageLoadedEvent;
use Shopware\Storefront\Page\Checkout\Confirm\CheckoutConfirmPageLoadedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
Expand Down Expand Up @@ -55,10 +56,6 @@ class CheckoutConfirmPageSubscriber implements EventSubscriberInterface
*/
private $repoLanguages;

/**
* @var LocaleRepositoryInterface
*/
private $repoLocales;

/**
* @var MandateServiceInterface
Expand Down Expand Up @@ -92,16 +89,14 @@ public static function getSubscribedEvents(): array
* @param MollieApiFactory $apiFactory
* @param SettingsService $settingsService
* @param LanguageRepositoryInterface $languageRepositoryInterface
* @param LocaleRepositoryInterface $localeRepositoryInterface
* @param MandateServiceInterface $mandateService
* @param MollieGatewayInterface $mollieGateway
*/
public function __construct(MollieApiFactory $apiFactory, SettingsService $settingsService, LanguageRepositoryInterface $languageRepositoryInterface, LocaleRepositoryInterface $localeRepositoryInterface, MandateServiceInterface $mandateService, MollieGatewayInterface $mollieGateway)
public function __construct(MollieApiFactory $apiFactory, SettingsService $settingsService, LanguageRepositoryInterface $languageRepositoryInterface, MandateServiceInterface $mandateService, MollieGatewayInterface $mollieGateway)
{
$this->apiFactory = $apiFactory;
$this->settingsService = $settingsService;
$this->repoLanguages = $languageRepositoryInterface;
$this->repoLocales = $localeRepositoryInterface;
$this->mandateService = $mandateService;
$this->mollieGateway = $mollieGateway;
}
Expand All @@ -113,18 +108,20 @@ public function __construct(MollieApiFactory $apiFactory, SettingsService $setti
*/
public function addDataToPage($args): void
{
# load our settings for the
# current request
$this->settings = $this->settingsService->getSettings($args->getSalesChannelContext()->getSalesChannel()->getId());

$scId = $args->getSalesChannelContext()->getSalesChannel()->getId();

$currentSelectedPaymentMethod = $args->getSalesChannelContext()->getPaymentMethod();
$mollieAttributes = new PaymentMethodAttributes($currentSelectedPaymentMethod);

# load additional data only for mollie payment methods
if (! $mollieAttributes->isMolliePayment()) {
return;
}

# load our settings for the
# current request
$this->settings = $this->settingsService->getSettings($scId);

# now use our factory to get the correct
# client with the correct sales channel settings
$this->apiClient = $this->apiFactory->getClient($scId);
Expand Down Expand Up @@ -178,7 +175,6 @@ private function addMollieLocaleVariableToPage($args): void
*/
$locale = '';

$context = $args->getContext();
$salesChannelContext = $args->getSalesChannelContext();


Expand All @@ -187,17 +183,16 @@ private function addMollieLocaleVariableToPage($args): void
$languageId = $salesChannel->getLanguageId();
if ($languageId !== null) {
$languageCriteria = new Criteria();
$languageCriteria->addAssociation('locale');
$languageCriteria->addFilter(new EqualsFilter('id', $languageId));

$languages = $this->repoLanguages->search($languageCriteria, $args->getContext());

$localeId = $languages->first()->getLocaleId();

$localeCriteria = new Criteria();
$localeCriteria->addFilter(new EqualsFilter('id', $localeId));
$languagesResult = $this->repoLanguages->search($languageCriteria, $args->getContext());
/** @var LanguageEntity $language */
$language = $languagesResult->first();

$locales = $this->repoLocales->search($localeCriteria, $args->getContext());
$locale = $locales->first()->getCode();
if ($language !== null) {
$locale = $language->getLocale()->getCode();

Check failure on line 194 in src/Subscriber/CheckoutConfirmPageSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan

Cannot call method getCode() on Shopware\Core\System\Locale\LocaleEntity|null.
}
}
}

Expand Down

0 comments on commit 17428cc

Please sign in to comment.