class PartnerFactory in Lockr 8.2
Creates partner objects for Lockr clients as well as information about the currently detected partner.
Hierarchy
- class \Drupal\lockr\PartnerFactory
Expanded class hierarchy of PartnerFactory
1 file declares its use of PartnerFactory
- LockrAdminController.php in src/
Controller/ LockrAdminController.php
1 string reference to 'PartnerFactory'
1 service uses PartnerFactory
File
- src/
PartnerFactory.php, line 14
Namespace
Drupal\lockrView source
class PartnerFactory {
/** @var \Drupal\Core\State\StateInterface */
protected $state;
/**
* Construct a new partner factory.
*
* @param \Drupal\Core\State\StateInterface
*/
public function __construct(StateInterface $state) {
$this->state = $state;
}
/**
* Get a partner object for use with a Lockr client.
*
* @return \Lockr\PartnerInterface
*/
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);
}
/**
* Return information about the detected partner.
*
* @return array|null
*/
public function detectPartner() {
if (defined('PANTHEON_BINDING')) {
return [
'name' => 'pantheon',
'title' => 'Pantheon',
'description' => "The Pantheor is strong with this one.\n We're detecting you 're on Pantheon and a friend of theirs is a friend of ours.\n Welcome to Lockr.",
'cert' => '/srv/bindings/' . PANTHEON_BINDING . '/certs/binding.pem',
];
}
return NULL;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PartnerFactory:: |
protected | property | @var \Drupal\Core\State\StateInterface | |
PartnerFactory:: |
public | function | Return information about the detected partner. | |
PartnerFactory:: |
public | function | Get a partner object for use with a Lockr client. | |
PartnerFactory:: |
public | function | Construct a new partner factory. |