class PetHelper in Previewable email templates 8.3
PetHelper.
@package Drupal\pet\Utility
Hierarchy
- class \Drupal\pet\Utility\PetHelper
Expanded class hierarchy of PetHelper
4 files declare their use of PetHelper
- pet.module in ./
pet.module - Previewable Email Template module.
- pet.rules.inc in ./
pet.rules.inc - Rules integration for the Pet module.
- PetForm.php in src/
Form/ PetForm.php - PetPreviewForm.php in src/
Form/ PetPreviewForm.php
File
- src/
Utility/ PetHelper.php, line 13
Namespace
Drupal\pet\UtilityView source
class PetHelper {
/**
* Get token substitutions for given user or node context.
*
* @param array $context
* Context items to be used for token substitutions.
* E.g.:
* [
* 'uid' => NULL,
* 'nid' => 4,
* ]
*
* 'uid' will always be set when preparing data, either the user id matching
* recipient address, or '0' in case of no match.
*
* @return array
* List of substitutions.
*/
public static function getSubstitutions(array $context) {
// Standard substitutions.
$substitutions['global'] = NULL;
if (isset($context['uid'])) {
$user = User::load($context['uid']);
$substitutions['user'] = $user;
}
if (isset($context['nid'])) {
$node = Node::load($context['nid']);
$substitutions['node'] = $node;
}
// Give modules the opportunity to add their own token types/objects.
\Drupal::moduleHandler()
->alter('pet_substitutions', $substitutions);
return $substitutions;
}
/**
* Check if Mime Mail is installed and enabled.
*
* @return bool
* TRUE if enabled.
*/
public static function hasMimeMail() {
return \Drupal::moduleHandler()
->moduleExists('mimemail');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PetHelper:: |
public static | function | Get token substitutions for given user or node context. | |
PetHelper:: |
public static | function | Check if Mime Mail is installed and enabled. |