You are here

class BotchaRecipeController in BOTCHA Spam Prevention 6.3

Same name and namespace in other branches
  1. 7.3 controller/recipe/botcha.recipe.controller.inc \BotchaRecipeController

Hierarchy

Expanded class hierarchy of BotchaRecipeController

File

controller/recipe/botcha.recipe.controller.inc, line 15
Controller layer of the BotchaRecipe objects.

View source
class BotchaRecipeController extends Controller implements IBotchaRecipeController {
  protected $app_name = 'Botcha';
  protected $controller_type = Botcha::CONTROLLER_TYPE_RECIPE;

  /**
   * Just for IDE autocomplete feature.
   * @return BotchaRecipeModel
   */
  protected function getModel() {
    return parent::getModel();
  }
  public function getRecipe($id, $create = TRUE) {

    // @todo Respect $create parameter.
    // @see?
    $r = $this
      ->getModel()
      ->getRecipe($id);
    $classname = $r->classname;
    $recipe = new $classname($id);
    $recipe
      ->setTitle($r->title)
      ->setDescription($r->description);
    return $recipe;
  }
  public function getRecipes($reset = FALSE) {
    $rs = array_keys($this
      ->getModel()
      ->getRecipes());
    return $rs;
  }
  public function save($recipe) {

    // Save recipe to DB.
    $this
      ->getModel()
      ->save($recipe);

    // Return updated object to check results if necessary.
    return $this
      ->getRecipe($recipe->id, FALSE);
  }
  public function delete($recipe) {

    // Save recipe to DB.
    $this
      ->getModel()
      ->delete($recipe);
  }

}

Members