You are here

public function Poll::getOptions in Poll 8

Get all options for this poll.

Return value

array Associative array of option keys and values.

Overrides PollInterface::getOptions

File

src/Entity/Poll.php, line 393

Class

Poll
Defines the poll entity class.

Namespace

Drupal\poll\Entity

Code

public function getOptions() {
  $options = array();
  if (count($this->choice)) {
    foreach ($this->choice as $choice_item) {
      $options[$choice_item->target_id] = \Drupal::service('entity.repository')
        ->getTranslationFromContext($choice_item->entity, $this
        ->language()
        ->getId())
        ->label();
    }
  }
  return $options;
}