Skip to content

Instantly share code, notes, and snippets.

@dpi
Last active April 15, 2016 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpi/034117caad94e50b1cb36ed3a7d53fd9 to your computer and use it in GitHub Desktop.
Save dpi/034117caad94e50b1cb36ed3a7d53fd9 to your computer and use it in GitHub Desktop.
notifyNeedsReview redux
/**
* Notify the owner of the Job using courier.
*/
private function notifyNeedsReview() {
$template_collection_ids = \Drupal::state()->get('tmgmt_notifications_template_collections', []);
if (isset($template_collection_ids['job_item_needs_review'])) {
$id = $template_collection_ids['job_item_needs_review'];
/** @var \Drupal\courier\TemplateCollectionInterface $template_collection */
$template_collection = TemplateCollection::load($id);
$template_collection->setTokenValue('tmgmt_job_item', $this);
$identity = $this->getJob()->getOwner();
$mqi = \Drupal::service('courier.manager')
->sendMessage($template_collection, $identity);
if ($mqi instanceof MessageQueueItemInterface) {
drupal_set_message(t('Message queued for delivery.'));
}
else {
drupal_set_message(t('Failed to send message'), 'error');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment