You are here

public function Immediately::processItem in Open Social 10.1.x

Same name and namespace in other branches
  1. 8.9 modules/custom/activity_send/modules/activity_send_email/src/Plugin/EmailFrequency/Immediately.php \Drupal\activity_send_email\Plugin\EmailFrequency\Immediately::processItem()
  2. 8 modules/custom/activity_send/modules/activity_send_email/src/Plugin/EmailFrequency/Immediately.php \Drupal\activity_send_email\Plugin\EmailFrequency\Immediately::processItem()
  3. 8.2 modules/custom/activity_send/modules/activity_send_email/src/Plugin/EmailFrequency/Immediately.php \Drupal\activity_send_email\Plugin\EmailFrequency\Immediately::processItem()
  4. 8.3 modules/custom/activity_send/modules/activity_send_email/src/Plugin/EmailFrequency/Immediately.php \Drupal\activity_send_email\Plugin\EmailFrequency\Immediately::processItem()
  5. 8.4 modules/custom/activity_send/modules/activity_send_email/src/Plugin/EmailFrequency/Immediately.php \Drupal\activity_send_email\Plugin\EmailFrequency\Immediately::processItem()
  6. 8.5 modules/custom/activity_send/modules/activity_send_email/src/Plugin/EmailFrequency/Immediately.php \Drupal\activity_send_email\Plugin\EmailFrequency\Immediately::processItem()
  7. 8.6 modules/custom/activity_send/modules/activity_send_email/src/Plugin/EmailFrequency/Immediately.php \Drupal\activity_send_email\Plugin\EmailFrequency\Immediately::processItem()
  8. 8.7 modules/custom/activity_send/modules/activity_send_email/src/Plugin/EmailFrequency/Immediately.php \Drupal\activity_send_email\Plugin\EmailFrequency\Immediately::processItem()
  9. 8.8 modules/custom/activity_send/modules/activity_send_email/src/Plugin/EmailFrequency/Immediately.php \Drupal\activity_send_email\Plugin\EmailFrequency\Immediately::processItem()
  10. 10.3.x modules/custom/activity_send/modules/activity_send_email/src/Plugin/EmailFrequency/Immediately.php \Drupal\activity_send_email\Plugin\EmailFrequency\Immediately::processItem()
  11. 10.0.x modules/custom/activity_send/modules/activity_send_email/src/Plugin/EmailFrequency/Immediately.php \Drupal\activity_send_email\Plugin\EmailFrequency\Immediately::processItem()
  12. 10.2.x modules/custom/activity_send/modules/activity_send_email/src/Plugin/EmailFrequency/Immediately.php \Drupal\activity_send_email\Plugin\EmailFrequency\Immediately::processItem()

Processes an activity item.

Parameters

\Drupal\activity_creator\Entity\Activity $activity: The Activity object.

\Drupal\message\Entity\Message $message: The Message object.

\Drupal\user\Entity\User $target: The target user account.

string|null $body_text: The output text of message.

Overrides EmailFrequencyBase::processItem

File

modules/custom/activity_send/modules/activity_send_email/src/Plugin/EmailFrequency/Immediately.php, line 28

Class

Immediately
Define a concrete class for immediate emails.

Namespace

Drupal\activity_send_email\Plugin\EmailFrequency

Code

public function processItem(Activity $activity, Message $message, User $target, $body_text = NULL) {

  // If the user is blocked, we don't want to process this item further.
  if ($target
    ->isBlocked()) {
    return;
  }

  // Continue if we have text to send and the user is currently offline.
  if (isset($activity->field_activity_output_text) && EmailActivityDestination::isUserOffline($target)) {
    $langcode = $target
      ->getPreferredLangcode();

    // If no body text is provided, get it from message for given language.
    if (!$body_text) {
      $body_text = EmailActivityDestination::getSendEmailOutputText($message, $langcode);
    }
    if ($langcode && !empty($body_text)) {
      $this
        ->sendEmail($body_text, $langcode, $target);
    }
  }
}