SchemaContactPointBase.php in Schema.org Metatag 7
File
src/SchemaContactPointBase.php
View source
<?php
class SchemaContactPointBase extends SchemaNameBase {
use SchemaContactPointTrait;
public function getForm(array $options = []) {
$value = $this
->schemaMetatagManager()
->unserialize($this
->value());
$input_values = [
'title' => $this
->label(),
'description' => $this
->description(),
'value' => $value,
'#required' => isset($options['#required']) ? $options['#required'] : FALSE,
'visibility_selector' => $this
->visibilitySelector(),
];
$form['value'] = $this
->contactPointForm($input_values);
if (empty($this
->multiple())) {
unset($form['value']['pivot']);
}
$form['value']['#element_validate'][] = 'schema_metatag_element_validate';
return $form;
}
public static function testValue() {
$items = [];
$keys = [
'@type',
'areaServed',
'availableLanguage',
'contactType',
'contactOption',
'email',
'faxnumber',
'productSupported',
'telephone',
'url',
];
foreach ($keys as $key) {
switch ($key) {
case '@type':
$items[$key] = 'ContactPoint';
break;
case 'areaServed':
$items[$key] = SchemaPlaceBase::testValue();
break;
default:
$items[$key] = parent::testDefaultValue(1, '');
break;
}
}
return $items;
}
}