public function ContentHubSubscription::registerClient in Acquia Content Hub 8
Registers a client to Acquia Content Hub.
It also sets up the Drupal variables with the client registration info.
Parameters
string $client_name: The client name to register.
Return value
bool TRUE if succeeds, FALSE otherwise.
File
- src/
ContentHubSubscription.php, line 235
Class
- ContentHubSubscription
- Handles operations on the Acquia Content Hub Subscription.
Namespace
Drupal\acquia_contenthubCode
public function registerClient($client_name) {
if ($site = $this->clientManager
->createRequest('register', [
$client_name,
])) {
// Resetting the origin now that we have one.
$origin = $site['uuid'];
// Registration successful. Setting up the origin and client name.
$this->config
->set('origin', $origin);
$this->config
->set('client_name', $client_name);
$this->config
->save();
\Drupal::messenger()
->addStatus($this
->t('Successful Client registration with name "@name" (UUID = @uuid)', [
'@name' => $client_name,
'@uuid' => $origin,
]));
$message = new FormattableMarkup('Successful Client registration with name "@name" (UUID = @uuid)', [
'@name' => $client_name,
'@uuid' => $origin,
]);
$this->loggerFactory
->get('acquia_contenthub')
->debug($message);
return TRUE;
}
return FALSE;
}