public function save(User $user)
 {
     $data = array('username' => $user->getUsername(), 'password' => $user->getPassword(), 'name' => $user->getName(), 'valid' => $user->getValid(), 'role' => $user->getRole());
     $id = (int) $user->getId();
     if ($id == 0) {
         $this->tableGateway->insert($data);
     } else {
         if ($this->get($id)) {
             $this->tableGateway->update($data, array('id' => $id));
         } else {
             throw new \Exception('User não existe');
         }
     }
 }