/** * @param $ingredientsData * @return array */ public function createIngredients($ingredientsData) { $ingredients = array(); foreach ($ingredientsData as $entityData) { //TODO: If the name is empty skip the adding $ingredientEntity = new Ingredient(); $ingredientEntity->setName($entityData['name']); $this->ingredientManager->persistStep($ingredientEntity); $ingredients[] = $ingredientEntity; } $this->ingredientManager->saveChanges(); return $ingredients; }
/** * @param Ingredient $ingredient */ public function __construct(Ingredient $ingredient) { $this->id = $ingredient->getId(); $this->name = $ingredient->getName(); }