Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
Notificator Class Reference
Inheritance diagram for Notificator:
NotificatorInterface

Public Member Functions

 __construct (TransportBuilder $transportBuilder, ConfigInterface $config, DeploymentConfig $deployConfig, StoreManagerInterface $storeManager)
 
 sendForgotPassword (UserInterface $user)
 
 sendCreated (UserInterface $user)
 
 sendUpdated (UserInterface $user, array $changed)
 

Detailed Description

@inheritDoc

@SuppressWarnings(PHPMD.CouplingBetweenObjects)

Definition at line 28 of file Notificator.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( TransportBuilder  $transportBuilder,
ConfigInterface  $config,
DeploymentConfig  $deployConfig,
StoreManagerInterface  $storeManager 
)
Parameters
TransportBuilder$transportBuilder
ConfigInterface$config
DeploymentConfig$deployConfig
StoreManagerInterface$storeManager

Definition at line 56 of file Notificator.php.

61  {
62  $this->transportBuilder = $transportBuilder;
63  $this->config = $config;
64  $this->deployConfig = $deployConfig;
65  $this->storeManager = $storeManager;
66  }
$config
Definition: fraud_order.php:17
$storeManager
$deployConfig

Member Function Documentation

◆ sendCreated()

sendCreated ( UserInterface  $user)

@inheritDoc

Implements NotificatorInterface.

Definition at line 129 of file Notificator.php.

129  : void
130  {
131  $toEmails = [];
132  $generalEmail = $this->config->getValue(
133  'trans_email/ident_general/email'
134  );
135  if ($generalEmail) {
136  $toEmails[] = $generalEmail;
137  }
138  if ($adminEmail = $this->deployConfig->get('user_admin_email')) {
139  $toEmails[] = $adminEmail;
140  }
141 
142  try {
143  foreach ($toEmails as $toEmail) {
144  $this->sendNotification(
145  'admin/emails/new_user_notification_template',
146  [
147  'user' => $user,
148  'store' => $this->storeManager->getStore(
150  )
151  ],
152  $toEmail,
153  __('Administrator')->getText()
154  );
155  }
156  } catch (LocalizedException $exception) {
157  throw new NotificatorException(
158  __($exception->getMessage()),
159  $exception
160  );
161  }
162  }
__()
Definition: __.php:13
$user
Definition: dummy_user.php:13

◆ sendForgotPassword()

sendForgotPassword ( UserInterface  $user)

@inheritDoc

Implements NotificatorInterface.

Definition at line 104 of file Notificator.php.

104  : void
105  {
106  try {
107  $this->sendNotification(
108  'admin/emails/forgot_email_template',
109  [
110  'user' => $user,
111  'store' => $this->storeManager->getStore(
113  )
114  ],
115  $user->getEmail(),
116  $user->getFirstName().' '.$user->getLastName()
117  );
118  } catch (LocalizedException $exception) {
119  throw new NotificatorException(
120  __($exception->getMessage()),
121  $exception
122  );
123  }
124  }
__()
Definition: __.php:13
$user
Definition: dummy_user.php:13

◆ sendUpdated()

sendUpdated ( UserInterface  $user,
array  $changed 
)

@inheritDoc

Implements NotificatorInterface.

Definition at line 167 of file Notificator.php.

167  : void
168  {
169  $email = $user->getEmail();
170  if ($user instanceof User) {
171  $email = $user->getOrigData('email');
172  }
173 
174  try {
175  $this->sendNotification(
176  'admin/emails/user_notification_template',
177  [
178  'user' => $user,
179  'store' => $this->storeManager->getStore(
181  ),
182  'changes' => implode(', ', $changed)
183  ],
184  $email,
185  $user->getFirstName().' '.$user->getLastName()
186  );
187  } catch (LocalizedException $exception) {
188  throw new NotificatorException(
189  __($exception->getMessage()),
190  $exception
191  );
192  }
193  }
$email
Definition: details.phtml:13
__()
Definition: __.php:13
$user
Definition: dummy_user.php:13

The documentation for this class was generated from the following file: