PartnerFactory.php in Lockr 8.2
File
src/PartnerFactory.php
View source
<?php
namespace Drupal\lockr;
use Drupal\Core\State\StateInterface;
use Lockr\NullPartner;
use Lockr\Partner;
class PartnerFactory {
protected $state;
public function __construct(StateInterface $state) {
$this->state = $state;
}
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);
}
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;
}
}
Classes
Name |
Description |
PartnerFactory |
Creates partner objects for Lockr clients as well as information
about the currently detected partner. |