forked from OS2Forms/os2forms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaestroHelper.php
More file actions
706 lines (634 loc) · 23 KB
/
MaestroHelper.php
File metadata and controls
706 lines (634 loc) · 23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
<?php
namespace Drupal\os2forms_forloeb;
use DigitalPost\MeMo\Action;
use DigitalPost\MeMo\EntryPoint;
use Drupal\Component\Render\MarkupInterface;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\ImmutableConfig;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Logger\LoggerChannelInterface;
use Drupal\Core\Mail\MailManagerInterface;
use Drupal\Core\Render\Markup;
use Drupal\Core\Site\Settings;
use Drupal\Core\Url;
use Drupal\advancedqueue\Entity\QueueInterface;
use Drupal\advancedqueue\Job;
use Drupal\advancedqueue\JobResult;
use Drupal\entity_print\Plugin\EntityPrintPluginManagerInterface;
use Drupal\maestro\Engine\MaestroEngine;
use Drupal\maestro\Utility\TaskHandler;
use Drupal\os2forms_digital_post\Helper\DigitalPostHelper;
use Drupal\os2forms_digital_post\Model\Document;
use Drupal\os2forms_forloeb\Exception\RuntimeException;
use Drupal\os2forms_forloeb\Form\SettingsForm;
use Drupal\os2forms_forloeb\Plugin\AdvancedQueue\JobType\SendMeastroNotification;
use Drupal\os2forms_forloeb\Plugin\EngineTasks\MaestroWebformInheritTask;
use Drupal\os2forms_forloeb\Plugin\WebformHandler\MaestroNotificationHandler;
use Drupal\webform\WebformSubmissionInterface;
use Drupal\webform\WebformSubmissionStorageInterface;
use Drupal\webform\WebformThemeManagerInterface;
use Drupal\webform\WebformTokenManagerInterface;
use ItkDev\Serviceplatformen\Service\SF1601\SF1601;
use Psr\Log\LoggerInterface;
use Psr\Log\LoggerTrait;
/**
* Maestro helper.
*/
class MaestroHelper implements LoggerInterface {
use LoggerTrait;
const NOTIFICATION_ASSIGNMENT = 'assignment';
const NOTIFICATION_REMINDER = 'reminder';
const NOTIFICATION_ESCALATION = 'escalation';
/**
* The config.
*
* @var \Drupal\Core\Config\ImmutableConfig
*/
private readonly ImmutableConfig $config;
/**
* The webform submission storage.
*
* @var \Drupal\webform\WebformSubmissionStorageInterface|\Drupal\Core\Entity\EntityStorageInterface
*/
private readonly WebformSubmissionStorageInterface $webformSubmissionStorage;
/**
* The queue storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
private readonly EntityStorageInterface $queueStorage;
/**
* Constructor.
*/
public function __construct(
EntityTypeManagerInterface $entityTypeManager,
ConfigFactoryInterface $configFactory,
private readonly WebformTokenManagerInterface $tokenManager,
private readonly MailManagerInterface $mailManager,
private readonly LanguageManagerInterface $languageManager,
private readonly WebformThemeManagerInterface $webformThemeManager,
private readonly EntityPrintPluginManagerInterface $entityPrintPluginManager,
private readonly DigitalPostHelper $digitalPostHelper,
private readonly LoggerChannelInterface $logger,
private readonly LoggerChannelInterface $submissionLogger,
) {
$this->config = $configFactory->get(SettingsForm::SETTINGS);
$this->webformSubmissionStorage = $entityTypeManager->getStorage('webform_submission');
$this->queueStorage = $entityTypeManager->getStorage('advancedqueue_queue');
}
/**
* Implements hook_maestro_zero_user_notification().
*/
public function maestroZeroUserNotification($templateMachineName, $taskMachineName, $queueID, $notificationType) {
$templateTask = MaestroEngine::getTemplateTaskByID($templateMachineName, $taskMachineName);
if (MaestroWebformInheritTask::isWebformTask($templateTask)) {
if ($inheritWebformUniqueId = ($templateTask['data'][MaestroWebformInheritTask::INHERIT_WEBFORM_UNIQUE_ID] ?? NULL)) {
if ($processID = (MaestroEngine::getProcessIdFromQueueId($queueID) ?: NULL)) {
if ($entityIdentifier = (self::getWebformSubmissionIdentifiersForProcess($processID)[$inheritWebformUniqueId] ?? NULL)) {
$submission = $this->webformSubmissionStorage->load($entityIdentifier['entity_id']);
if ($submission) {
$this->handleSubmissionNotification($notificationType, $submission, $templateTask, $queueID);
}
}
}
}
}
}
/**
* Get webform submission identifiers for a process.
*
* @param int $processID
* The Maestro Process ID.
*
* @return array
* The webform submission identifiers sorted ascendingly by creation time.
*/
public static function getWebformSubmissionIdentifiersForProcess(int $processID): array {
// Get webform submissions in process.
$entityIdentifiers = array_filter(
MaestroEngine::getAllEntityIdentifiersForProcess($processID),
static fn (array $entityIdentifier) => 'webform_submission' === ($entityIdentifier['entity_type'] ?? NULL)
);
// Sort by entity ID.
uasort($entityIdentifiers, static fn (array $a, array $b) => ($b['entity_id'] ?? 0) <=> ($a['entity_id'] ?? 0));
return $entityIdentifiers;
}
/**
* Handle submission notification.
*
* Creates job for sending notification to assigned user.
*
* @param string $notificationType
* The notification type (one of the NOTIFICATION_* constannts).
* @param \Drupal\webform\WebformSubmissionInterface $submission
* The webform submission.
* @param array $templateTask
* The template task.
* @param int $maestroQueueID
* The Maestro queue ID.
*
* @see self::processJob()
*/
private function handleSubmissionNotification(
string $notificationType,
WebformSubmissionInterface $submission,
array $templateTask,
int $maestroQueueID,
): ?Job {
$context = [
'webform_submission' => $submission,
];
try {
$job = Job::create(SendMeastroNotification::class, [
'notificationType' => $notificationType,
'templateTask' => $templateTask,
'queueID' => $maestroQueueID,
'submissionID' => $submission->id(),
'webformID' => $submission->getWebform()->id(),
]);
$queue = $this->loadQueue();
$queue->enqueueJob($job);
$context['@queue'] = $queue->id();
$this->notice('Job for sending notification added to the queue @queue.', $context + [
'handler_id' => 'os2forms_forloeb',
'operation' => 'notification queued for sending',
]);
return $job;
}
catch (\Exception $exception) {
$this->error('Error creating job for sending notification: @message', $context + [
'@message' => $exception->getMessage(),
'handler_id' => 'os2forms_forloeb',
'operation' => 'notification failed',
'exception' => $exception,
]);
return NULL;
}
}
/**
* Process a job to send out a notification.
*
* @param \Drupal\advancedqueue\Job $job
* The job (created by handleSubmissionNotification)
*
* @see self::handleSubmissionNotification()
*/
public function processJob(Job $job): JobResult {
$payload = $job->getPayload();
[
'notificationType' => $notificationType,
'templateTask' => $templateTask,
'queueID' => $maestroQueueID,
'submissionID' => $submissionID,
] = $payload;
$submission = $this->webformSubmissionStorage->load($submissionID);
$this->sendNotification($notificationType, $submission, $templateTask, $maestroQueueID);
return JobResult::success();
}
/**
* Send notification.
*
* @param string $notificationType
* The notification type (one of the NOTIFICATION_* constannts).
* @param \Drupal\webform\WebformSubmissionInterface $submission
* The webform submission.
* @param array $templateTask
* The template task.
* @param int $maestroQueueID
* The Maestro queue ID.
*/
private function sendNotification(
string $notificationType,
WebformSubmissionInterface $submission,
array $templateTask,
int $maestroQueueID,
) {
$context = [
'webform_submission' => $submission,
];
try {
$handlers = $submission->getWebform()->getHandlers();
foreach ($handlers as $handler) {
if (!($handler instanceof MaestroNotificationHandler)
|| $handler->isDisabled()
|| $handler->isExcluded()
|| !$handler->isNotificationEnabled($notificationType)
|| !$handler->checkConditions($submission)
) {
continue;
}
[
'content' => $content,
'contentType' => $contentType,
'recipient' => $recipient,
'subject' => $subject,
'taskUrl' => $taskUrl,
'actionLabel' => $actionLabel,
'senderLabel' => $senderLabel,
] = $this->renderNotification($submission, $handler->getHandlerId(), $notificationType, $templateTask, $maestroQueueID);
if ('email' === $contentType) {
$this->sendNotificationEmail($recipient, $subject, $content, $submission, $notificationType);
}
else {
$this->sendNotificationDigitalPost($recipient, $subject, $content, $taskUrl, $actionLabel, $submission, $notificationType, $senderLabel);
}
}
}
catch (\Exception $exception) {
$this->error('Error sending notification: @message', $context + [
'@message' => $exception->getMessage(),
'handler_id' => 'os2forms_forloeb',
'operation' => 'notification failed',
'exception' => $exception,
]);
}
}
/**
* Load advanced queue used to process notification jobs.
*
* @return \Drupal\advancedqueue\Entity\QueueInterface
* The queue.
*/
private function loadQueue(): QueueInterface {
$queueId = $this->config->get('processing')['queue'] ?? NULL;
if (NULL === $queueId) {
throw new RuntimeException('Cannot get queue ID');
}
$queue = $this->queueStorage->load($queueId);
if (NULL === $queue) {
throw new RuntimeException(sprintf('Cannot load queue %s', $queueId));
}
return $queue;
}
/**
* Send notification email.
*
* @param string $recipient
* The recipient.
* @param string $subject
* The subject.
* @param string $body
* The body.
* @param \Drupal\webform\WebformSubmissionInterface $submission
* The webform submission.
* @param string $notificationType
* The notification type (one of the NOTIFICATION_* constannts).
*/
private function sendNotificationEmail(
string $recipient,
string $subject,
string $body,
WebformSubmissionInterface $submission,
string $notificationType,
): void {
try {
$message = [
'subject' => $subject,
'body' => $body,
'html' => TRUE,
];
$langcode = $this->languageManager->getCurrentLanguage()->getId();
$result = $this->mailManager->mail(
'os2forms_forloeb',
'notification',
$recipient,
$langcode,
$message
);
if (!$result['result']) {
throw new RuntimeException(sprintf('Error sending notification (%s) email to %s', $notificationType, $recipient));
}
$this->notice('Email notification (@type) sent to @recipient', [
'@type' => $notificationType,
'webform_submission' => $submission,
'@recipient' => $recipient,
'handler_id' => 'os2forms_forloeb',
'operation' => 'notification sent',
]);
}
catch (\Exception $exception) {
$this->error('Error sending email notification (@type): @message', [
'@type' => $notificationType,
'@message' => $exception->getMessage(),
'webform_submission' => $submission,
'handler_id' => 'os2forms_forloeb',
'operation' => 'failed sending notification',
]);
}
}
/**
* Send notification digital post.
*
* @param string $recipient
* The recipient.
* @param string $subject
* The subject.
* @param string $content
* The content.
* @param string $taskUrl
* The Maestro task URL.
* @param string $actionLabel
* The action label.
* @param \Drupal\webform\WebformSubmissionInterface $submission
* The webform submission.
* @param string $notificationType
* The notification type (one of the NOTIFICATION_* constants).
* @param string $senderLabel
* The sender label.
*/
private function sendNotificationDigitalPost(
string $recipient,
string $subject,
string $content,
string $taskUrl,
string $actionLabel,
WebformSubmissionInterface $submission,
string $notificationType,
string $senderLabel,
): void {
try {
$document = new Document(
$content,
Document::MIME_TYPE_PDF,
$subject . '.pdf'
);
$messageLabel = $subject;
$recipientLookupResult = $this->digitalPostHelper->lookupRecipient($recipient);
$actions = [
(new Action())
->setActionCode(SF1601::ACTION_SELVBETJENING)
->setEntryPoint((new EntryPoint())
->setUrl($taskUrl)
)
->setLabel($actionLabel),
];
$message = $this->digitalPostHelper->getMeMoHelper()->buildMessage($recipientLookupResult, $senderLabel,
$messageLabel, $document, $actions);
$forsendelse = $this->digitalPostHelper->getForsendelseHelper()->buildForsendelse($recipientLookupResult,
$messageLabel, $document);
$this->digitalPostHelper->sendDigitalPost(
SF1601::TYPE_AUTOMATISK_VALG,
$message,
$forsendelse,
$submission
);
$this->notice('Digital post notification sent (@type)', [
'@type' => $notificationType,
'webform_submission' => $submission,
'handler_id' => 'os2forms_forloeb',
'operation' => 'notification sent',
]);
}
catch (\Exception $exception) {
$this->error('Error sending digital post notification (@type): @message', [
'@type' => $notificationType,
'@message' => $exception->getMessage(),
'webform_submission' => $submission,
'handler_id' => 'os2forms_forloeb',
'operation' => 'failed sending notification',
]);
}
}
/**
* Render notification.
*
* @param \Drupal\webform\WebformSubmissionInterface $submission
* The submission.
* @param string $handlerId
* The handler ID.
* @param string $notificationType
* The notification type (one of the NOTIFICATION_* constants).
* @param array $templateTask
* The Maestro template task.
* @param int $maestroQueueID
* The Maestro queue ID.
* @param string|null $contentType
* Optional content type. If not set the content type will be computed based
* on the recipient.
*
* @return array
* The rendered notification with keys
* - content
* - contentType
* - recipient
* - subject
* - taskUrl (for digital post)
* - actionLabel (for digital post)
* - senderLabel (for digital post)
*
* @see self::renderHtml()
*/
public function renderNotification(WebformSubmissionInterface $submission, string $handlerId, string $notificationType, array $templateTask, int $maestroQueueID, ?string $contentType = NULL): array {
$handler = $submission->getWebform()->getHandler($handlerId);
$settings = $handler->getSettings();
$senderLabel = $settings[MaestroNotificationHandler::NOTIFICATION][MaestroNotificationHandler::SENDER_LABEL] ?? NULL;
if (NULL === $senderLabel) {
throw new RuntimeException(sprintf('Cannot get setting for Maestro notification: %s', MaestroNotificationHandler::SENDER_LABEL));
}
$data = $submission->getData();
$recipientElement = $settings[MaestroNotificationHandler::NOTIFICATION][MaestroNotificationHandler::RECIPIENT_ELEMENT] ?? NULL;
// Handle os2forms_person_lookup element.
$recipient = $data[$recipientElement]['cpr_number']
// Simple element.
?? $data[$recipientElement]
?? NULL;
// Handle composite elements.
if ($recipient === NULL) {
// Composite subelement keys consist of
// the composite element key and the subelement key separated by '__',
// e.g. 'contact__name'.
if (str_contains($recipientElement, '__')) {
$keys = explode('__', $recipientElement);
$recipient = NestedArray::getValue($data, $keys);
}
}
if ($notificationType === self::NOTIFICATION_ESCALATION) {
$recipient = $settings[MaestroNotificationHandler::NOTIFICATION][$notificationType][MaestroNotificationHandler::NOTIFICATION_RECIPIENT] ?? NULL;
}
if (NULL !== $recipient) {
// Lifted from MaestroEngine.
$maestroTokenData = [
'maestro' => [
'task' => $templateTask,
'queueID' => $maestroQueueID,
],
];
$notificationSetting = $settings[MaestroNotificationHandler::NOTIFICATION][$notificationType] ?? NULL;
if (NULL === $notificationSetting) {
throw new RuntimeException(sprintf('Cannot get setting for %s notification', $notificationType));
}
$processValue = static fn (string $value) => $value;
// Handle a preview, i.e. not a real Maestro context.
if (empty($templateTask) || 0 === $maestroQueueID) {
$taskUrl = Url::fromRoute('os2forms_forloeb.meastro_notification.preview_message', ['message' => 'This is just a preview'])->toString(TRUE)->getGeneratedUrl();
$processValue = static function (string $value) use ($taskUrl) {
// Replace href="[maestro:task-url]" with href="«$taskUrl»".
$value = preg_replace('/href\s*=\s*["\']\[maestro:task-url\]["\']/', sprintf('href="%s"', htmlspecialchars($taskUrl)), $value);
$value = preg_replace('/\[(maestro:[^]]+)\]/', '(\1)', $value);
return $value;
};
}
else {
$taskUrl = TaskHandler::getHandlerURL($maestroQueueID);
}
$subject = $this->tokenManager->replace(
$processValue($notificationSetting[MaestroNotificationHandler::NOTIFICATION_SUBJECT]),
$submission,
$maestroTokenData
);
$content = $notificationSetting[MaestroNotificationHandler::NOTIFICATION_CONTENT];
if (isset($content['value'])) {
$content['value'] = $processValue($content['value']);
}
$actionLabel = $this->tokenManager->replace($notificationSetting[MaestroNotificationHandler::NOTIFICATION_ACTION_LABEL], $submission);
if (NULL === $contentType) {
$contentType = filter_var($recipient, FILTER_VALIDATE_EMAIL) ? 'email' : 'pdf';
}
switch ($contentType) {
case 'email':
$content = $this->renderHtml($contentType, $subject, $content, $taskUrl, $actionLabel, $submission, $maestroTokenData);
break;
case 'pdf':
$pdfContent = $this->renderHtml($contentType, $subject, $content, $taskUrl, $actionLabel, $submission, $maestroTokenData);
// Get dompdf plugin from entity_print module.
/** @var \Drupal\entity_print\Plugin\EntityPrint\PrintEngine\PdfEngineBase $printer */
$printer = $this->entityPrintPluginManager->createInstance('dompdf');
$printer->addPage($pdfContent);
$content = $printer->getBlob();
break;
default:
throw new RuntimeException(sprintf('Invalid content type: %s', $contentType));
}
return [
'content' => $content,
'contentType' => $contentType,
'recipient' => $recipient,
'subject' => $subject,
'taskUrl' => $taskUrl,
'actionLabel' => $actionLabel,
'senderLabel' => $senderLabel,
];
}
throw new RuntimeException();
}
/**
* Render HTML for a notification.
*
* @param string $type
* The notification content type ('email' or 'pdf').
* @param string $subject
* The subject.
* @param array $content
* The content.
* @param string $taskUrl
* The Maestro taks URL.
* @param string $actionLabel
* The action label.
* @param \Drupal\webform\WebformSubmissionInterface $submission
* The webform submission.
* @param array $maestroTokenData
* The Maestro token data.
*
* @return string|MarkupInterface
* The rendered content.
*/
private function renderHtml(
string $type,
string $subject,
array $content,
string $taskUrl,
string $actionLabel,
WebformSubmissionInterface $submission,
array $maestroTokenData,
): string|MarkupInterface {
$template = $this->config->get('templates')['notification_' . $type] ?? NULL;
if (file_exists($template)) {
$template = file_get_contents($template) ?: NULL;
}
if (NULL === $template) {
$template = 'Missing or invalid template';
}
$build = [
'#type' => 'inline_template',
'#template' => $template,
'#context' => [
'message' => [
'subject' => $subject,
'content' => $content,
],
'task_url' => $taskUrl,
'action_label' => $actionLabel,
'webform_submission' => $submission,
'handler' => $this,
'base_url' => Settings::get('base_url'),
],
];
$html = trim((string) $this->webformThemeManager->renderPlain($build));
return Markup::create($this->tokenManager->replace(
$html,
$submission,
$maestroTokenData
));
}
/**
* Implements hook_mail().
*/
public function mail(string $key, array &$message, array $params) {
switch ($key) {
case 'notification':
$message['subject'] = $params['subject'];
$message['body'][] = $params['body'];
if (isset($params['attachments'])) {
foreach ($params['attachments'] as $attachment) {
$message['params']['attachments'][] = $attachment;
}
}
break;
}
}
/**
* Implements hook_mail_alter().
*/
public function mailAlter(array &$message) {
if (str_starts_with($message['id'], 'os2forms_forloeb')) {
if (isset($message['params']['html']) && $message['params']['html']) {
$message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed';
}
}
}
/**
* {@inheritdoc}
*/
public function log($level, $message, array $context = []): void {
$this->logger->log($level, $message, $context);
// @see https://www.drupal.org/node/3020595
if (isset($context['webform_submission']) && $context['webform_submission'] instanceof WebformSubmissionInterface) {
$this->submissionLogger->log($level, $message, $context);
}
}
/**
* Implements hook_maestro_can_user_execute_task_alter().
*/
public function maestroCanUserExecuteTaskAlter(bool &$returnValue, int $queueID, int $userID): void {
// Perform our checks only if an anonymous user has been barred access.
if (0 === $userID && FALSE === $returnValue) {
$templateTask = MaestroEngine::getTemplateTaskByQueueID($queueID);
if (isset($templateTask['assigned'])) {
$assignments = explode(',', $templateTask['assigned']);
// Check if one of the assignments match our known anonymous roles.
$knownAnonymousAssignments = array_map(
static fn(string $role) => 'role:fixed:' . $role,
array_filter($this->config->get('known_anonymous_roles') ?: [])
);
foreach ($assignments as $assignment) {
if (in_array($assignment, $knownAnonymousAssignments, TRUE)) {
$returnValue = TRUE;
}
}
}
}
}
}