You are here

public function VotingApiWidgetBase::getWindow in Votingapi Widgets 8

Get time window settings.

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

File

src/Plugin/VotingApiWidgetBase.php, line 260

Class

VotingApiWidgetBase
Base class for Voting api widget plugins.

Namespace

Drupal\votingapi_widgets\Plugin

Code

public function getWindow($window_type, $entity_type_id, $entity_bundle, $field_name) {
  $config = FieldConfig::loadByName($entity_type_id, $entity_bundle, $field_name);
  $window_field_setting = $config
    ->getSetting($window_type);
  $use_site_default = FALSE;
  if ($window_field_setting === NULL || $window_field_setting === "-1") {
    $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;
}