/** * @param Item $item The item object to add. */ protected function doAddItem($item) { $recipeIngredient = new RecipeIngredient(); $recipeIngredient->setItem($item); $this->addRecipeIngredient($recipeIngredient); }
foreach ($oldRIs as $oldRI) { if ($oldRI->getItemId() == $item->getDataId()) { // 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();