You are here

public function PrivateFileKeyProvider::checkRequirements in Apigee Edge 8

Checks the requirements of the key provider.

Parameters

\Drupal\key\KeyInterface $key: The key entity.

Throws

\Drupal\apigee_edge\Exception\KeyProviderRequirementsException Exception thrown when the requirements of the key provider are not fulfilled.

Overrides KeyProviderRequirementsInterface::checkRequirements

1 call to PrivateFileKeyProvider::checkRequirements()
PrivateFileKeyProvider::setKeyValue in src/Plugin/KeyProvider/PrivateFileKeyProvider.php
Sets the value of a key.

File

src/Plugin/KeyProvider/PrivateFileKeyProvider.php, line 169

Class

PrivateFileKeyProvider
Stores Apigee Edge authentication credentials in a private file.

Namespace

Drupal\apigee_edge\Plugin\KeyProvider

Code

public function checkRequirements(KeyInterface $key) : void {

  // Validate private file path is set.
  $file_private_path = $this
    ->getFileSystem()
    ->realpath('private://');
  if (!(bool) $file_private_path) {
    throw new KeyProviderRequirementsException('Private filesystem has not been configured yet.', $this
      ->t("Private filesystem has not been configured yet. <a href=':file_docs_uri' target='_blank'>Learn more</a>", [
      ':file_docs_uri' => 'https://www.drupal.org/docs/8/modules/apigee-edge/configure-the-connection-to-apigee-edge#configure-private-file',
    ]));
  }

  // Validate private file path is writable.
  if (!is_writable($file_private_path)) {
    throw new KeyProviderRequirementsException('The private file path is not writable.', $this
      ->t('The private file path is not writable.'));
  }

  // Validate private file path is a directory.
  if (!is_dir($file_private_path)) {
    throw new KeyProviderRequirementsException('The private file path does not exist.', $this
      ->t('The private file path does not exist.'));
  }
}