| @@ 126-155 (lines=30) @@ | ||
| 123 | * @param boolean $forceEncryptPassword |
|
| 124 | * @return \Admin\Entity\User |
|
| 125 | */ |
|
| 126 | public function exchangeArray($data = array(), $forceEncryptPassword = false) |
|
| 127 | { |
|
| 128 | if (isset($data['id']) && !empty($data["id"]) ) { |
|
| 129 | $this->id = ($data['id']); |
|
| 130 | $this->user_id = ($data['id']); |
|
| 131 | } elseif (isset($data['user_id']) && !empty($data["user_id"]) ) { |
|
| 132 | $this->id = ($data['user_id']); |
|
| 133 | $this->user_id = ($data['user_id']); |
|
| 134 | } |
|
| 135 | $this->username = (isset($data['username'])) ? $data['username'] : $this->username; |
|
| 136 | $this->email = (isset($data['email'])) ? $data['email'] : $this->email; |
|
| 137 | if (isset($data['displayName']) ) { |
|
| 138 | $this->display_name = $data['displayName']; |
|
| 139 | $this->displayName = $data['displayName']; |
|
| 140 | } elseif (isset($data['display_name']) ) { |
|
| 141 | $this->display_name = $data['display_name']; |
|
| 142 | $this->displayName = $data['display_name']; |
|
| 143 | } |
|
| 144 | if (isset($data["password"]) && $forceEncryptPassword ) { |
|
| 145 | $bcrypt = new Bcrypt; |
|
| 146 | $bcrypt->setCost(null); // @TODO $this->getUserService()->getOptions()->getPasswordCost()); |
|
| 147 | $data["password"] = $bcrypt->create($data['password']); |
|
| 148 | } |
|
| 149 | $this->password = (isset($data['password'])) ? $data['password'] : $this->password; |
|
| 150 | $this->state = (isset($data['state'])) ? $data['state'] : $this->state; |
|
| 151 | $this->aclrole = (isset($data['aclrole'])) ? $data['aclrole'] : $this->aclrole; |
|
| 152 | $this->token = (isset($data['token'])) ? $data['token'] : $this->token; |
|
| 153 | ||
| 154 | return $this; |
|
| 155 | } |
|
| 156 | ||
| 157 | /** |
|
| 158 | * get copy of user's object properties in an assosiative array |
|
| @@ 55-84 (lines=30) @@ | ||
| 52 | * @param boolean $forceEncryptPassword |
|
| 53 | * @return \Admin\Entity\User |
|
| 54 | */ |
|
| 55 | public function exchangeArray($data = array(), $forceEncryptPassword = false) |
|
| 56 | { |
|
| 57 | if (isset($data['id']) && !empty($data["id"]) ) { |
|
| 58 | $this->id = ($data['id']); |
|
| 59 | $this->user_id = ($data['id']); |
|
| 60 | } elseif (isset($data['user_id']) && !empty($data["user_id"]) ) { |
|
| 61 | $this->id = ($data['user_id']); |
|
| 62 | $this->user_id = ($data['user_id']); |
|
| 63 | } |
|
| 64 | $this->username = (isset($data['username'])) ? $data['username'] : $this->username; |
|
| 65 | $this->email = (isset($data['email'])) ? $data['email'] : $this->email; |
|
| 66 | if (isset($data['displayName']) ) { |
|
| 67 | $this->display_name = $data['displayName']; |
|
| 68 | $this->displayName = $data['displayName']; |
|
| 69 | } elseif (isset($data['display_name']) ) { |
|
| 70 | $this->display_name = $data['display_name']; |
|
| 71 | $this->displayName = $data['display_name']; |
|
| 72 | } |
|
| 73 | if (isset($data["password"]) && $forceEncryptPassword ) { |
|
| 74 | $bcrypt = new Bcrypt; |
|
| 75 | $bcrypt->setCost(null); // @TODO $this->getUserService()->getOptions()->getPasswordCost()); |
|
| 76 | $data["password"] = $bcrypt->create($data['password']); |
|
| 77 | } |
|
| 78 | $this->password = (isset($data['password'])) ? $data['password'] : $this->password; |
|
| 79 | $this->state = (isset($data['state'])) ? $data['state'] : $this->state; |
|
| 80 | $this->aclrole = (isset($data['aclrole'])) ? $data['aclrole'] : $this->aclrole; |
|
| 81 | $this->token = (isset($data['token'])) ? $data['token'] : $this->token; |
|
| 82 | ||
| 83 | return $this; |
|
| 84 | } |
|
| 85 | ||
| 86 | ||
| 87 | public function getArrayCopy() |
|