HmacWrapper.php in Acquia Content Hub 8
File
src/Middleware/HmacWrapper.php
View source
<?php
namespace Drupal\acquia_contenthub\Middleware;
use Acquia\ContentHubClient\Middleware\MiddlewareHmacBase;
use Acquia\ContentHubClient\Middleware\MiddlewareHmacInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
class HmacWrapper extends MiddlewareHmacBase implements MiddlewareHmacInterface {
protected $config;
public function __construct(ConfigFactoryInterface $config_factory) {
$configFactory = $config_factory;
$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');
}
}
public function getMiddleware() {
$version = 'V1';
$class = "\\Acquia\\ContentHubClient\\Middleware\\MiddlewareHmac" . $version;
$middleware = new $class($this->apiKey, $this->secretKey, $version);
return $middleware
->getMiddleware();
}
}