Skip to content

Commit

Permalink
Remove the akeneo auth from the construct
Browse files Browse the repository at this point in the history
  • Loading branch information
indykoning authored Jul 31, 2024
1 parent b7c821a commit df0ee21
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions Job/ImportMetricUnits.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,23 @@ 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(
Authenticator $authenticator,
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('<error>Akeneo client not configured!</error>');
}
Expand Down Expand Up @@ -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'] ?? [];
}
}

0 comments on commit df0ee21

Please sign in to comment.