function scheduler_entity_base_field_info in Scheduler 8
Same name and namespace in other branches
- 2.x scheduler.module \scheduler_entity_base_field_info()
Implements hook_entity_base_field_info().
File
- ./
scheduler.module, line 359 - Scheduler publishes and unpublishes nodes on dates specified by the user.
Code
function scheduler_entity_base_field_info(EntityTypeInterface $entity_type) {
$fields = [];
if ($entity_type
->id() === 'node') {
$fields['publish_on'] = BaseFieldDefinition::create('timestamp')
->setLabel(t('Publish on'))
->setDisplayOptions('form', [
'type' => 'datetime_timestamp_no_default',
'weight' => 30,
])
->setDisplayConfigurable('form', TRUE)
->setTranslatable(TRUE)
->setRevisionable(TRUE)
->addConstraint('SchedulerPublishOn');
$fields['unpublish_on'] = BaseFieldDefinition::create('timestamp')
->setLabel(t('Unpublish on'))
->setDisplayOptions('form', [
'type' => 'datetime_timestamp_no_default',
'weight' => 30,
])
->setDisplayConfigurable('form', TRUE)
->setTranslatable(TRUE)
->setRevisionable(TRUE)
->addConstraint('SchedulerUnpublishOn');
return $fields;
}
}