Skip to content

Commit

Permalink
Move API key initialization outside the constructor (#150)
Browse files Browse the repository at this point in the history
Because the API key utilizes the store scope during retrieval, doing so in the constructor fails if Magento hasn't been installed yet.  This prevents installing TaxJar at the same time as Magento.
  • Loading branch information
ryanreeves-taxjar committed Aug 18, 2020
1 parent cda0795 commit a8cc96b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Model/Transaction/Backfill.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ public function __construct(
$this->filterGroupBuilder = $filterGroupBuilder;
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
$this->taxjarConfig = $taxjarConfig;
$this->apiKey = $this->taxjarConfig->getApiKey();
}

/**
Expand All @@ -146,6 +145,8 @@ public function start(
) {
// @codingStandardsIgnoreEnd

$this->apiKey = $this->taxjarConfig->getApiKey();

if (!$this->apiKey) {
throw new LocalizedException(__('Could not sync transactions with TaxJar. Please make sure you have an API key.'));
}
Expand Down
3 changes: 2 additions & 1 deletion Observer/ImportCategories.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ public function __construct(
$this->categoryFactory = $categoryFactory;
$this->categoryResourceModel = $categoryResourceModel;
$this->taxjarConfig = $taxjarConfig;
$this->apiKey = $this->taxjarConfig->getApiKey();
}

/**
Expand All @@ -110,6 +109,8 @@ public function __construct(
// @codingStandardsIgnoreStart
public function execute(Observer $observer)
{
$this->apiKey = $this->taxjarConfig->getApiKey();

// @codingStandardsIgnoreEnd
if ($this->apiKey) {
$this->client = $this->clientFactory->create();
Expand Down

0 comments on commit a8cc96b

Please sign in to comment.