/** * Return the user entity in an array format * * @return array Array with all users attributes */ public function __toArray() : array { $user = parent::__toArray(); $user['right'] = $this->right !== null ? $this->right->__toArray() : []; $user['roomRight'] = $this->roomRight !== null ? $this->roomRight->__toArray() : []; return $user; }
/** * Update the client user * * @param array $data JSON decoded client data * @param Client $client The client object */ private function updateUser(array $data, Client $client) { $client->setUser(new User($data['user'])); $client->getUser()->setRight(new UserRight($data['user']['right'])); if (count($data['user']['roomRight']) > 0) { $roomRightCollection = new RoomRightCollection(); foreach ($data['user']['roomRight'] as $userChatRightInfo) { $roomRightCollection->add(new RoomRight($userChatRightInfo)); } $client->getUser()->setChatRight($roomRightCollection); } }