public function CacheTagsHash::getSiteId in Fastly 8.3
Get site id.
Return value
array|false|mixed|string
1 call to CacheTagsHash::getSiteId()
- CacheTagsHash::cacheTagsToHashes in src/
CacheTagsHash.php - Maps cache tags to hashes.
File
- src/
CacheTagsHash.php, line 83
Class
- CacheTagsHash
- Class CacheTagsHash.
Namespace
Drupal\fastlyCode
public function getSiteId() {
$siteId = getenv('FASTLY_SITE_ID') ?: $this->config
->get('site_id');
if (!$siteId) {
// Create random 8 character string and save it to config.
$random = new Random();
$siteId = $random
->name();
$siteId = mb_strtolower($siteId);
if ($this->configFactory
->get('fastly.settings')) {
$config = $this->configFactory
->getEditable('fastly.settings');
$config
->set('site_id', $siteId)
->save(TRUE);
}
}
return $siteId;
}