You are here

protected function StarsFormatter::getSelectedWidgetKey in Fivestar 8

Gets the selected widget key.

Sites that used an older version of the module will have a stale key set for their selected widget. This returns the proper, cleaned up version if that's the case.

Return value

string The active widget's key

2 calls to StarsFormatter::getSelectedWidgetKey()
StarsFormatter::settingsSummary in src/Plugin/Field/FieldFormatter/StarsFormatter.php
Returns a short summary for the current formatter settings.
StarsFormatter::viewElements in src/Plugin/Field/FieldFormatter/StarsFormatter.php
Builds a renderable array for a field value.

File

src/Plugin/Field/FieldFormatter/StarsFormatter.php, line 157

Class

StarsFormatter
Plugin implementation of the 'fivestar_stars' formatter.

Namespace

Drupal\fivestar\Plugin\Field\FieldFormatter

Code

protected function getSelectedWidgetKey() {
  $setting = $this
    ->getSetting('fivestar_widget') ?: 'default';
  if (strpos($setting, '.css') === FALSE) {
    return $setting;
  }
  $file_name = basename($setting);
  $file_name_exploded = explode('.', $file_name);
  $setting = reset($file_name_exploded);
  return $setting;
}