예제 #1
0
                     // mark the recipe
                     $oldRI->setOkOnImport();
                     $foundOld = true;
                     // update the count if it changed
                     if ($oldRI->getCount() != $ingrow['Count']) {
                         $oldRI->setCount($ingrow['Count']);
                         $oldRI->save();
                     }
                 }
             }
             // only create a new recipe if we haven't found it
             if (!$foundOld) {
                 $ri = new RecipeIngredient();
                 $ri->setItem($item);
                 $ri->setCount($ingrow['Count']);
                 $ri->setRecipe($r);
                 $ri->save();
                 // mark the recipe
                 $ri->setOkOnImport();
             }
         }
     }
     // remove old ingredients that aren't in the import any more
     foreach ($oldRIs as $oldRI) {
         if (!$oldRI->getOkOnImport()) {
             $oldRI->delete();
         }
     }
     $r->save();
 } catch (Exception $e) {
     $failed[] = $row;
예제 #2
0
 /**
  * @param	Recipe $recipe The recipe object to add.
  */
 protected function doAddRecipe($recipe)
 {
     $recipeIngredient = new RecipeIngredient();
     $recipeIngredient->setRecipe($recipe);
     $this->addRecipeIngredient($recipeIngredient);
 }