You are here

public static function Botcha::getRecipe in BOTCHA Spam Prevention 6.2

Same name and namespace in other branches
  1. 7.2 controller/botcha.controller.inc \Botcha::getRecipe()

Gets a recipe from cache. If it does not exists in cache - gets from database. If it does not exists there also - returns NULL.

Parameters

string $id: Machine name of the recipe to look for.

boolean $create: Determines whether we should initialize new recipe book or not.

Return value

BotchaRecipe

1 call to Botcha::getRecipe()
BotchaRecipebookAbstract::getRecipes in controller/botcha_recipebook.controller.inc
@todo BotchaRecipebook getRecipes Description.

File

controller/botcha.controller.inc, line 425
Contains Botcha class.

Class

Botcha
Singleton realization of botcha application.

Code

public static function getRecipe($id, $create = TRUE) {
  $recipe_session =& $_SESSION[self::BOTCHA_SESSION_RECIPES][$id];
  if (empty($recipe_session)) {
    $recipe = BotchaRecipe::getRecipe($id, $create);

    // @todo ?Do we need it?

    //if (!($recipe1 instanceof BotchaRecipeNone)) {

    // Set relationships for this concrete recipe.
    $rbs = array_keys(BotchaModel::getRecipesRecipebooks(array(
      'mode' => 'recipebook',
      'recipes' => $id,
    )));
    foreach ($rbs as $rbid) {
      $recipe = $recipe
        ->setRecipebook($rbid);
    }

    //}
    Botcha::setRecipe($recipe);
  }
  $recipe = unserialize($recipe_session);
  return $recipe;
}