You are here

public function StarRatingFormatter::settingsSummary in Star Rating 8

Same name and namespace in other branches
  1. 8.4 src/Plugin/Field/FieldFormatter/StarRatingFormatter.php \Drupal\starrating\Plugin\Field\FieldFormatter\StarRatingFormatter::settingsSummary()
  2. 8.2 src/Plugin/Field/FieldFormatter/StarRatingFormatter.php \Drupal\starrating\Plugin\Field\FieldFormatter\StarRatingFormatter::settingsSummary()
  3. 8.3 src/Plugin/Field/FieldFormatter/StarRatingFormatter.php \Drupal\starrating\Plugin\Field\FieldFormatter\StarRatingFormatter::settingsSummary()

Returns a short summary for the current formatter settings.

If an empty result is returned, a UI can still be provided to display a settings form in case the formatter has configurable settings.

Return value

string[] A short summary of the formatter settings.

Overrides FormatterBase::settingsSummary

File

src/Plugin/Field/FieldFormatter/StarRatingFormatter.php, line 104

Class

StarRatingFormatter
Plugin implementation of the 'addtocart' formatter.

Namespace

Drupal\starrating\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = [];
  $field_settings = $this
    ->getFieldSettings();
  $max = $field_settings['max_value'];
  $min = 0;
  $rate = $max;
  $icon_type = $this
    ->getSetting('icon_type');
  $icon_color = $this
    ->getSetting('icon_color');
  $fill_blank = $this
    ->getSetting('fill_blank');
  $elements = [];
  $elements['#markup'] = $this
    ->formatterExecute($rate, $min, $max, $icon_type, $icon_color, $fill_blank);
  $elements['#attached']['library'][] = 'starrating/' . $icon_type;
  $summary[] = $elements;
  return $summary;
}