You are here

function drush_lockr_register in Lockr 8.3

Same name and namespace in other branches
  1. 8.4 lockr.drush.inc \drush_lockr_register()
  2. 8.2 lockr.drush.inc \drush_lockr_register()
  3. 7.3 lockr.drush.inc \drush_lockr_register()
  4. 7.2 lockr.drush.inc \drush_lockr_register()
  5. 4.x lockr.drush.inc \drush_lockr_register()

Registers the site with lockr.

File

./lockr.drush.inc, line 41
Hooks and callbacks for drush.

Code

function drush_lockr_register($email) {
  $name = variable_get('site_name');
  $client = \Drupal::service('lockr.client');
  $password = drush_get_option('password');
  try {
    $client
      ->register($email, $password, $name);
  } catch (LockrClientException $e) {
    if ($e->title === 'Missing header value' && $e->description === 'The Auth header is required.') {
      $msg = 'Email is already registered, please provide a password.';
    }
    elseif ($e->title === 'Partner mismatch') {
      $msg = "We didn't recognize your certificate, please ensure the provide path is a valid Lockr certificate.";
    }
    elseif ($e->title === 'Site exists') {
      $msg = 'This site is already registered. If you are experiencing issues, please contact support@lockr.io.';
    }
    elseif ($e->title === 'Credentials invalid') {
      $msg = 'The username and password did not match, please try again.';
    }
    else {
      $msg = 'An unknown error occurred, please try again later.';
    }
    \Drupal::logger($msg, 'error');
  } catch (LockrServerException $e) {
    \Drupal::logger('An unknown error occurred, please try again.', 'error');
  }
}