class WishlistShareMail in Commerce Wishlist 8.3
Defines the wishlist share email.
Hierarchy
- class \Drupal\commerce_wishlist\Mail\WishlistShareMail implements WishlistShareMailInterface uses StringTranslationTrait
 
Expanded class hierarchy of WishlistShareMail
1 string reference to 'WishlistShareMail'
1 service uses WishlistShareMail
File
- src/
Mail/ WishlistShareMail.php, line 13  
Namespace
Drupal\commerce_wishlist\MailView source
class WishlistShareMail implements WishlistShareMailInterface {
  use StringTranslationTrait;
  /**
   * The config factory.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;
  /**
   * The commerce mail handler.
   *
   * @var \Drupal\commerce\MailHandlerInterface
   */
  protected $mailHandler;
  /**
   * Constructs a new WishlistShareMail object.
   *
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   The configuration factory.
   * @param \Drupal\commerce\MailHandlerInterface $mail_handler
   *   The mail handler.
   */
  public function __construct(ConfigFactoryInterface $config_factory, MailHandlerInterface $mail_handler) {
    $this->configFactory = $config_factory;
    $this->mailHandler = $mail_handler;
  }
  /**
   * {@inheritdoc}
   */
  public function send(WishlistInterface $wishlist, $to) {
    $owner = $wishlist
      ->getOwner();
    if (!$owner || $owner
      ->isAnonymous()) {
      // Only wishlists belonging to authenticated users can be shared.
      return FALSE;
    }
    $subject = $this
      ->t('Check out my @site-name wishlist', [
      '@site-name' => $this->configFactory
        ->get('system.site')
        ->get('name'),
    ]);
    $body = [
      '#theme' => 'commerce_wishlist_share_mail',
      '#wishlist_entity' => $wishlist,
    ];
    $params = [
      'id' => 'wishlist_share',
      'from' => $owner
        ->getEmail(),
      'wishlist' => $wishlist,
    ];
    return $this->mailHandler
      ->sendMail($to, $subject, $body, $params);
  }
}Members
| 
            Name | 
                  Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| 
            StringTranslationTrait:: | 
                  protected | property | The string translation service. | 1 | 
| 
            StringTranslationTrait:: | 
                  protected | function | Formats a string containing a count of items. | |
| 
            StringTranslationTrait:: | 
                  protected | function | Returns the number of plurals supported by a given language. | |
| 
            StringTranslationTrait:: | 
                  protected | function | Gets the string translation service. | |
| 
            StringTranslationTrait:: | 
                  public | function | Sets the string translation service to use. | 2 | 
| 
            StringTranslationTrait:: | 
                  protected | function | Translates a string to the current language or to a given language. | |
| 
            WishlistShareMail:: | 
                  protected | property | The config factory. | |
| 
            WishlistShareMail:: | 
                  protected | property | The commerce mail handler. | |
| 
            WishlistShareMail:: | 
                  public | function | 
            Sends the wishlist share email to the given address. Overrides WishlistShareMailInterface:: | 
                  |
| 
            WishlistShareMail:: | 
                  public | function | Constructs a new WishlistShareMail object. |