function scheduler_entity_base_field_info in Scheduler 2.x
Same name and namespace in other branches
- 8 scheduler.module \scheduler_entity_base_field_info()
Implements hook_entity_base_field_info().
1 call to scheduler_entity_base_field_info()
- SchedulerManager::entityUpdate in src/
SchedulerManager.php - Updates db tables for entities that should have the Scheduler fields.
File
- ./
scheduler.module, line 607 - Scheduler publishes and unpublishes entities on dates specified by the user.
Code
function scheduler_entity_base_field_info(EntityTypeInterface $entity_type) {
$fields = [];
$entity_types = \Drupal::service('scheduler.manager')
->getPluginEntityTypes();
if (in_array($entity_type
->id(), $entity_types)) {
$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;
}
}