public function CommentFormController::buildEntity

Overrides EntityFormController::buildEntity().

Overrides EntityFormControllerNG::buildEntity

File

drupal/core/modules/comment/lib/Drupal/comment/CommentFormController.php, line 245
Definition of Drupal\comment\CommentFormController.

Class

CommentFormController
Base for controller for comment forms.

Namespace

Drupal\comment

Code

public function buildEntity(array $form, array &$form_state) {
  $comment = parent::buildEntity($form, $form_state);
  if (!empty($form_state['values']['date']) && $form_state['values']['date'] instanceof DrupalDateTime) {
    $comment->created->value = $form_state['values']['date']
      ->getTimestamp();
  }
  else {
    $comment->created->value = REQUEST_TIME;
  }
  $comment->changed->value = REQUEST_TIME;
  return $comment;
}