Last active
September 17, 2017 00:36
-
-
Save ahebrank/8b6d3136686432484f19aefecef5bcf8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/content_moderation_notifications.services.yml b/content_moderation_notifications.services.yml | |
| index 5b2d342..2a6b525 100644 | |
| --- a/content_moderation_notifications.services.yml | |
| +++ b/content_moderation_notifications.services.yml | |
| @@ -4,4 +4,4 @@ services: | |
| arguments: ['@entity_type.manager', '@content_moderation.moderation_information'] | |
| content_moderation_notifications.notification: | |
| class: Drupal\content_moderation_notifications\Notification | |
| - arguments: ['@plugin.manager.mail'] | |
| + arguments: ['@plugin.manager.mail', '@?token.entity_mapper'] | |
| diff --git a/src/Notification.php b/src/Notification.php | |
| index 3c7e2cd..7ea2ff0 100644 | |
| --- a/src/Notification.php | |
| +++ b/src/Notification.php | |
| @@ -4,6 +4,7 @@ namespace Drupal\content_moderation_notifications; | |
| use Drupal\Core\Entity\EntityInterface; | |
| use Drupal\Core\Mail\MailManager; | |
| +use Drupal\token\TokenEntityMapperInterface; | |
| /** | |
| * General service for moderation-related questions about Entity API. | |
| @@ -18,13 +19,21 @@ class Notification implements NotificationInterface { | |
| protected $mailManager; | |
| /** | |
| + * @var \Drupal\token\TokenEntityMapperInterface | |
| + */ | |
| + protected $tokenEntityMapper; | |
| + | |
| + /** | |
| * Creates a new ModerationInformation instance. | |
| * | |
| * @param \Drupal\Core\Mail\MailManager $mail_manager | |
| * The mail manager. | |
| + * @param \Drupal\token\TokenEntityMapperInterface $token_entity_mappper | |
| + * The token entity mapper service. | |
| */ | |
| - public function __construct(MailManager $mail_manager) { | |
| + public function __construct(MailManager $mail_manager, TokenEntityMapperInterface $token_entity_mappper = NULL) { | |
| $this->mailManager = $mail_manager; | |
| + $this->tokenEntityMapper = $token_entity_mappper; | |
| } | |
| /** | |
| @@ -44,6 +53,9 @@ class Notification implements NotificationInterface { | |
| 'entity' => $entity, | |
| 'user' => \Drupal::currentUser(), | |
| ]; | |
| + if ($this->tokenEntityMapper) { | |
| + $data['params']['context'][$this->tokenEntityMapper->getTokenTypeForEntityType($entity->getEntityTypeId())] = $entity; | |
| + } | |
| // Figure out who the email should be going to. | |
| $data['to'] = []; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment