class DateToTimestamp in Open Social 10.3.x
Get the date range as a timestamp.
Plugin annotation
@DataProducer(
id = "date_to_timestamp",
name = @Translation("Date to timestamp"),
description = @Translation("Convert date field object to timestamp."),
produces = @ContextDefinition("int",
label = @Translation("Timestamp")
),
consumes = {
"field" = @ContextDefinition("any",
label = @Translation("The date field")
)
}
)
Hierarchy
- class \Drupal\social_event\Plugin\GraphQL\DataProducer\Field\DateToTimestamp extends \Drupal\graphql\Plugin\GraphQL\DataProducer\DataProducerPluginBase
Expanded class hierarchy of DateToTimestamp
File
- modules/
social_features/ social_event/ src/ Plugin/ GraphQL/ DataProducer/ Field/ DateToTimestamp.php, line 26
Namespace
Drupal\social_event\Plugin\GraphQL\DataProducer\FieldView source
class DateToTimestamp extends DataProducerPluginBase {
/**
* Resolves the request to the requested values.
*
* @param \Drupal\datetime\Plugin\Field\FieldType\DateTimeFieldItemList $field
* The date field object.
*
* @return int|null
* An event start or end day timestamp.
*/
public function resolve(DateTimeFieldItemList $field) {
if ($field
->isEmpty()) {
return NULL;
}
return $field->{DateTimeItem::DATETIME_TYPE_DATE}
->getTimestamp();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DateToTimestamp:: |
public | function | Resolves the request to the requested values. |