public function MailCacheStatic::get in Simplenews 8.2
Same name and namespace in other branches
- 8 src/Mail/MailCacheStatic.php \Drupal\simplenews\Mail\MailCacheStatic::get()
- 3.x src/Mail/MailCacheStatic.php \Drupal\simplenews\Mail\MailCacheStatic::get()
Return a cached element, if existing.
Although group and key can be used to identify the requested cache, the implementations are responsible to create a unique cache key themself using the $mail. For example based on the node id and the language.
Parameters
\Drupal\simplenews\Mail\MailInterface $mail: The mail object.
string $group: Group of the cache key, which allows cache implementations to decide what they want to cache. Currently used groups:
- data: Raw data, e.g. attachments.
- build: Built and themed content, before personalizations like tokens.
- final: The final returned data. Caching this means that newsletter can not be personalized anymore.
string $key: Identifies the requested element, e.g. body or attachments.
Return value
mixed The cached data or NULL.
Overrides MailCacheInterface::get
File
- src/
Mail/ MailCacheStatic.php, line 39
Class
- MailCacheStatic
- Abstract implementation of the mail caching that does static caching.
Namespace
Drupal\simplenews\MailCode
public function get(MailInterface $mail, $group, $key) {
if (!$this
->isCacheable($mail, $group, $key)) {
return NULL;
}
if (isset($this->cache[$this
->getCid($mail)][$group][$key])) {
return $this->cache[$this
->getCid($mail)][$group][$key];
}
}