/** * This method is called on the presenter lifecycle begin, * so we can put here code that would be duplicated among the action methods. * * Also, this is a good place to add some common checks that apply to all presenter actions. */ protected function startup() { parent::startup(); // so we don't have to repeat the code in every action if ($id = $this->getParameter('id')) { $this->pad = $this->padRepository->findOneBy(['id' => $id, 'user' => $this->user->getId()]); } }
/** * Callback method, that is called once form is successfully submitted, without validation errors. * * @param Form $form * @param Nette\Utils\ArrayHash $values */ public function formSucceeded(Form $form, $values) { if ($this->note === NULL) { $note = new Note($this->user->getIdentity()); $this->em->persist($note); } else { $note = $this->note; } $note->setName($values->name); $note->setText($values->text); if ($values->pad === NULL) { $note->setPad(NULL); } else { $note->setPad($this->padRepository->find($values->pad)); } $this->em->flush(); $this->onSuccess($this); }
public function render() { $this->template->pads = $this->padRepository->findBy(['user' => $this->user->getId()]); $this->template->render(__DIR__ . '/default.latte'); }