2019-09-07 02:57:59 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
namespace A2nt\SilverStripeMapboxField;
|
|
|
|
|
|
|
|
use SilverStripe\Core\Extension;
|
2022-06-16 00:27:59 +02:00
|
|
|
use SilverStripe\Core\Config\Config;
|
2019-09-07 02:57:59 +02:00
|
|
|
|
|
|
|
class SiteConfigExtension extends Extension
|
|
|
|
{
|
|
|
|
public function MapAPIKey()
|
|
|
|
{
|
|
|
|
return MapboxField::getAccessToken();
|
|
|
|
}
|
2022-06-16 00:25:09 +02:00
|
|
|
|
2022-06-16 00:26:25 +02:00
|
|
|
public function MapAPIKeyFrontend(): string
|
2022-06-16 00:25:09 +02:00
|
|
|
{
|
|
|
|
$type = $this->owner->config()->get('map_type');
|
|
|
|
|
|
|
|
switch ($type) {
|
|
|
|
case 'mapbox':
|
|
|
|
$key = MapboxField::getAccessToken();
|
|
|
|
break;
|
|
|
|
case 'google-maps':
|
|
|
|
$cfg = Config::inst()->get(GoogleMapField::class, 'default_options');
|
|
|
|
$key = $cfg['api_key'];
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$key = '';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $key;
|
|
|
|
}
|
2019-09-07 02:57:59 +02:00
|
|
|
|
|
|
|
public function MapStyle()
|
|
|
|
{
|
|
|
|
return MapboxField::config()->get('map_style');
|
|
|
|
}
|
|
|
|
}
|