class FirebaseConfigManager in TMGMT Translator Smartling 8.4
Same name and namespace in other branches
- 8.3 src/Smartling/ConfigManager/FirebaseConfigManager.php \Drupal\tmgmt_smartling\Smartling\ConfigManager\FirebaseConfigManager
Class FirebaseConfigManager.
Hierarchy
- class \Drupal\tmgmt_smartling\Smartling\ConfigManager\SmartlingConfigManager
- class \Drupal\tmgmt_smartling\Smartling\ConfigManager\FirebaseConfigManager
Expanded class hierarchy of FirebaseConfigManager
1 string reference to 'FirebaseConfigManager'
1 service uses FirebaseConfigManager
File
- src/
Smartling/ ConfigManager/ FirebaseConfigManager.php, line 16 - FirebaseConfigManager.
Namespace
Drupal\tmgmt_smartling\Smartling\ConfigManagerView source
class FirebaseConfigManager extends SmartlingConfigManager {
/**
* @var \Drupal\tmgmt_smartling\Smartling\SmartlingApiWrapper
*/
protected $apiWrapper;
/**
* @var \Drupal\Core\Cache\CacheBackendInterface $defaultCache
*/
protected $defaultCache;
/**
* @param \Drupal\tmgmt_smartling\Smartling\SmartlingApiWrapper $apiWrapper
*/
public function setSmartlingApiWrapper(SmartlingApiWrapper $apiWrapper) {
$this->apiWrapper = $apiWrapper;
}
/**
* @param \Drupal\Core\Cache\CacheBackendInterface $defaultCache
*/
public function setDefaultCache(CacheBackendInterface $defaultCache) {
$this->defaultCache = $defaultCache;
}
/**
* Returns array of available smartling providers with enabled notifications.
*
* @return array
*/
public function getAvailableConfigs() {
$firebaseConfigs = [];
$configs = parent::getAvailableConfigs();
foreach ($configs as $config) {
$provider_settings = $config
->get('settings');
if (empty($provider_settings['enable_notifications'])) {
continue;
}
$cachedData = $this->defaultCache
->get("tmgmt_smartling.firebase_config.{$provider_settings["project_id"]}");
if (empty($cachedData)) {
try {
$this->apiWrapper
->setSettings($provider_settings);
$project_details = $this->apiWrapper
->getApi("project")
->getProjectDetails();
$data = $this->apiWrapper
->getApi("progress")
->getToken($project_details["accountUid"]);
$data["accountUid"] = $project_details["accountUid"];
$data["projectId"] = $provider_settings["project_id"];
$firebaseConfigs[] = $data;
$this->defaultCache
->set("tmgmt_smartling.firebase_config.{$provider_settings["project_id"]}", $data, time() + 3600, [
"tmgmt_smartling:firebase_config:{$provider_settings["project_id"]}",
]);
} catch (\Exception $e) {
// Empty settings, can't fetch project details.
}
}
else {
$firebaseConfigs[] = $cachedData->data;
}
}
return $firebaseConfigs;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FirebaseConfigManager:: |
protected | property | ||
FirebaseConfigManager:: |
protected | property | ||
FirebaseConfigManager:: |
public | function |
Returns array of available smartling providers with enabled notifications. Overrides SmartlingConfigManager:: |
|
FirebaseConfigManager:: |
public | function | ||
FirebaseConfigManager:: |
public | function | ||
SmartlingConfigManager:: |
protected | property | ||
SmartlingConfigManager:: |
public | function | Returns smartling provider config by project id. | |
SmartlingConfigManager:: |
public | function | SmartlingConfigManager constructor. |