Created
February 4, 2013 22:03
-
-
Save enumag/4710107 to your computer and use it in GitHub Desktop.
FormFactory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace App; | |
| class UserFormFactory extends \Nette\Object | |
| { | |
| /**@var \Model\UserRepository */ | |
| private $userRepository; | |
| /** | |
| * @param \Model\UserRepository $userRepository | |
| */ | |
| public function __construct(\Model\UserRepository $userStatusRepository) | |
| { | |
| $this->userRepository = $userRepository; | |
| } | |
| /** | |
| * @return \Nette\Application\UI\Form | |
| */ | |
| public function create() | |
| { | |
| $form = new \Nette\Application\UI\Form | |
| // díky tomu že je to factory (služba) mohu injectnout nějaké modely a podle nich testovat i unikátnost etc. | |
| $form->onSuccess[] = callback($this, 'save'); | |
| return $form; | |
| } | |
| public function save(\Nette\Application\UI\Form $form) | |
| { | |
| // uložení do injectnutých modelů | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment