You are here

public function RateWidgetBaseForm::getResults in Rate 8.2

Get results.

2 calls to RateWidgetBaseForm::getResults()
RateWidgetBaseForm::ajaxSubmit in src/Form/RateWidgetBaseForm.php
Ajax submit handler.
RateWidgetBaseForm::buildForm in src/Form/RateWidgetBaseForm.php
Form constructor.

File

src/Form/RateWidgetBaseForm.php, line 384

Class

RateWidgetBaseForm
Form controller for rate vote forms.

Namespace

Drupal\rate\Form

Code

public function getResults($result_function = FALSE, $reset = FALSE) {
  $entity = $this->entity;
  if ($reset) {
    drupal_static_reset(__FUNCTION__);
  }
  $resultCache =& drupal_static(__FUNCTION__);
  if (!$resultCache || !isset($resultCache[$entity
    ->getVotedEntityType()][$entity
    ->getVotedEntityId()])) {
    $resultCache[$entity
      ->getVotedEntityType()][$entity
      ->getVotedEntityId()] = $this->votingapiResult
      ->getResults($entity
      ->getVotedEntityType(), $entity
      ->getVotedEntityId());
  }
  $result = isset($resultCache[$entity
    ->getVotedEntityType()][$entity
    ->getVotedEntityId()]) ? $resultCache[$entity
    ->getVotedEntityType()][$entity
    ->getVotedEntityId()] : [];
  $result = !empty($result) && array_key_exists($entity
    ->bundle(), $result) ? $result[$entity
    ->bundle()] : [];
  if ($result_function && array_key_exists($result_function, $result) && $result[$result_function]) {
    $result = $result[$result_function];
  }
  else {
    $result = 0;
  }
  return $result;
}