public function FractionProperty::getValue in Fraction 8
Same name and namespace in other branches
- 2.x 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\fractionCode
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;
}