1 | <?php |
||
9 | class User extends AbstractDbMapper implements UserInterface |
||
10 | { |
||
11 | protected $tableName = 'user'; |
||
12 | |||
13 | public function findByEmail($email) |
||
14 | { |
||
15 | $select = $this->getSelect() |
||
16 | ->where(array('email' => $email)); |
||
17 | |||
18 | $entity = $this->select($select)->current(); |
||
19 | $this->getEventManager()->trigger('find', $this, array('entity' => $entity)); |
||
20 | return $entity; |
||
21 | } |
||
22 | |||
23 | public function findByUsername($username) |
||
24 | { |
||
25 | $select = $this->getSelect() |
||
26 | ->where(array('username' => $username)); |
||
27 | |||
28 | $entity = $this->select($select)->current(); |
||
29 | $this->getEventManager()->trigger('find', $this, array('entity' => $entity)); |
||
30 | return $entity; |
||
31 | } |
||
32 | |||
33 | public function findById($id) |
||
34 | { |
||
35 | $select = $this->getSelect() |
||
36 | ->where(array('user_id' => $id)); |
||
37 | |||
38 | $entity = $this->select($select)->current(); |
||
39 | $this->getEventManager()->trigger('find', $this, array('entity' => $entity)); |
||
40 | return $entity; |
||
41 | } |
||
42 | |||
43 | public function getTableName() |
||
47 | |||
48 | public function setTableName($tableName) |
||
52 | |||
53 | public function insert($entity, $tableName = null, HydratorInterface $hydrator = null) |
||
54 | { |
||
55 | $result = parent::insert($entity, $tableName, $hydrator); |
||
56 | $entity->setId($result->getGeneratedValue()); |
||
57 | return $result; |
||
58 | } |
||
59 | |||
60 | public function update($entity, $where = null, $tableName = null, HydratorInterface $hydrator = null) |
||
68 | } |
||
69 |