DateTimeEnhancerBase.php in JSON:API Extras 8.3
File
src/Plugin/DateTimeEnhancerBase.php
View source
<?php
namespace Drupal\jsonapi_extras\Plugin;
abstract class DateTimeEnhancerBase extends ResourceFieldEnhancerBase {
public function defaultConfiguration() {
return [
'dateTimeFormat' => \DateTime::ISO8601,
];
}
public function getOutputJsonSchema() {
return [
'type' => 'string',
];
}
public function getSettingsForm(array $resource_field_info) {
$settings = empty($resource_field_info['enhancer']['settings']) ? $this
->getConfiguration() : $resource_field_info['enhancer']['settings'];
return [
'dateTimeFormat' => [
'#type' => 'textfield',
'#title' => $this
->t('Format'),
'#description' => $this
->t('Use a valid date format.'),
'#default_value' => $settings['dateTimeFormat'],
],
];
}
}