class TeamInvitationNotifierEmail in Apigee Edge 8
Handles notifications for team_invitation via email.
Hierarchy
- class \Drupal\apigee_edge_teams\TeamInvitationNotifierEmail implements TeamInvitationNotifierInterface
Expanded class hierarchy of TeamInvitationNotifierEmail
1 string reference to 'TeamInvitationNotifierEmail'
- apigee_edge_teams.services.yml in modules/
apigee_edge_teams/ apigee_edge_teams.services.yml - modules/apigee_edge_teams/apigee_edge_teams.services.yml
1 service uses TeamInvitationNotifierEmail
File
- modules/
apigee_edge_teams/ src/ TeamInvitationNotifierEmail.php, line 30
Namespace
Drupal\apigee_edge_teamsView source
class TeamInvitationNotifierEmail implements TeamInvitationNotifierInterface {
/**
* The mail service.
*
* @var \Drupal\Core\Mail\MailManagerInterface
*/
protected $mailManager;
/**
* The language manager.
*
* @var \Drupal\Core\Language\LanguageManagerInterface
*/
protected $languageManager;
/**
* TeamInvitationNotifierEmail constructor.
*
* @param \Drupal\Core\Mail\MailManagerInterface $mail_manager
* The mail service.
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
* The language manager.
*/
public function __construct(MailManagerInterface $mail_manager, LanguageManagerInterface $language_manager) {
$this->mailManager = $mail_manager;
$this->languageManager = $language_manager;
}
/**
* {@inheritdoc}
*/
public function sendNotificationsFor(TeamInvitationInterface $team_invitation) : bool {
$email = $team_invitation
->getRecipient();
$langcode = $this->languageManager
->getDefaultLanguage()
->getId();
$params = [
'team_invitation' => $team_invitation,
'user' => NULL,
];
/** @var \Drupal\user\UserInterface $user */
$user = user_load_by_mail($email);
if ($user) {
$langcode = $user
->getPreferredLangcode();
$params['user'] = $user;
}
// Send email notification.
$message = $this->mailManager
->mail('apigee_edge_teams', 'team_invitation_created', $email, $langcode, $params);
return $message['result'];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
TeamInvitationNotifierEmail:: |
protected | property | The language manager. | |
TeamInvitationNotifierEmail:: |
protected | property | The mail service. | |
TeamInvitationNotifierEmail:: |
public | function |
Sends notification for the provided team_invitation. Overrides TeamInvitationNotifierInterface:: |
|
TeamInvitationNotifierEmail:: |
public | function | TeamInvitationNotifierEmail constructor. |