Skip to content

Commit

Permalink
Hotfix, admin crash if api key is wrong or invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
HelgeSverre committed Dec 12, 2019
1 parent 111f89e commit c2a7d8f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 12 additions & 8 deletions src/HubspotConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,21 @@ protected function getFrequencyList()

protected function getContactInformationPropertiesList()
{


if ($this->hubspot->hasApiKey() === false) {
return [];
}

return array_map(function ($item) {
return [
"label" => $item->label,
"value" => $item->name,
];
}, $this->hubspot->getHubspotDefinedContactInformationProperties());
try {

return array_map(function ($item) {
return [
"label" => $item->label,
"value" => $item->name,
];
}, $this->hubspot->getHubspotDefinedContactInformationProperties());
} catch (\Exception $e) {
// Prevent admin area from crashing if the api key is wrong
return [];
}
}
}
2 changes: 1 addition & 1 deletion src/services/Hubspot.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected function setupClients()

public function hasApiKey()
{
return empty($this->apiKey) === false;
return trim($this->apiKey) != "";
}


Expand Down

0 comments on commit c2a7d8f

Please sign in to comment.