You are here

function recipe_node_view in Recipe 8.2

Same name and namespace in other branches
  1. 7.2 recipe.module \recipe_node_view()
  2. 7 recipe.module \recipe_node_view()

Implements hook_ENTITY_TYPE_view().

File

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

Code

function recipe_node_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
  if ($entity
    ->getEntityTypeId() !== 'node' || $entity
    ->bundle() !== 'recipe') {
    return;
  }

  // Calculate the total time required to make the recipe.
  if ($display
    ->getComponent('recipe_total_time')) {
    recipe_build_total_time($build, $entity, $display, $view_mode);
  }

  // Display the recipe yield by combining the recipe_yield_amount and
  // recipe_yield_unit fields.
  if ($display
    ->getComponent('recipe_yield')) {
    recipe_build_yield($build, $entity, $display, $view_mode);
  }
}