Merge pull request #118 from ThomasRubini/recipe_preload

This commit is contained in:
Thomas Rubini 2023-01-26 16:27:38 +01:00 committed by GitHub
commit 81dbc8a68c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 27 deletions

View File

@ -10,7 +10,7 @@ final class RecipeController
}
//TODO MAKE THE VIEW USE THE NEW DATA FORMAT
$O_recipe = RecipeModel::getFullRecipeWithApprs($A_urlParams[0]);
$O_recipe = RecipeModel::getByID($A_urlParams[0]);
if ($O_recipe === null) {
throw new HTTPSpecialCaseException(404);
}
@ -30,7 +30,7 @@ final class RecipeController
}
$O_recipe = RecipeModel::getFullRecipeById($A_urlParams[0]);
$O_recipe = RecipeModel::getByID($A_urlParams[0]);
if ($O_recipe === null) {
throw new HTTPSpecialCaseException(404);
}

View File

@ -147,30 +147,6 @@ final class RecipeModel
return $this->A_APPRS;
}
public function getFullRecipe()
{
$this->getAuthor();
$this->getDifficulty();
$this->getIngredients();
}
public static function getFullRecipeById($I_id)
{
$O_recipe = self::getByID($I_id);
$O_recipe->getFullRecipe();
return $O_recipe;
}
public static function getFullRecipeWithApprs($I_id)
{
$O_recipe = self::getFullRecipeById($I_id);
if ($O_recipe === null)return null;
$O_recipe->getApprs();
return $O_recipe;
}
//TODO: return array object
public static function searchRecipesByName($S_query)
{

View File

@ -9,7 +9,7 @@ $O_recipe = $A_view["RECIPE"];
<section class="infosRecette">
<header>
<h1><?= $O_recipe->S_NAME ?></h1>
<p><?= $O_recipe->I_TIME ?>&nbsp;—&nbsp;<?= $O_recipe->O_DIFFICULTY->S_NAME ?></p>
<p><?= $O_recipe->I_TIME ?>&nbsp;—&nbsp;<?= $O_recipe->getDifficulty()->S_NAME ?></p>
</header>
<p><?= $O_recipe->S_DESCR ?></p>
</section>