You are here

public function RateWidgetBase::getWindow in Rate 8.2

Get time window settings.

1 call to RateWidgetBase::getWindow()
RateWidgetBase::getEntityForVoting in src/Plugin/RateWidgetBase.php
Returns a Vote entity.

File

src/Plugin/RateWidgetBase.php, line 331

Class

RateWidgetBase
Base class for Rate widget plugins.

Namespace

Drupal\rate\Plugin

Code

public function getWindow($window_type, $entity_type_id, $entity_bundle, $rate_widget, $voting_settings) {

  // Check for rollover window settings in widget or use votingapi setting.
  $window_field_setting = isset($voting_settings[$window_type]) ? $voting_settings[$window_type] : -2;
  $use_site_default = FALSE;

  // Use votingapi site-wide setting if requested or window not set.
  if ($window_field_setting === NULL || $window_field_setting === -2) {
    $use_site_default = TRUE;
  }
  $window = $window_field_setting;
  if ($use_site_default) {

    /*
     * @var \Drupal\Core\Config\ImmutableConfig $voting_configuration
     */
    $voting_configuration = $this->configFactory
      ->get('votingapi.settings');
    $window = $voting_configuration
      ->get($window_type);
  }
  return $window;
}