You are here

public function OauthTokenFileStorage::checkRequirements in Apigee Edge 8

Checks requirements of the token storage.

If a requirement does not fulfilled it throws an exception.

Throws

\Drupal\apigee_edge\Exception\OauthTokenStorageException Exception with the unfulfilled requirement.

Overrides OauthTokenStorageInterface::checkRequirements

1 call to OauthTokenFileStorage::checkRequirements()
OauthTokenFileStorage::saveToken in src/OauthTokenFileStorage.php

File

src/OauthTokenFileStorage.php, line 192

Class

OauthTokenFileStorage
Stores OAuth token data in a file.

Namespace

Drupal\apigee_edge

Code

public function checkRequirements() : void {
  if ($this
    ->isTokenFileInPrivateFileSystem() && !$this
    ->isPrivateFileSystemConfigured()) {
    throw new OauthTokenStorageException('Unable to save token data to private filesystem because it has not been configured yet.');
  }

  // Gets the file directory so we can make sure it exists.
  $token_directory = $this->fileSystem
    ->dirname($this->tokenFilePath);
  if (!$this->fileSystem
    ->prepareDirectory($token_directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS)) {
    throw new OauthTokenStorageException("Unable to set up {$token_directory} directory for token file.");
  }
}