You are here

function ingredient_quantity_from_decimal in Recipe 8.2

Converts an ingredient's quantity from decimal to fraction.

Parameters

float $ingredient_quantity: The ingredient quantity formatted as a decimal.

string $fraction_format: A string representing the fraction format, used by sprintf().

bool $edit_mode: Whether or not the ingredient is being edited.

Return value

string The ingredient quantity formatted as a fraction.

Deprecated

This function was deprecated in version 8.x-2.0 and will be removed in version 3.0.0. Use \Drupal\ingredient\Utility\IngredientQuantityUtility::getQuantityFromDecimal() instead.

File

modules/ingredient/ingredient.module, line 101
Contains basic functions for the Ingredient module.

Code

function ingredient_quantity_from_decimal($ingredient_quantity, $fraction_format = '{%d} %d⁄%d', $edit_mode = FALSE) {
  return \Drupal::service('ingredient.quantity')
    ->getQuantityFromDecimal($ingredient_quantity, $fraction_format, $edit_mode);
}