class SchemaItemListElementBase in Schema.org Metatag 7
All Schema.org itemListElement tags should extend this class.
Hierarchy
- class \DrupalDefaultMetaTag implements DrupalMetaTagInterface
- class \DrupalTextMetaTag
- class \SchemaNameBase implements SchemaMetatagTestTagInterface
- class \SchemaItemListElementBase
- class \SchemaNameBase implements SchemaMetatagTestTagInterface
- class \DrupalTextMetaTag
Expanded class hierarchy of SchemaItemListElementBase
File
- src/
SchemaItemListElementBase.php, line 6
View source
class SchemaItemListElementBase extends SchemaNameBase {
/**
* {@inheritdoc}
*/
public function getForm(array $options = []) {
$form = parent::getForm($options);
$form['value']['#description'] = $this
->t('To create a list, provide a token for a multiple value field, or a comma-separated list of values.');
return $form;
}
/**
* {@inheritdoc}
*/
public static function outputValue($input_value) {
$items = [];
$values = static::getItems($input_value);
if (!empty($values) && is_array($values)) {
foreach ($values as $key => $value) {
// Complex arrays of values are displayed as ListItem objects, otherwise
// values are presented in a simple list.
if (is_array($value)) {
// Maps to Google all-in-one page view.
if (array_key_exists('@type', $value)) {
$items[] = [
'@type' => 'ListItem',
'position' => $key,
'item' => $value,
];
}
elseif (array_key_exists('url', $value)) {
$items[] = [
'@type' => 'ListItem',
'position' => $key,
'url' => $value['url'],
];
}
elseif (array_key_exists('name', $value) && array_key_exists('item', $value)) {
$items[] = [
'@type' => 'ListItem',
'position' => $key,
'name' => $value['name'],
'item' => $value['item'],
];
}
}
else {
$items[] = $value;
}
}
}
return $items;
}
/**
* Process the input value into an array of items.
*
* Each type of ItemList can extend this to process the input value into a
* list of items. The default behavior will be a simple array from a
* comma-separated list.
*/
public static function getItems($input_value) {
if (!is_array($input_value)) {
$input_value = SchemaMetatagManager::explode($input_value);
}
return $input_value;
}
/**
* {@inheritdoc}
*/
public static function testValue() {
return static::testDefaultValue(3, ',');
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DrupalDefaultMetaTag:: |
protected | property | The values submitted for this tag. | |
DrupalDefaultMetaTag:: |
protected | property | All of the basic information about this tag. | |
DrupalDefaultMetaTag:: |
protected | property | This item's weight; used for sorting the output. | |
DrupalDefaultMetaTag:: |
protected | function | Make sure a given URL is absolute. | |
DrupalDefaultMetaTag:: |
public | function |
Calculate the weight of this meta tag. Overrides DrupalMetaTagInterface:: |
|
DrupalDefaultMetaTag:: |
protected | function | Identify the maximum length of which strings will be allowed. | |
DrupalDefaultMetaTag:: |
public static | function |
Copied from text.module with the following changes:. Overrides DrupalMetaTagInterface:: |
|
DrupalDefaultMetaTag:: |
protected | function | Remove unwanted formatting from a meta tag. | |
DrupalDefaultMetaTag:: |
protected | function | Shorten a string to a certain length using ::textSummary(). | |
DrupalTextMetaTag:: |
public | function |
Get the string value of this meta tag. Overrides DrupalDefaultMetaTag:: |
1 |
SchemaItemListElementBase:: |
public | function |
Build the form for this meta tag. Overrides SchemaNameBase:: |
2 |
SchemaItemListElementBase:: |
public static | function | Process the input value into an array of items. | 2 |
SchemaItemListElementBase:: |
public static | function |
Transform input value to its display output. Overrides SchemaNameBase:: |
1 |
SchemaItemListElementBase:: |
public static | function |
Provide a test input value for the property that will validate. Overrides SchemaNameBase:: |
2 |
SchemaNameBase:: |
protected | property | The schemaMetatagManager service. | |
SchemaNameBase:: |
public | function | ||
SchemaNameBase:: |
public | function |
Get the HTML tag for this meta tag. Overrides DrupalDefaultMetaTag:: |
1 |
SchemaNameBase:: |
public | function | ||
SchemaNameBase:: |
public | function | ||
SchemaNameBase:: |
public | function | ||
SchemaNameBase:: |
public static | function | Nested elements that cannot be exploded. | |
SchemaNameBase:: |
public static | function | ||
SchemaNameBase:: |
public static | function |
Provide a test output value for the input value. Overrides SchemaMetatagTestTagInterface:: |
17 |
SchemaNameBase:: |
protected | function | Process an individual item. | |
SchemaNameBase:: |
public static | function |
Explode a test value. Overrides SchemaMetatagTestTagInterface:: |
|
SchemaNameBase:: |
public static | function |
Random absolute url for testing. Overrides SchemaMetatagTestTagInterface:: |
|
SchemaNameBase:: |
protected | function | Return the SchemaMetatagManager. | |
SchemaNameBase:: |
public | function | ||
SchemaNameBase:: |
public static | function |
Provide a random test value. Overrides SchemaMetatagTestTagInterface:: |
|
SchemaNameBase:: |
public | function | ||
SchemaNameBase:: |
protected | function | The #states visibility selector for this element. | |
SchemaNameBase:: |
function |
Constructor. Overrides DrupalDefaultMetaTag:: |
1 |