Skip to content

Commit

Permalink
Merge pull request #144 from creative-commoners/pulls/5.3/remove-self
Browse files Browse the repository at this point in the history
ENH Use class name instead of self
  • Loading branch information
GuySartorelli authored Jun 17, 2024
2 parents bf5ee1c + aae799a commit a4ebf4b
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 143 deletions.
14 changes: 7 additions & 7 deletions src/Authenticator/LoginForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function __construct($controller, $name)
$integrationType = $service->config()->integration_type;

if ($integrationType === RealMeService::TYPE_ASSERT) {
$this->template = self::class . '/RealMeAssertForm';
$this->template = LoginForm::class . '/RealMeAssertForm';
}

if ($this->config()->include_javascript) {
Expand Down Expand Up @@ -163,7 +163,7 @@ public function HasRealMeLastError()
*/
public function getAuthenticatorName()
{
return _t(self::class . '.AUTHENTICATOR_NAME', 'RealMe Account');
return _t(LoginForm::class . '.AUTHENTICATOR_NAME', 'RealMe Account');
}

/**
Expand Down Expand Up @@ -192,22 +192,22 @@ protected function getFormActions()
if ($integrationType === RealMeService::TYPE_ASSERT) {
$loginButtonContent = ArrayData::create(array(
'Label' => _t(
self::class . '.ASSERTLOGINBUTTON',
LoginForm::class . '.ASSERTLOGINBUTTON',
'Share your details with {orgname}',
['orgname' => $service->config()->metadata_organisation_display_name]
),
'ShowNewWindowIcon' => false
))->renderWith(self::class . '/RealMeLoginButton');
))->renderWith(LoginForm::class . '/RealMeLoginButton');
} else {
// Login button
$loginButtonContent = ArrayData::create(array(
'Label' => _t(self::class . '.LOGINBUTTON2', 'Log in'),
'Label' => _t(LoginForm::class . '.LOGINBUTTON2', 'Log in'),
'ShowNewWindowIcon' => true
))->renderWith(self::class . '/RealMeLoginButton');
))->renderWith(LoginForm::class . '/RealMeLoginButton');
}

return FieldList::create(array(
FormAction::create('doLogin', _t(self::class . '.LOGINBUTTON2', 'Log in'))
FormAction::create('doLogin', _t(LoginForm::class . '.LOGINBUTTON2', 'Log in'))
->setUseButtonTag(true)
->setButtonContent($loginButtonContent)
->setAttribute('class', 'realme_button')
Expand Down
6 changes: 3 additions & 3 deletions src/Authenticator/MiniLoginForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class MiniLoginForm extends LoginForm
{
/**
* @var string The position at which the 'What's RealMe?' popup appears on hover. Can be either 'left' or 'right'.
* @see self::setMiniLoginFormPopupPosition()
* @see MiniLoginForm::setMiniLoginFormPopupPosition()
*/
private $popupPosition = 'left';

Expand All @@ -18,14 +18,14 @@ public function __construct($controller, $name)
parent::__construct($controller, $name);
$this->setFormMethod('GET', true);

$buttonName = sprintf('action_%s', self::$action_button_name);
$buttonName = sprintf('action_%s', MiniLoginForm::$action_button_name);
$this->Actions()->fieldByName($buttonName)->addExtraClass('mini');
}

public function getRealMeMiniLoginLink()
{
$fields = $this->Fields();
$buttonName = sprintf('action_%s', self::$action_button_name);
$buttonName = sprintf('action_%s', MiniLoginForm::$action_button_name);
$action = $this->Actions()->fieldByName($buttonName);

$authMethod = $fields->dataFieldByName('AuthenticationMethod')->Value();
Expand Down
28 changes: 16 additions & 12 deletions src/Model/FederatedIdentity.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function __construct($nameId)
*/
public static function createFromXML(DOMDocument $identityDocument, $nameId)
{
$identity = new self($nameId);
$identity = new FederatedIdentity($nameId);

$xpath = new DOMXPath($identityDocument);
$xpath->registerNamespace('p', 'urn:oasis:names:tc:ciq:xpil:3');
Expand All @@ -155,50 +155,54 @@ public static function createFromXML(DOMDocument $identityDocument, $nameId)
$xpath->registerNamespace('addr', 'urn:oasis:names:tc:ciq:xal:3');

// Name elements
$identity->FirstName = self::getNodeValue(
$identity->FirstName = FederatedIdentity::getNodeValue(
$xpath,
"/p:Party/p:PartyName/n:PersonName/n:NameElement[@n:ElementType='FirstName']"
);
$identity->MiddleName = self::getNodeValue(
$identity->MiddleName = FederatedIdentity::getNodeValue(
$xpath,
"/p:Party/p:PartyName/n:PersonName/n:NameElement[@n:ElementType='MiddleName']"
);
$identity->LastName = self::getNodeValue(
$identity->LastName = FederatedIdentity::getNodeValue(
$xpath,
"/p:Party/p:PartyName/n:PersonName/n:NameElement[@n:ElementType='LastName']"
);

// Gender
$identity->Gender = self::getNamedItemNodeValue($xpath, '/p:Party/p:PersonInfo[@p:Gender]', 'Gender');
$identity->Gender = FederatedIdentity::getNamedItemNodeValue(
$xpath,
'/p:Party/p:PersonInfo[@p:Gender]',
'Gender'
);

// Birth info
$identity->BirthInfoQuality = $xpath->query("/p:Party/p:BirthInfo[@dataQuality:DataQualityType]");

// Birth date
$identity->BirthYear = self::getNodeValue(
$identity->BirthYear = FederatedIdentity::getNodeValue(
$xpath,
"/p:Party/p:BirthInfo/p:BirthInfoElement[@p:Type='BirthYear']"
);
$identity->BirthMonth = self::getNodeValue(
$identity->BirthMonth = FederatedIdentity::getNodeValue(
$xpath,
"/p:Party/p:BirthInfo/p:BirthInfoElement[@p:Type='BirthMonth']"
);
$identity->BirthDay = self::getNodeValue(
$identity->BirthDay = FederatedIdentity::getNodeValue(
$xpath,
"/p:Party/p:BirthInfo/p:BirthInfoElement[@p:Type='BirthDay']"
);

// Birth place
$identity->BirthPlaceQuality = self::getNamedItemNodeValue(
$identity->BirthPlaceQuality = FederatedIdentity::getNamedItemNodeValue(
$xpath,
'/p:Party/p:BirthInfo/p:BirthPlaceDetails[@dataQuality:DataQualityType]',
'DataQualityType'
);
$identity->BirthPlaceCountry = self::getNodeValue(
$identity->BirthPlaceCountry = FederatedIdentity::getNodeValue(
$xpath,
"/p:Party/p:BirthInfo/p:BirthPlaceDetails/addr:Country/addr:NameElement[@addr:NameType='Name']"
);
$identity->BirthPlaceLocality = self::getNodeValue(
$identity->BirthPlaceLocality = FederatedIdentity::getNodeValue(
$xpath,
"/p:Party/p:BirthInfo/p:BirthPlaceDetails/addr:Locality/addr:NameElement[@addr:NameType='Name']"
);
Expand Down Expand Up @@ -268,7 +272,7 @@ private static function getNodeValue(DOMXPath $xpath, $query)
*/
public static function createFromJSON($identityHashMap, $nameId)
{
$identity = new self($nameId);
$identity = new FederatedIdentity($nameId);

$identityMap = json_decode($identityHashMap ?? '', true);

Expand Down
Loading

0 comments on commit a4ebf4b

Please sign in to comment.