You are here

class HmacWrapper in Acquia Content Hub 8

Wrapper for HMAC.

@package Drupal\acquia_contenthub\Middleware

Hierarchy

  • class \Drupal\acquia_contenthub\Middleware\HmacWrapper extends \Acquia\ContentHubClient\Middleware\MiddlewareHmacBase implements \Acquia\ContentHubClient\Middleware\MiddlewareHmacInterface

Expanded class hierarchy of HmacWrapper

1 string reference to 'HmacWrapper'
acquia_contenthub.services.yml in ./acquia_contenthub.services.yml
acquia_contenthub.services.yml
1 service uses HmacWrapper
acquia_contenthub.middleware_hmac in ./acquia_contenthub.services.yml
Drupal\acquia_contenthub\Middleware\HmacWrapper

File

src/Middleware/HmacWrapper.php, line 14

Namespace

Drupal\acquia_contenthub\Middleware
View source
class HmacWrapper extends MiddlewareHmacBase implements MiddlewareHmacInterface {

  /**
   * The Drupal Configuration.
   *
   * @var \Drupal\Core\Config\Config
   */
  protected $config;

  /**
   * HmacWrapper constructor.
   *
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   The config factory.
   */
  public function __construct(ConfigFactoryInterface $config_factory) {
    $configFactory = $config_factory;

    // Get the content hub config settings.
    $this->config = $configFactory
      ->get('acquia_contenthub.admin_settings');
    if (!$this->apiKey) {
      $this->apiKey = $this->config
        ->get('api_key');
    }
    if (!$this->secretKey) {
      $this->secretKey = $this->config
        ->get('secret_key');
    }
  }

  /**
   * Gets the middleware.
   *
   * @return mixed
   *   The middleware.
   */
  public function getMiddleware() {

    // When HMAC V2 is supported, grab the configured version below.
    // $version = $config->get('hmac_version');.
    $version = 'V1';
    $class = "\\Acquia\\ContentHubClient\\Middleware\\MiddlewareHmac" . $version;
    $middleware = new $class($this->apiKey, $this->secretKey, $version);
    return $middleware
      ->getMiddleware();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
HmacWrapper::$config protected property The Drupal Configuration.
HmacWrapper::getMiddleware public function Gets the middleware.
HmacWrapper::__construct public function HmacWrapper constructor.