You are here

public function PollChoice::needsSaving in Poll 8

Whether or not the choice must be saved when the poll is saved.

Parameters

null|bool $new_value: Pass FALSE or TRUE to change the current value.

Return value

bool Returns the current value.

Overrides PollChoiceInterface::needsSaving

File

src/Entity/PollChoice.php, line 51

Class

PollChoice
Defines the poll choice entity class.

Namespace

Drupal\poll\Entity

Code

public function needsSaving($new_value = NULL) {

  // If explicitly set, return that value. otherwise fall back to isNew(),
  // saving is always required for new entities.
  $return = $this->needsSave !== NULL ? $this->needsSave : $this
    ->isNew();
  if ($new_value !== NULL) {
    $this->needsSave = $new_value;
  }
  return $return;
}