You are here

public function PartnerFactory::getPartner in Lockr 8.2

Get a partner object for use with a Lockr client.

Return value

\Lockr\PartnerInterface

File

src/PartnerFactory.php, line 33

Class

PartnerFactory
Creates partner objects for Lockr clients as well as information about the currently detected partner.

Namespace

Drupal\lockr

Code

public function getPartner() {
  $region = $this->state
    ->get('lockr.region', 'us');
  if ($this->state
    ->get('lockr.custom', FALSE)) {
    $cert_path = $this->state
      ->get('lockr.cert');
    if ($cert_path) {
      return new Partner($cert_path, 'custom', $region);
    }
    return new NullPartner($region);
  }
  $detected_partner = $this
    ->detectPartner();
  if (!$detected_partner) {
    return new NullPartner($region);
  }
  return new Partner($detected_partner['cert'], $detected_partner['name'], $region);
}