You are here

function lightning_scheduler_entity_base_field_info in Lightning Scheduler 8

Implements hook_entity_base_field_info().

File

./lightning_scheduler.module, line 83

Code

function lightning_scheduler_entity_base_field_info(EntityTypeInterface $entity_type) {
  $fields = [];

  /** @var \Drupal\content_moderation\ModerationInformationInterface $moderation_info */
  $moderation_info = Drupal::service('content_moderation.moderation_information');
  if ($moderation_info
    ->canModerateEntitiesOfEntityType($entity_type)) {
    $fields['scheduled_transition_date'] = BaseFieldDefinition::create('datetime')
      ->setDisplayConfigurable('view', FALSE)
      ->setDisplayConfigurable('form', FALSE)
      ->setLabel(t('Scheduled transition date'))
      ->setTranslatable(TRUE)
      ->setRevisionable(TRUE)
      ->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
    $fields['scheduled_transition_state'] = BaseFieldDefinition::create('string')
      ->setDisplayConfigurable('view', FALSE)
      ->setDisplayConfigurable('form', FALSE)
      ->setLabel(t('Scheduled transition state'))
      ->setTranslatable(TRUE)
      ->setRevisionable(TRUE)
      ->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
  }
  return $fields;
}