You are here

function recipe_build_yield in Recipe 8.2

1 call to recipe_build_yield()
recipe_node_view in ./recipe.module
Implements hook_ENTITY_TYPE_view().

File

./recipe.module, line 182
Contains functions for Recipe node CRUD and display.

Code

function recipe_build_yield(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
  $node_type = NodeType::load('recipe');

  // Do not display if the yield_amount is NULL.
  if ($entity->recipe_yield_amount->value == NULL) {
    return;
  }
  $arguments = [
    '@yield_amount' => $entity->recipe_yield_amount->value,
    '@yield_unit' => $entity->recipe_yield_unit->value,
  ];
  $build['recipe_yield'] = [
    '#theme' => 'recipe_yield',
    '#label' => $node_type
      ->getThirdPartySetting('recipe', 'yield_label'),
    '#label_display' => $node_type
      ->getThirdPartySetting('recipe', 'total_time_label_display'),
    '#yield' => t('@yield_amount @yield_unit', $arguments),
  ];
}