SchemaDurationBase.php in Schema.org Metatag 8
File
src/Plugin/metatag/Tag/SchemaDurationBase.php
View source
<?php
namespace Drupal\schema_metatag\Plugin\metatag\Tag;
class SchemaDurationBase extends SchemaNameBase {
public function output() {
$element = parent::output();
if (!empty($element)) {
$input_value = $element['#attributes']['content'];
$element['#attributes']['content'] = static::outputValue($input_value);
}
return $element;
}
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;
}
}