public function ScreenLoaderManager::updateRemoteScreens in Janrain Registration 8
Update Janrain screens cache if screens folder is the remote one.
File
- src/
ScreenLoaderManager.php, line 124
Class
- ScreenLoaderManager
- Allow to load and manage Janrain screens (local and remote).
Namespace
Drupal\janrain_captureCode
public function updateRemoteScreens() {
$cache_directory = static::CACHE_DIR;
$success = $this->fileSystem
->prepareDirectory($cache_directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
if (!$success) {
$this->logger
->error('Failed to create screen cache directory: @directory', [
'@directory' => $cache_directory,
]);
return;
}
foreach (static::ALLOWED_SCREENS as $name) {
foreach (static::ALLOWED_TYPES as $type) {
$screen_source = static::buildPath($this->path, $name, $type);
$screen_destination = static::buildPath($cache_directory, $name, $type);
$response = $this->httpClient
->get($screen_source);
if ($response
->getStatusCode() !== 200) {
$this->logger
->error('Error during retrieving Janrain remote screen (@url)', [
'@url' => $screen_source,
]);
continue;
}
$success_file_save = $this->fileSystem
->saveData($response
->getBody(), $screen_destination, FileSystemInterface::EXISTS_REPLACE);
if ($success_file_save === FALSE) {
$this->logger
->error('Failed to write @screenDest', [
'@screenDest' => $screen_destination,
]);
}
}
}
}