You are here

protected function RateWidgetBaseForm::checkDeadlineDisabled in Rate 8.2

Helper function to check the voting deadline.

Parameters

object $voted_entity: The voted entity object.

array $voting: The rate widget voting settings.

Return value

bool True if the rate widget should be disabled as deadline has passed.

2 calls to RateWidgetBaseForm::checkDeadlineDisabled()
RateWidgetBaseForm::ajaxSubmit in src/Form/RateWidgetBaseForm.php
Ajax submit handler.
RateWidgetBaseForm::buildForm in src/Form/RateWidgetBaseForm.php
Form constructor.

File

src/Form/RateWidgetBaseForm.php, line 614

Class

RateWidgetBaseForm
Form controller for rate vote forms.

Namespace

Drupal\rate\Form

Code

protected function checkDeadlineDisabled($voted_entity, array $voting) {
  $deadline_disabled = FALSE;
  if (isset($voting['use_deadline']) && $voting['use_deadline'] == 1) {

    // Get the rate_vote_deadline field.
    if ($voted_entity
      ->hasField('field_rate_vote_deadline')) {
      $deadline = $voted_entity
        ->get('field_rate_vote_deadline')
        ->getString();
      $current_time = $this->time
        ->getRequestTime();

      // Disable the widget if deadline to vote was set and was passed.
      if (!empty($deadline) && strtotime($deadline) <= $current_time) {
        $deadline_disabled = TRUE;
      }
    }
  }
  return $deadline_disabled;
}