Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class UserRepository
- {
- private $mapper;
- public function __construct(Nette\Database\Context $database)
- {
- $this->mapper = new UserMapper($database)
- }
- }
- class UserMapper
- {
- private $database;
- private $table = 'users';
- public function __construct(Nette\Database\Context $database)
- {
- $this->database = $database;
- }
- /** REGISTRACE UZIVATELE
- @return int (user id)
- **/
- public function insertNewUser(USERENTITY $user)
- {
- return $this->database->table($this->table)->insert($user->toArray());
- }
- }
- class User
- {
- private $id;
- private $username;
- private $password;
- // etc ...
- // musis si udelat neco cim ty entity naplnnis
- /**
- @param $data (data z formulare nebo radek z databaze whatever)
- **/
- public function __construct($data)
- {
- // naplnis entitu datama a si libovej
- // rekneme ze ti prijde http request na registraci
- // nejak to vymrdas ti data z JSONU zavolas si new User(json data api)
- // a pak zavolas jenom repository
- // $repository->insertNewUser($userEntity)
- $this->populate($data);
- }
- /** VYMYSLI JAK SI BUDES CHTIT NAPLNOVAT PROPERTIES TY TRIDY **/
- private function populate()
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement