You are here

public function FractionProperty::getValue in Fraction 2.x

Same name and namespace in other branches
  1. 8 src/FractionProperty.php \Drupal\fraction\FractionProperty::getValue()

Implements \Drupal\Core\TypedData\TypedDataInterface::getValue().

Overrides TypedData::getValue

File

src/FractionProperty.php, line 22

Class

FractionProperty
A computed property for storing the fraction.

Namespace

Drupal\fraction

Code

public function getValue($langcode = NULL) {

  // If a Fraction object is already available, return it.
  if ($this->fraction !== NULL) {
    return $this->fraction;
  }

  // Load the parent item.
  $item = $this
    ->getParent();

  // Otherwise, create a Fraction object.
  $this->fraction = new Fraction($item->numerator, $item->denominator);
  return $this->fraction;
}