You are here

public function ShareMessage::getTokenizedField in Share Message 8

Tokenizes a field, if it is set.

Parameters

string $property_value: A field value.

array $context: A context array for Token::replace().

string $default: (optional) Default value if field value is not set.

Return value

string If existent, the field value with tokens replace, the default otherwise.

Overrides ShareMessageInterface::getTokenizedField

4 calls to ShareMessage::getTokenizedField()
ShareMessage::buildOGTags in src/Entity/ShareMessage.php
Returns Open Graph meta tags for <head>.
ShareMessage::buildTwitterCardTags in src/Entity/ShareMessage.php
Adds meta tags in order to share images on Twitter.
ShareMessage::getImageUrl in src/Entity/ShareMessage.php
Gets the image url of the ShareMessage.
ShareMessage::getUrl in src/Entity/ShareMessage.php
Gets the Share Message URL.

File

src/Entity/ShareMessage.php, line 467

Class

ShareMessage
Entity class for the Share Message entity.

Namespace

Drupal\sharemessage\Entity

Code

public function getTokenizedField($property_value, $context, $default = '') {
  if ($property_value) {
    return strip_tags(PlainTextOutput::renderFromHtml(\Drupal::token()
      ->replace($property_value, $context, [
      'clear' => TRUE,
    ])));
  }
  return $default;
}