class SchemaOfferBase in Schema.org Metatag 7
Provides a plugin for the 'schema_offer_base' meta tag.
Hierarchy
- class \DrupalDefaultMetaTag implements DrupalMetaTagInterface
- class \DrupalTextMetaTag
- class \SchemaNameBase implements SchemaMetatagTestTagInterface
- class \SchemaOfferBase uses SchemaOfferTrait
- class \SchemaNameBase implements SchemaMetatagTestTagInterface
- class \DrupalTextMetaTag
Expanded class hierarchy of SchemaOfferBase
5 string references to 'SchemaOfferBase'
- SchemaActionTrait::actionProperties in src/
SchemaActionTrait.php - Return an array of the unique properties for an action type.
- schema_event_metatag_info in schema_event/
schema_event.metatag.inc - Implements hook_metatag_info().
- schema_metatag_test_metatag_info in tests/
schema_metatag_test.metatag.inc - Implements hook_metatag_info().
- schema_product_metatag_info in schema_product/
schema_product.metatag.inc - Implements hook_metatag_info().
- schema_service_metatag_info in schema_service/
schema_service.metatag.inc - Implements hook_metatag_info().
File
- src/
SchemaOfferBase.php, line 6
View source
class SchemaOfferBase extends SchemaNameBase {
use SchemaOfferTrait;
/**
* {@inheritdoc}
*/
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
->offerForm($input_values);
if (empty($this
->multiple())) {
unset($form['value']['pivot']);
}
// Validation from parent::getForm() got wiped out, so add callback.
$form['value']['#element_validate'][] = 'schema_metatag_element_validate';
return $form;
}
/**
* {@inheritdoc}
*/
public static function testValue() {
$items = [];
$keys = [
'@type',
'@id',
'price',
'priceCurrency',
'lowPrice',
'highPrice',
'offerCount',
'url',
'availability',
'availabilityStarts',
'availabilityEnds',
'itemCondition',
'validFrom',
'category',
'eligibleRegion',
'ineligibleRegion',
'priceValidUntil',
];
foreach ($keys as $key) {
switch ($key) {
case '@type':
$items[$key] = 'Offer';
break;
case 'eligibleRegion':
case 'ineligibleRegion':
$items[$key] = SchemaCountryBase::testValue();
break;
default:
$items[$key] = parent::testDefaultValue(2, ' ');
break;
}
}
return $items;
}
/**
* {@inheritdoc}
*/
public static function processedTestValue($items) {
foreach ($items as $key => $value) {
switch ($key) {
case 'eligibleRegion':
case 'ineligibleRegion':
$items[$key] = SchemaCountryBase::processedTestValue($items[$key]);
break;
}
}
return $items;
}
}
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 |
SchemaCountryTrait:: |
public | function | The form element. | |
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 |
Transform input value to its display output. Overrides SchemaMetatagTestTagInterface:: |
2 |
SchemaNameBase:: |
public static | function | ||
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:: |
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 | |
SchemaOfferBase:: |
public | function |
Build the form for this meta tag. Overrides SchemaNameBase:: |
|
SchemaOfferBase:: |
public static | function |
Provide a test output value for the input value. Overrides SchemaNameBase:: |
|
SchemaOfferBase:: |
public static | function |
Provide a test input value for the property that will validate. Overrides SchemaNameBase:: |
|
SchemaOfferTrait:: |
public | function | The form element. | |
SchemaOfferTrait:: |
abstract protected | function |
Return the SchemaMetatagManager. Overrides SchemaCountryTrait:: |