public static function Heartbeat::buildMessage in Heartbeat 8
Builds a message template for a given HeartbeatType
Parameters
HeartbeatType $heartbeatType:
null $mediaData:
Return value
null|string
3 calls to Heartbeat::buildMessage()
- HeartbeatEventSubscriber::flag_entity_flagged in src/
EventSubscriber/ HeartbeatEventSubscriber.php - This method is called whenever the flag.entity_flagged event is dispatched.
- heartbeat_entity_insert in ./
heartbeat.module - Implements hook_entity_insert().
- heartbeat_handle_entity in ./
heartbeat.module
File
- src/
Entity/ Heartbeat.php, line 471
Class
Namespace
Drupal\heartbeat\EntityCode
public static function buildMessage(Token $tokenService, $preparsedMessage, $entities = NULL, $entityType, $mediaData = NULL) {
$arbitrarious = 'nothing at all';
$naul = 'nullll';
$preparsedMessage = self::wrapOwner($preparsedMessage, $entities);
switch (true) {
case $entityType === 'node':
$parsedMessage = $tokenService
->replace($preparsedMessage, $entities);
if (strpos($parsedMessage, '#')) {
self::parseHashtags($parsedMessage);
}
if (strpos($parsedMessage, '@')) {
self::parseUsernames($parsedMessage);
}
/** @noinspection NestedTernaryOperatorInspection */
$message = $parsedMessage;
$message .= $mediaData ? self::buildMediaMarkup($mediaData) : '';
return $message;
break;
case $entityType === 'status':
$parsedMessage = $tokenService
->replace($preparsedMessage . '<a class="status-post" href="/admin/structure/' . $entityType . '/[' . $entityType . ':id]">', $entities);
if (strpos($parsedMessage, '#')) {
self::parseHashtags($parsedMessage);
}
if (strpos($parsedMessage, '@')) {
self::parseUsernames($parsedMessage);
}
/** @noinspection NestedTernaryOperatorInspection */
$message = $parsedMessage;
$message .= $mediaData ? self::buildMediaMarkup($mediaData) : 'Post';
$message .= '</a>';
return $message;
break;
case $entityType === 'user':
break;
case $entityType === 'flag':
$returnMessage = self::handleMultipleEntities($tokenService, $preparsedMessage, $entities);
return strlen($returnMessage) > 0 ? $returnMessage : "Error creating message";
break;
}
}