public function CourseEnrollmentEntityForm::submitForm in Course 3.x
Update the timestamp on submission by user.
Overrides ContentEntityForm::submitForm
File
- src/
Form/ CourseEnrollmentEntityForm.php, line 14
Class
Namespace
Drupal\course\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
$account = \Drupal::currentUser();
if ($account
->id() == $this->entity
->getUser()
->id()) {
// Only update start time if this belongs to the current user.
if ($this->entity
->get('timestamp')
->isEmpty()) {
\Drupal::messenger()
->addStatus(t('Your enrollment in this course has been recorded.'));
}
$this->entity
->set('timestamp', \Drupal::time()
->getRequestTime());
}
}