You are here

final public function KeyProviderRequirementsBase::getKeyValue in Apigee Edge 8

Returns the value of a key.

Parameters

\Drupal\key\KeyInterface $key: The key whose value will be retrieved.

Return value

string The key value.

Overrides KeyProviderInterface::getKeyValue

File

src/Plugin/KeyProvider/KeyProviderRequirementsBase.php, line 88

Class

KeyProviderRequirementsBase
Base class for key providers with pre-requirements.

Namespace

Drupal\apigee_edge\Plugin\KeyProvider

Code

public final function getKeyValue(KeyInterface $key) {

  // Throwing an exception would be better than returning NULL but the key
  // module's design does not allow this.
  // Related issue: https://www.drupal.org/project/key/issues/3038212
  try {
    $this
      ->checkRequirements($key);
  } catch (KeyProviderRequirementsException $exception) {
    $context = [
      '@message' => (string) $exception,
    ];
    $context += Error::decodeException($exception);
    $this
      ->getLogger()
      ->error('Could not retrieve Apigee Edge authentication key value from the environment variables: @message %function (line %line of %file). <pre>@backtrace_string</pre>', $context);
    return NULL;
  }
  return $this
    ->realGetKeyValue($key);
}