Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Person
- {
- //metadata
- protected $_email;
- protected $_password;
- protected $_username;
- protected $_test =1;
- protected $_test2 ='some text';
- protected $_test3 ='<html><b>some text</b></html>';
- public function __get($name) { }
- public function __set($name, $value) { }
- //Behaviors
- public function authenticate() { }
- public function logout() { }
- public function ban() { }
- }
- class personTable extends Zend_Db_Table_Abstract
- {
- protected $_name='person';
- protected $_primary='username';
- public function save($data) {
- // insert || update logic
- }
- }
- class personMapper
- {
- private $table;
- public function save(Person $person)
- {
- $data = array(
- 'username' => $person->username,
- 'password' => $person->password,
- 'email' => $person->email
- );
- $this->getTable()->save($data);
- }
- public function fetch($username=null);
- public function getTable() {
- if(! $this->table) {
- $this->table = new personTable();
- }
- return $this->table;
- };
- public function setTable($table) {
- $this->table = $table;
- }
- }
- class PersonService
- {
- public function create(array $data)
- {
- // у нас ведь нет класса Person! - почему он тут используется?
- $person = new Person();
- if(!$data = $this->getValidator()
- ->isValid($data)
- )
- {
- throw new InvalidArgumentExeption();
- }
- $person->username= $data['username'];
- $person->password=$data['password'];
- $person->email = $data['email'];
- //нет метода getMapper() - я так понимаю что он возвращает обьект класса PersonMapper?
- // Уже есть! что дальше?
- $this->getMapper()->save($person);
- return $person;
- }
- function getMapper() {
- if(!$this->personMapper) {
- return new PersonMapper();
- }
- return $this->personMapper;
- }
- }
Add Comment
Please, Sign In to add comment