Skip to content

Commit

Permalink
Merge branch 'issue/4' into 8.x
Browse files Browse the repository at this point in the history
[#4] Per-profile permissions not available
  • Loading branch information
jensschuppe committed Nov 11, 2020
2 parents 3ba4bd5 + e297c1e commit 06ec2ee
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
42 changes: 40 additions & 2 deletions src/CiviMRF.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected function connector() {
* The Advanced Newsletter Management profile configuration, or NULL if the
* profile could not be retrieved.
*/
public function profileGet($profile_name = NULL) {
public function profileGetSingle($profile_name = NULL) {
$params = array();
if ($profile_name) {
$params['name'] = $profile_name;
Expand All @@ -73,7 +73,7 @@ public function profileGet($profile_name = NULL) {
$call = $this->core->createCall(
$this->connector(),
'NewsletterProfile',
'get',
'getsingle',
$params,
[]
);
Expand Down Expand Up @@ -101,6 +101,44 @@ public function profileGet($profile_name = NULL) {
return $return;
}

/**
* Retrieves the configuration for all Advanced Newsletter Management profiles
* from CiviCRM.
*
* @return array
* An array of Advanced Newsletter Management profile configurations.
*/
public function profileGet() {
$params = array();
try {
$call = $this->core->createCall(
$this->connector(),
'NewsletterProfile',
'get',
$params,
[]
);
$this->core->executeCall($call);
$reply = $call->getReply();
if ($reply['is_error'] == 1) {
$return = [];
}
else {
$return = $reply['values'];
}
}
catch (Exception $exception) {
$variables = Error::decodeException($exception);
Drupal::logger('civicrm_newsletter')->error(
'%type: @message in %function (line %line of %file).',
$variables
);
$return = [];
}

return $return;
}

/**
* Retrieves the subscription status for a given contact hash.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Routing/ProfileConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct(CiviMRF $cmrf) {
*/
public function convert($value, $definition, $name, array $defaults) {
try {
return (object) $this->cmrf->profileGet($value);
return (object) $this->cmrf->profileGetSingle($value);
} catch (Exception $exception) {
throw new NotFoundHttpException();
}
Expand Down

0 comments on commit 06ec2ee

Please sign in to comment.