public function formCalculatorSucceeded($form) { if ($form['submit']->isSubmittedBy()) { $date = DateTime::createFromFormat('Y-m-d', date("Y-m-d"))->format('Y-m-d'); $currentCalculation = $this->calculationFacade->findByDate($date, $this->addressId); if ($currentCalculation == NULL) { $this->calculationFacade->update(array('date' => $date, 'address' => $this->addressFacade->find($this->addressId))); $currentCalculation = $this->calculationFacade->findByDate($date, $this->addressId); } else { $items = $this->calculationItemFacade->findCalculationItems($currentCalculation->getId()); foreach ($items as $item) { $this->calculationItemFacade->delete($item->getId()); } } foreach ($this->tariffs as $item) { $this->calculationItemFacade->update(array('tariff' => $item['value'], 'previous' => $form['previous_' . array_search($item, $this->tariffs)]->getValue(), 'current' => $form['current_' . array_search($item, $this->tariffs)]->getValue(), 'calculation' => $currentCalculation, 'name' => $item['name'])); } } else { if ($form['addCategory']->isSubmittedBy()) { foreach ($form['addCategory']->values as $newCategory) { $this->tariffFacade->update(array('address' => $this->addressFacade->find($this->addressId), 'value' => (double) str_replace(',', '.', $newCategory['tariff']), 'name' => $newCategory['category'])); } } else { if ($form['deleteAddress']->isSubmittedBy()) { $this->addressFacade->delete($this->addressId); throw new InvalidArgumentException('Address with id=' . $this->addressId . ' has been deleted'); } else { foreach (array_keys($this->tariffs) as $key) { if ($form['delete_' . $key]->isSubmittedBy()) { $this->tariffFacade->delete($key); } } } } } }
public function formAddSucceeded($form) { $this->addressFacade->update(array('country' => $form['country']->getValue(), 'city' => $form['city']->getValue(), 'street' => $form['street']->getValue(), 'house' => $form['house']->getValue(), 'room' => $form['room']->getValue(), 'user' => $this->usersFacade->find($this->user->id))); }