Merge pull request #153 from ThomasRubini/recipe_insert
This commit is contained in:
commit
e68c31becb
@ -72,11 +72,6 @@ final class RecipeController
|
|||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$O_recipe->S_RECIPE = substr($S_recipe, 2);
|
$O_recipe->S_RECIPE = substr($S_recipe, 2);
|
||||||
|
|
||||||
$fp = Utils::tryProcessImg("recipeImage");
|
|
||||||
if($fp !== null) {
|
|
||||||
$O_recipe->updateImg($fp);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createAction(Array $A_urlParams = null, Array $A_postParams = null)
|
public function createAction(Array $A_urlParams = null, Array $A_postParams = null)
|
||||||
@ -84,9 +79,18 @@ final class RecipeController
|
|||||||
Session::login_or_die();
|
Session::login_or_die();
|
||||||
|
|
||||||
$O_recipe = RecipeModel::createEmpty();
|
$O_recipe = RecipeModel::createEmpty();
|
||||||
|
|
||||||
|
// fill basic recipe attribtues
|
||||||
self::fillRecipeFromPostParams($O_recipe, $A_postParams);
|
self::fillRecipeFromPostParams($O_recipe, $A_postParams);
|
||||||
$O_recipe->insert();
|
$O_recipe->insert();
|
||||||
|
|
||||||
|
// update img if necessary
|
||||||
|
$fp = Utils::tryProcessImg("recipeImage");
|
||||||
|
if($fp !== null) {
|
||||||
|
$O_recipe->updateImg($fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
// handle ingredients
|
||||||
$A_ingredientNames = Utils::getOrDie($A_postParams, "recipeIngredientNames");
|
$A_ingredientNames = Utils::getOrDie($A_postParams, "recipeIngredientNames");
|
||||||
$A_ingredientQuantities = Utils::getOrDie($A_postParams, "recipeIngredientQuantities");
|
$A_ingredientQuantities = Utils::getOrDie($A_postParams, "recipeIngredientQuantities");
|
||||||
|
|
||||||
@ -120,9 +124,17 @@ final class RecipeController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fill basic recipe attribtues
|
||||||
self::fillRecipeFromPostParams($O_recipe, $A_postParams);
|
self::fillRecipeFromPostParams($O_recipe, $A_postParams);
|
||||||
$O_recipe->update();
|
$O_recipe->update();
|
||||||
|
|
||||||
|
// update img if necessary
|
||||||
|
$fp = Utils::tryProcessImg("recipeImage");
|
||||||
|
if($fp !== null) {
|
||||||
|
$O_recipe->updateImg($fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
// handle ingredients
|
||||||
$A_ingredientNames = Utils::getOrDie($A_postParams, "recipeIngredientNames");
|
$A_ingredientNames = Utils::getOrDie($A_postParams, "recipeIngredientNames");
|
||||||
$A_ingredientQuantities = Utils::getOrDie($A_postParams, "recipeIngredientQuantities");
|
$A_ingredientQuantities = Utils::getOrDie($A_postParams, "recipeIngredientQuantities");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user