Skip to content

Commit e9acb4a

Browse files
authored
Update for deprecated FILE_REPLACE function (#1138)
1 parent d303cbc commit e9acb4a

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/OauthTokenFileStorage.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Drupal\Component\Serialization\Json;
2323
use Drupal\Core\Config\ConfigFactoryInterface;
2424
use Drupal\Core\File\Exception\FileException;
25+
use Drupal\Core\File\FileExists;
2526
use Drupal\Core\File\FileSystemInterface;
2627
use Drupal\Core\Logger\LoggerChannelInterface;
2728
use Drupal\apigee_edge\Exception\OauthTokenStorageException;
@@ -172,7 +173,7 @@ public function saveToken(array $data): void {
172173
try {
173174
$this->checkRequirements();
174175
// Write the obfuscated token data to a private file.
175-
$this->fileSystem->saveData(base64_encode(Json::encode($data)), $this->tokenFilePath, FileSystemInterface::EXISTS_REPLACE);
176+
$this->fileSystem->saveData(base64_encode(Json::encode($data)), $this->tokenFilePath, FileExists::Replace);
176177
}
177178
catch (FileException $e) {
178179
$this->logger->critical('Error saving OAuth token file.');

src/Plugin/KeyProvider/PrivateFileKeyProvider.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
namespace Drupal\apigee_edge\Plugin\KeyProvider;
2121

2222
use Drupal\Core\File\Exception\FileException;
23+
use Drupal\Core\File\FileExists;
2324
use Drupal\Core\File\FileSystemInterface;
2425
use Drupal\Core\Form\FormStateInterface;
2526
use Drupal\Core\Utility\Error;
@@ -145,7 +146,7 @@ public function setKeyValue(KeyInterface $key, $key_value) {
145146
try {
146147
// Save the token data.
147148
return $this->getFileSystem()
148-
->saveData($key_value, $file_uri, FileSystemInterface::EXISTS_REPLACE);
149+
->saveData($key_value, $file_uri, FileExists::Replace);
149150
}
150151
catch (FileException $e) {
151152
return FALSE;

tests/src/Kernel/OauthTokenFileStorageTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
use Drupal\Component\Serialization\Json;
2323
use Drupal\Core\DependencyInjection\ContainerBuilder;
24+
use Drupal\Core\File\FileExists;
2425
use Drupal\Core\File\FileSystemInterface;
2526
use Drupal\KernelTests\KernelTestBase;
2627
use Drupal\apigee_edge\Exception\OauthTokenStorageException;
@@ -183,7 +184,7 @@ public function testStaticCaching() {
183184
$stored_token['access_token'] = mb_strtolower($this->randomMachineName(32));
184185
\Drupal::service('file_system')->saveData(
185186
base64_encode(Json::encode($stored_token)),
186-
$this->tokenFileUri(), FileSystemInterface::EXISTS_REPLACE);
187+
$this->tokenFileUri(), FileExists::Replace);
187188

188189
// Make sure the cached version is still returned.
189190
$this->assertSame($access_token, $storage->getAccessToken());

0 commit comments

Comments
 (0)