Skip to content

Commit

Permalink
UPDATE allow for setting api keys via env
Browse files Browse the repository at this point in the history
  • Loading branch information
muskie9 committed Aug 2, 2022
1 parent 486292a commit cf01107
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/AddressDataExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use SilverStripe\Control\Director;
use Dynamic\StateDropdownField\Fields\StateDropdownField;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Environment;
use SilverStripe\Core\Manifest\ModuleResourceLoader;
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\CompositeField;
Expand Down Expand Up @@ -133,6 +134,9 @@ public function AddressMap($width = 320, $height = 240, $scale = 1)
}

$icon = Director::absoluteURL(static::getIconImage(false));
$key = Environment::getEnv('DYNAMIC_MAP_API_KEY') ?
Environment::getEnv('DYNAMIC_MAP_API_KEY')
: Config::inst()->get(GoogleGeocoder::class, 'map_api_key');

$data = $this->owner->customise([
'Width' => $width,
Expand All @@ -141,7 +145,7 @@ public function AddressMap($width = 320, $height = 240, $scale = 1)
'Address' => rawurlencode($this->getFullAddress()),
'Style' => $style,
'Icon' => $icon,
'Key' => Config::inst()->get(GoogleGeocoder::class, 'map_api_key'),
'Key' => $key,
]);

return $data->renderWith('Dynamic/Geocoder/AddressMap');
Expand Down

0 comments on commit cf01107

Please sign in to comment.