You are here

public static function SchemaDurationBase::outputValue in Schema.org Metatag 8

Transform input value to its display output.

Tags that need to transform the output to something different than the stored value should extend this method and do the transformation here.

Parameters

mixed $input_value: Input value, could be either a string or array. This will be the unserialized value stored in the tag configuration, after token replacement.

Return value

mixed Return the (possibly expanded) value which will be rendered in JSON-LD.

Overrides SchemaNameBase::outputValue

1 call to SchemaDurationBase::outputValue()
SchemaDurationBase::output in src/Plugin/metatag/Tag/SchemaDurationBase.php
Generate the HTML tag output for a meta tag.

File

src/Plugin/metatag/Tag/SchemaDurationBase.php, line 25

Class

SchemaDurationBase
Provides a plugin for the 'schema_duration_base' meta tag.

Namespace

Drupal\schema_metatag\Plugin\metatag\Tag

Code

public static function outputValue($input_value) {
  $is_integer = ctype_digit($input_value) || is_int($input_value);
  if (!empty($input_value) && $is_integer && $input_value > 0) {
    return 'PT' . $input_value . 'S';
  }
  return $input_value;
}