Skip to content

Commit 6e82b20

Browse files
author
Oleksandr Gorkun
committed
MAGETWO-92720: E-mail admin users when a new administrator is created.
1 parent 4c3f8af commit 6e82b20

File tree

8 files changed

+18
-14
lines changed

8 files changed

+18
-14
lines changed

app/code/Magento/User/Controller/Adminhtml/Auth/Forgotpassword.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
use Magento\Security\Model\SecurityManager;
1111
use Magento\User\Model\Spi\NotificatorInterface;
1212

13+
/**
14+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
15+
*/
1316
class Forgotpassword extends \Magento\User\Controller\Adminhtml\Auth
1417
{
1518
/**

app/code/Magento/User/Controller/Adminhtml/User/Save.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Magento\Framework\Exception\AuthenticationException;
1010
use Magento\Framework\Exception\State\UserLockedException;
1111
use Magento\Security\Model\SecurityCookie;
12-
use Magento\User\Model\Spi\NotificationException;
12+
use Magento\User\Model\Spi\NotificationExceptionInterface;
1313

1414
/**
1515
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -99,7 +99,7 @@ public function execute()
9999
\Magento\Security\Model\AdminSessionsManager::LOGOUT_REASON_USER_LOCKED
100100
);
101101
$this->_redirect('adminhtml/*/');
102-
} catch (NotificationException $exception) {
102+
} catch (NotificationExceptionInterface $exception) {
103103
$this->messageManager->addErrorMessage($exception->getMessage());
104104
} catch (\Magento\Framework\Exception\AuthenticationException $e) {
105105
$this->messageManager->addError(

app/code/Magento/User/Model/Notificator.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@
1818
use Magento\Framework\Mail\Template\TransportBuilder;
1919
use Magento\Framework\App\DeploymentConfig;
2020
use Magento\Backend\App\Area\FrontNameResolver;
21+
use Magento\Email\Model\BackendTemplate;
2122

2223
/**
2324
* @inheritDoc
25+
*
26+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2427
*/
2528
class Notificator implements NotificatorInterface
2629
{
@@ -81,7 +84,7 @@ private function sendNotification(
8184
): void {
8285
$transport = $this->transportBuilder
8386
->setTemplateIdentifier($this->config->getValue($templateConfigId))
84-
->setTemplateModel(\Magento\Email\Model\BackendTemplate::class)
87+
->setTemplateModel(BackendTemplate::class)
8588
->setTemplateOptions([
8689
'area' => FrontNameResolver::AREA_CODE,
8790
'store' => Store::DEFAULT_STORE_ID
@@ -188,5 +191,4 @@ public function sendUpdated(UserInterface $user, array $changed): void
188191
);
189192
}
190193
}
191-
192194
}

app/code/Magento/User/Model/NotificatorException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
namespace Magento\User\Model;
1010

1111
use Magento\Framework\Exception\MailException;
12-
use Magento\User\Model\Spi\NotificationException;
12+
use Magento\User\Model\Spi\NotificationExceptionInterface;
1313

1414
/**
1515
* When notificator cannot send an email.
1616
*/
17-
class NotificatorException extends MailException implements NotificationException
17+
class NotificatorException extends MailException implements NotificationExceptionInterface
1818
{
1919

2020
}

app/code/Magento/User/Model/Spi/NotificationException.php renamed to app/code/Magento/User/Model/Spi/NotificationExceptionInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/**
1212
* When a notification cannot be sent.
1313
*/
14-
interface NotificationException extends \Throwable
14+
interface NotificationExceptionInterface extends \Throwable
1515
{
1616

1717
}

app/code/Magento/User/Model/Spi/NotificatorInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ interface NotificatorInterface
1919
* Send notification when a user requests password reset.
2020
*
2121
* @param UserInterface $user User that requested password reset.
22-
* @throws NotificationException
22+
* @throws NotificationExceptionInterface
2323
*
2424
* @return void
2525
*/
@@ -29,7 +29,7 @@ public function sendForgotPassword(UserInterface $user): void;
2929
* Send a notification when a new user is created.
3030
*
3131
* @param UserInterface $user The new user.
32-
* @throws NotificationException
32+
* @throws NotificationExceptionInterface
3333
*
3434
* @return void
3535
*/
@@ -40,7 +40,7 @@ public function sendCreated(UserInterface $user): void;
4040
*
4141
* @param UserInterface $user The user updated.
4242
* @param string[] List of changed properties.
43-
* @throws NotificationException
43+
* @throws NotificationExceptionInterface
4444
*
4545
* @return void
4646
*/

app/code/Magento/User/Model/User.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use Magento\Framework\Exception\AuthenticationException;
1313
use Magento\Framework\Serialize\Serializer\Json;
1414
use Magento\User\Api\Data\UserInterface;
15-
use Magento\User\Model\Spi\NotificationException;
15+
use Magento\User\Model\Spi\NotificationExceptionInterface;
1616
use Magento\User\Model\Spi\NotificatorInterface;
1717

1818
/**
@@ -446,7 +446,7 @@ public function sendPasswordResetNotificationEmail()
446446
/**
447447
* Check changes and send notification emails.
448448
*
449-
* @throws NotificationException
449+
* @throws NotificationExceptionInterface
450450
* @return $this
451451
* @since 100.1.0
452452
*/
@@ -495,7 +495,7 @@ protected function createChangesDescriptionString()
495495
*
496496
* @param string $changes
497497
* @param string $email
498-
* @throws NotificationException
498+
* @throws NotificationExceptionInterface
499499
* @return $this
500500
* @since 100.1.0
501501
* @deprecated

app/code/Magento/User/Test/Unit/Model/UserTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ protected function setUp()
4444
);
4545
}
4646

47-
4847
/**
4948
* @return void
5049
*/

0 commit comments

Comments
 (0)