From df0ee2159ad954cf9bdbea1d3b4d0a5ccc42a94f Mon Sep 17 00:00:00 2001 From: indykoning <15870933+indykoning@users.noreply.github.com> Date: Wed, 31 Jul 2024 16:27:58 +0200 Subject: [PATCH] Remove the akeneo auth from the construct --- Job/ImportMetricUnits.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Job/ImportMetricUnits.php b/Job/ImportMetricUnits.php index 7c85951..36c675a 100644 --- a/Job/ImportMetricUnits.php +++ b/Job/ImportMetricUnits.php @@ -18,8 +18,8 @@ class ImportMetricUnits protected const ENABLED_CONFIG_KEY = 'enablemetricunits'; protected const CHANNEL_CONFIG_KEY = 'metric_conversion_channel'; + protected Authenticator $authenticator; protected AttributeRepositoryInterface $attributeRepository; - protected ?AkeneoPimClientInterface $akeneoClient = null; protected ScopeConfigInterface $config; public function __construct( @@ -27,17 +27,14 @@ public function __construct( AttributeRepositoryInterface $attributeRepository, ScopeConfigInterface $config ) { + $this->authenticator = $authenticator; $this->attributeRepository = $attributeRepository; $this->config = $config; - - if (($client = $authenticator->getAkeneoApiClient())) { - $this->akeneoClient = $client; - } } public function execute(OutputInterface $output = null): void { - if (! $this->akeneoClient) { + if (! $this->authenticator->getAkeneoApiClient()) { if ($output) { $output->writeln('Akeneo client not configured!'); } @@ -90,13 +87,13 @@ protected function getMetricAttributes(): ResourceCursor { $search = (new SearchBuilder())->addFilter('type', 'IN', ['pim_catalog_metric']); - return $this->akeneoClient->getAttributeApi()->all(100, ['search' => $search->getFilters()]); + return $this->authenticator->getAkeneoApiClient()->getAttributeApi()->all(100, ['search' => $search->getFilters()]); } protected function getChannelConversions(): array { $channel = $this->config->getValue(static::CONFIG_PREFIX . static::CHANNEL_CONFIG_KEY); - return $this->akeneoClient->getChannelApi()->get($channel)['conversion_units'] ?? []; + return $this->authenticator->getAkeneoApiClient()->getChannelApi()->get($channel)['conversion_units'] ?? []; } }