Loading mail.info.yml +1 −1 Original line number Diff line number Diff line name: Mail description: Provides a config entity for emails sent by the site. type: module core: 8.x core_version_requirement: ^9 package: Mail mail_example/mail_example.module +6 −3 Original line number Diff line number Diff line <?php use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Access\AccessResult; /** * @file * Provides a working example of a module using Mail. */ /** * Implements hook_ENTITY_TYPE_access(). */ function mail_example_mail_message_access(\Drupal\Core\Entity\EntityInterface $entity, $operation, \Drupal\Core\Session\AccountInterface $account) { function mail_example_mail_message_access(EntityInterface $entity, $operation, AccountInterface $account) { // Allow access to messages in our group. if ($entity->group == 'mail_example') { return \Drupal\Core\Access\AccessResult::allowedIfHasPermission($account, 'edit mail_example mails'); return AccessResult::allowedIfHasPermission($account, 'edit mail_example mails'); } } src/EntityMailer.php +1 −1 Original line number Diff line number Diff line Loading @@ -152,7 +152,7 @@ class EntityMailer implements EntityMailerInterface { '%to' => $message['to'], '%reply' => $message['reply-to'] ? $message['reply-to'] : $this->t('not set'), )); drupal_set_message($this->t('Unable to send email. Contact the site administrator if the problem persists.'), 'error'); \Drupal::messenger()->addError($this->t('Unable to send email. Contact the site administrator if the problem persists.')); } } Loading src/Form/MailMessageForm.php +3 −3 Original line number Diff line number Diff line Loading @@ -105,17 +105,17 @@ class MailMessageForm extends EntityForm { switch ($status) { case SAVED_NEW: drupal_set_message($this->t('Created the %label mail message.', [ $this->messenger()->addStatus($this->t('Created the %label mail message.', [ '%label' => $mail_message->label(), ])); break; default: drupal_set_message($this->t('Saved the %label mail message.', [ $this->messenger()->addStatus($this->t('Saved the %label mail message.', [ '%label' => $mail_message->label(), ])); } $form_state->setRedirectUrl($mail_message->urlInfo('collection')); $form_state->setRedirectUrl($mail_message->toUrl('collection')); } } src/MailMessageGroupListController.php +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ class MailMessageGroupListController extends ControllerBase { * A render array as expected by drupal_render(). */ public function listing($group) { $list_builder = $this->entityManager()->getListBuilder('mail_message'); $list_builder = $this->entityTypeManager()->getListBuilder('mail_message'); $list_builder->setGroup($group); $list_builder->setRedirect($this->getDestinationArray()); Loading Loading
mail.info.yml +1 −1 Original line number Diff line number Diff line name: Mail description: Provides a config entity for emails sent by the site. type: module core: 8.x core_version_requirement: ^9 package: Mail
mail_example/mail_example.module +6 −3 Original line number Diff line number Diff line <?php use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Access\AccessResult; /** * @file * Provides a working example of a module using Mail. */ /** * Implements hook_ENTITY_TYPE_access(). */ function mail_example_mail_message_access(\Drupal\Core\Entity\EntityInterface $entity, $operation, \Drupal\Core\Session\AccountInterface $account) { function mail_example_mail_message_access(EntityInterface $entity, $operation, AccountInterface $account) { // Allow access to messages in our group. if ($entity->group == 'mail_example') { return \Drupal\Core\Access\AccessResult::allowedIfHasPermission($account, 'edit mail_example mails'); return AccessResult::allowedIfHasPermission($account, 'edit mail_example mails'); } }
src/EntityMailer.php +1 −1 Original line number Diff line number Diff line Loading @@ -152,7 +152,7 @@ class EntityMailer implements EntityMailerInterface { '%to' => $message['to'], '%reply' => $message['reply-to'] ? $message['reply-to'] : $this->t('not set'), )); drupal_set_message($this->t('Unable to send email. Contact the site administrator if the problem persists.'), 'error'); \Drupal::messenger()->addError($this->t('Unable to send email. Contact the site administrator if the problem persists.')); } } Loading
src/Form/MailMessageForm.php +3 −3 Original line number Diff line number Diff line Loading @@ -105,17 +105,17 @@ class MailMessageForm extends EntityForm { switch ($status) { case SAVED_NEW: drupal_set_message($this->t('Created the %label mail message.', [ $this->messenger()->addStatus($this->t('Created the %label mail message.', [ '%label' => $mail_message->label(), ])); break; default: drupal_set_message($this->t('Saved the %label mail message.', [ $this->messenger()->addStatus($this->t('Saved the %label mail message.', [ '%label' => $mail_message->label(), ])); } $form_state->setRedirectUrl($mail_message->urlInfo('collection')); $form_state->setRedirectUrl($mail_message->toUrl('collection')); } }
src/MailMessageGroupListController.php +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ class MailMessageGroupListController extends ControllerBase { * A render array as expected by drupal_render(). */ public function listing($group) { $list_builder = $this->entityManager()->getListBuilder('mail_message'); $list_builder = $this->entityTypeManager()->getListBuilder('mail_message'); $list_builder->setGroup($group); $list_builder->setRedirect($this->getDestinationArray()); Loading