public function execute(IWebRequest $request, IWebResponse $response) { DebugLog::separator(); DebugLog::log($request->postAll()); $feeding = $this->feedingRepository->getInProgressOrNew(); $this->executeInner($request, $response, $feeding); if ($request->post('docommit', false)) { $feeding->setStatus(Feeding::STATUS_Finalized); $this->model->setStatus($feeding->getStatus()); } $this->feedingRepository->save($feeding); return $this->model; }
protected function executeInner(IWebRequest $request, IWebResponse $response, Feeding $feeding) { $whichBoob = $request->post('whichBoob', null); if (is_null($whichBoob)) { throw new Exception('Missing whichBoob'); } $totalMinutes = $request->post('totalMinutes', 0); $whichBoob = strtolower($whichBoob); switch ($whichBoob) { case 'left': $feeding->setBreastLeft($totalMinutes); break; case 'right': $feeding->setBreastRight($totalMinutes); break; default: throw new Exception('Unknown boob ' . $whichBoob); } }
protected function executeInner(IWebRequest $request, IWebResponse $response, Feeding $feeding) { $type = $request->post('type', null); if (is_null($type)) { throw new Exception('Missing type'); } $amount = $request->post('amount', 0); if ($amount > 0) { switch (strtolower($type)) { case 'milk': $type = Bottle::TYPE_MILK; break; case 'formula': $type = Bottle::TYPE_FORMULA; break; default: throw new Exception('Unknown type ' . $type); } $feeding->setBottle(new Bottle($type, $amount)); } }
public function execute(IWebRequest $request, IWebResponse $response) { $this->model->setTemplateName($this->getTemplateName()); $this->model->setFeeding($this->feedingRepository->getInProgress()); $feeding = $this->model->getFeeding(); if ($feeding->hasBottle() && !$this->stringHelper->startsWith($request->path(), '/bottle')) { $response->redirect('/bottle'); } else { if ($feeding->hasMilking() && !$this->stringHelper->startsWith($request->path(), '/milking')) { $response->redirect('/milking'); } else { if ($feeding->hasBreastFeeding() && !$this->stringHelper->startsWith($request->path(), '/breast')) { $response->redirect('/breast'); } else { if ($feeding->hasDiaper() && !$this->stringHelper->startsWith($request->path(), '/diaper')) { $response->redirect('/diaper'); } } } } return $this->model; }
protected function executeInner(IWebRequest $request, IWebResponse $response, Feeding $feeding) { $feeding->setMilking($request->post('amount', $feeding->getMilking())); }
protected function executeInner(IWebRequest $request, IWebResponse $response, Feeding $feeding) { $feeding->setPee($request->post('pee', $feeding->getPee())); $feeding->setPoo($request->post('poo', $feeding->getPoo())); }