You are here

function ingredient_is_page in Recipe 8.2

Returns whether the current page is the page of the passed-in ingredient.

Parameters

\Drupal\ingredient\Entity\Ingredient $ingredient: A ingredient entity.

Return value

int|false The ingredient's ID if displaying an ingredient's page, FALSE otherwise.

1 call to ingredient_is_page()
template_preprocess_ingredient in modules/ingredient/ingredient.module
Prepares variables for ingredient templates.

File

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

Code

function ingredient_is_page(Ingredient $ingredient) {
  if (\Drupal::routeMatch()
    ->getRouteName() == 'entity.ingredient.canonical' && ($page_id = \Drupal::routeMatch()
    ->getRawParameter('ingredient'))) {
    return $page_id == $ingredient
      ->id();
  }
  return FALSE;
}