Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
recurring_events
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
recurring_events
Commits
3d78241b
Commit
3d78241b
authored
1 year ago
by
Camilo Ernesto Escobar Bedoya
Committed by
Andrii Podanenko
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3362297
Added explanatory comments in recurring_events_registration_mail()
parent
a0ad2e1b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!70
Issue #3362297 New Queue Worker to send Email Notifications
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/recurring_events_registration/recurring_events_registration.module
+15
-12
15 additions, 12 deletions
..._events_registration/recurring_events_registration.module
with
15 additions
and
12 deletions
modules/recurring_events_registration/recurring_events_registration.module
+
15
−
12
View file @
3d78241b
...
@@ -143,15 +143,25 @@ function template_preprocess_registrant(array &$variables) {
...
@@ -143,15 +143,25 @@ function template_preprocess_registrant(array &$variables) {
* Implements hook_mail().
* Implements hook_mail().
*/
*/
function
recurring_events_registration_mail
(
$key
,
&
$message
,
$params
)
{
function
recurring_events_registration_mail
(
$key
,
&
$message
,
$params
)
{
// Only if a value for 'subject', 'body' or 'from' has not been received in
// the `$params`, then use the notification service which is able to get
// those values from the `$key` and the `$registrant`.
// Some pieces of code can call the `mail()` function with already proccessed
// values for 'subject', 'body' and 'from', meaning that it is not necessary
// that those values are calculated here by the notification service.
// @see \Drupal\recurring_events_registration\Plugin\QueueWorker\EmailNotificationsQueueWorker
if
((
empty
(
$params
[
'subject'
])
||
empty
(
$params
[
'body'
])
||
empty
(
$params
[
'from'
]))
if
((
empty
(
$params
[
'subject'
])
||
empty
(
$params
[
'body'
])
||
empty
(
$params
[
'from'
]))
&&
!
empty
(
$params
[
'registrant'
])
&&
!
empty
(
$params
[
'registrant'
])
&&
$params
[
'registrant'
]
instanceof
Registrant
)
{
&&
$params
[
'registrant'
]
instanceof
Registrant
)
{
/** @var \Drupal\recurring_events_registration\NotificationService */
/** @var \Drupal\recurring_events_registration\NotificationService
$service
*/
$service
=
\Drupal
::
service
(
'recurring_events_registration.notification_service'
);
$service
=
\Drupal
::
service
(
'recurring_events_registration.notification_service'
);
$service
->
setKey
(
$key
)
->
setEntity
(
$params
[
'registrant'
]);
$service
->
setKey
(
$key
)
->
setEntity
(
$params
[
'registrant'
]);
}
}
// If other pieces of code that have called the `mail()` function have
// already defined those params, give them precedence. Else, let the
// notification service to calculate those values.
// Set the `$message['from']`.
if
(
!
empty
(
$params
[
'from'
]))
{
if
(
!
empty
(
$params
[
'from'
]))
{
$message
[
'from'
]
=
$params
[
'from'
];
$message
[
'from'
]
=
$params
[
'from'
];
}
}
...
@@ -159,6 +169,7 @@ function recurring_events_registration_mail($key, &$message, $params) {
...
@@ -159,6 +169,7 @@ function recurring_events_registration_mail($key, &$message, $params) {
$message
[
'from'
]
=
$service
->
getFrom
();
$message
[
'from'
]
=
$service
->
getFrom
();
}
}
// Set the `$message['subject']`.
if
(
!
empty
(
$params
[
'subject'
]))
{
if
(
!
empty
(
$params
[
'subject'
]))
{
$message
[
'subject'
]
=
$params
[
'subject'
];
$message
[
'subject'
]
=
$params
[
'subject'
];
}
}
...
@@ -166,21 +177,13 @@ function recurring_events_registration_mail($key, &$message, $params) {
...
@@ -166,21 +177,13 @@ function recurring_events_registration_mail($key, &$message, $params) {
$message
[
'subject'
]
=
$service
->
getSubject
();
$message
[
'subject'
]
=
$service
->
getSubject
();
}
}
// Set the `$message['body']`.
if
(
!
empty
(
$params
[
'body'
]))
{
if
(
!
empty
(
$params
[
'body'
]))
{
$message
[
'body'
][]
=
$params
[
'body'
];
$message
[
'body'
][]
=
$params
[
'body'
];
}
}
elseif
(
isset
(
$service
))
{
elseif
(
isset
(
$service
))
{
$message
[
'body'
][]
=
$service
->
getMessage
();
$message
[
'body'
][]
=
$service
->
getMessage
();
}
}
// echo 'params::' . PHP_EOL;
// print_r($params);
// echo 'message::' . PHP_EOL;
// print_r($message);
// $message['from'] = $params['from'] ?? isset($service) ? $service->getFrom() : '';
// $message['subject'] = $params['subject'] ?? isset($service) ? $service->getSubject() : '';
// $message['body'][] = $params['body'] ?? isset($service) ? $service->getMessage() : '';
}
}
/**
/**
...
@@ -339,7 +342,7 @@ function recurring_events_registration_recurring_events_pre_delete_instances(Eve
...
@@ -339,7 +342,7 @@ function recurring_events_registration_recurring_events_pre_delete_instances(Eve
*
*
* @param string $key
* @param string $key
* The mail key used to determine the message and subject.
* The mail key used to determine the message and subject.
* @param \Drupal\recurring_events_registration\Entity\RegistrantInterface
|bool
$registrant
* @param \Drupal\recurring_events_registration\Entity\RegistrantInterface $registrant
* The registrant this email relates to.
* The registrant this email relates to.
*/
*/
function
recurring_events_registration_send_notification
(
$key
,
RegistrantInterface
$registrant
)
{
function
recurring_events_registration_send_notification
(
$key
,
RegistrantInterface
$registrant
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment