silverstripe-mapboxfield/src/SiteConfigExtension.php

40 lines
857 B
PHP
Raw Normal View History

2019-09-07 02:57:59 +02:00
<?php
namespace A2nt\SilverStripeMapboxField;
use SilverStripe\Core\Extension;
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');
}
}