Skip to content

Commit

Permalink
Added support for unprefixed "eligible_authroles" and "eligible_authi…
Browse files Browse the repository at this point in the history
…ds" options in publish messages, in accordance with the standard. For backwards compatibility, the prefixed version is still preferred if both options are specified.
  • Loading branch information
boenrobot committed Jul 12, 2022
1 parent 705b7ab commit 4a83b75
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/Message/PublishMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,20 +157,24 @@ public function setOptions($options)
$this->exclude_me = isset($options->exclude_me) && $options->exclude_me === false ? false : true;
$this->exclude = isset($options->exclude) && is_array($options->exclude) ? $options->exclude : [];
$this->eligible = isset($options->eligible) && is_array($options->eligible) ? $options->eligible : null;
$this->eligible_authroles = []; // default to no auth roles eligible

if (isset($options->_thruway_eligible_authroles)) {
if (is_array($options->_thruway_eligible_authroles)) {
$this->eligible_authroles = $options->_thruway_eligible_authroles;
$this->eligible_authroles = []; // default to no auth roles eligible
// Support both the standard and prefixed versions of eligible_authroles, preferring the prefixed version
$authroles = $options->_thruway_eligible_authroles ?? $options->eligible_authroles ?? null;
if (isset($authroles)) {
if (is_array($authroles)) {
$this->eligible_authroles = $authroles;
}
} else {
$this->eligible_authroles = null; // null says every authrole is valid
}

$this->eligible_authids = []; // default to no authids eligible
if (isset($options->_thruway_eligible_authids)) {
if (is_array($options->_thruway_eligible_authids)) {
$this->eligible_authids = $options->_thruway_eligible_authids;
// Support both the standard and prefixed versions of eligible_authids, preferring the prefixed version
$authids = $options->_thruway_eligible_authids ?? $options->eligible_authids ?? null;
if (isset($authids)) {
if (is_array($authids)) {
$this->eligible_authids = $authids;
}
} else {
$this->eligible_authids = null; // null says every authid is valid
Expand Down

0 comments on commit 4a83b75

Please sign in to comment.