You are here

FieldCount.php in Votingapi Widgets 8

File

src/Plugin/VoteResultFunction/FieldCount.php
View source
<?php

namespace Drupal\votingapi_widgets\Plugin\VoteResultFunction;

use Drupal\votingapi_widgets\FieldVoteResultBase;

/**
 * A sum of a set of votes.
 *
 * @VoteResultFunction(
 *   id = "vote_field_count",
 *   label = @Translation("Count"),
 *   description = @Translation("The number of votes cast."),
 *   deriver = "Drupal\votingapi_widgets\Plugin\Derivative\FieldResultFunction",
 * )
 */
class FieldCount extends FieldVoteResultBase {

  /**
   * {@inheritdoc}
   */
  public function calculateResult($votes) {
    $votes = $this
      ->getVotesForField($votes);
    return count($votes);
  }

}

Classes

Namesort descending Description
FieldCount A sum of a set of votes.