public function SchemaNameBase::getElement in Schema.org Metatag 7
Get the HTML tag for this meta tag.
Return value
array A render array for this meta tag.
Overrides DrupalDefaultMetaTag::getElement
1 call to SchemaNameBase::getElement()
- SchemaItemListBase::getElement in src/
SchemaItemListBase.php - Get the HTML tag for this meta tag.
1 method overrides SchemaNameBase::getElement()
- SchemaItemListBase::getElement in src/
SchemaItemListBase.php - Get the HTML tag for this meta tag.
File
- src/
SchemaNameBase.php, line 104
Class
- SchemaNameBase
- All Schema.org tags should extend this class.
Code
public function getElement(array $options = array()) {
$this->options = $options;
$value = $this
->schemaMetatagManager()
->unserialize($this
->value());
// If this is a complex array of value, process the array.
if (is_array($value)) {
// Clean out empty values.
$value = $this
->schemaMetatagManager()
->arrayTrim($value);
}
if (empty($value)) {
return '';
}
elseif (is_array($value)) {
// If the item is an array of values,
// walk the array and process the values.
array_walk_recursive($value, 'static::processItem');
// Recursively pivot each branch of the array.
$value = static::pivotItem($value);
}
else {
$this
->processItem($value);
}
$parts = explode('.', $this->info['name']);
$id = 'schema_metatag_' . $this->info['name'];
$element = [
'#type' => 'html_tag',
'#tag' => 'meta',
'#attributes' => [
'schema_metatag' => TRUE,
'group' => $parts[0],
'name' => $parts[1],
'content' => static::outputValue($value),
],
];
return array(
'#attached' => array(
'drupal_add_html_head' => array(
array(
$element,
$id,
),
),
),
);
}