Source of file GoogleAPI.php
Size: 3,022 Bytes - Last Modified: 2021-12-23T10:36:51+00:00
/var/www/docs.ssmods.com/process/src/src/API/GoogleAPI.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 | <?php /** * This file is part of SilverWare. * * PHP version >=5.6.0 * * For full copyright and license information, please view the * LICENSE.md file that was distributed with this source code. * * @package SilverWare\Google\API * @author Colin Tucker <colin@praxis.net.au> * @copyright 2017 Praxis Interactive * @license https://opensource.org/licenses/BSD-3-Clause BSD-3-Clause * @link https://github.com/praxisnetau/silverware-google */ namespace SilverWare\Google\API; use SilverStripe\Core\Config\Configurable; use SilverStripe\Core\Injector\Injectable; use SilverStripe\SiteConfig\SiteConfig; /** * An object to encapsulate Google API data and methods. * * @package SilverWare\Google\API * @author Colin Tucker <colin@praxis.net.au> * @copyright 2017 Praxis Interactive * @license https://opensource.org/licenses/BSD-3-Clause BSD-3-Clause * @link https://github.com/praxisnetau/silverware-google */ class GoogleAPI { use Injectable; use Configurable; /** * Answers the API key from site or YAML configuration. * * @return string */ public function getAPIKey() { $key = SiteConfig::current_site_config()->GoogleAPIKey; if (!$key) { $key = self::config()->api_key; } return $key; } /** * Answers true if the receiver has an API key. * * @return boolean */ public function hasAPIKey() { return (boolean) $this->getAPIKey(); } /** * Answers the API language from site or YAML configuration. * * @return string */ public function getAPILanguage() { $lang = SiteConfig::current_site_config()->GoogleAPILanguage; if (!$lang) { $lang = self::config()->api_language; } return $lang; } /** * Answers the analytics tracking ID from site or YAML configuration. * * @return string */ public function getAnalyticsTrackingID() { $id = SiteConfig::current_site_config()->GoogleAnalyticsTrackingID; if (!$id) { $id = self::config()->analytics_tracking_id; } return $id; } /** * Answers the site verification code from site or YAML configuration. * * @return string */ public function getVerificationCode() { $code = SiteConfig::current_site_config()->GoogleVerificationCode; if (!$code) { $code = self::config()->verification_code; } return $code; } /** * Answers true if analytics is enabled for the site. * * @return boolean */ public function isAnalyticsEnabled() { $enabled = SiteConfig::current_site_config()->GoogleAnalyticsEnabled; if (!$enabled) { $enabled = self::config()->analytics_enabled; } return (boolean) $enabled; } } |