@hatman

Почему система не дает удалить юзера?

Пытаюсь удалить юзера в симфони

if($userOriginal === $userDoubleCheck){
            $entityManager = $this->getDoctrine()->getManager();
            $entityManager->remove($userDoubleCheck);
            $entityManager->flush();


Система выбрасывает ошибку

You cannot refresh a user from the EntityUserProvider that does not contain an identifier. The user object has to be serialized with its own identifier mapped by Doctrine.

Но в юзер-классе у меня стоит сериализация id

/** @see \Serializable::serialize() */
    public function serialize()
    {
        return serialize(array(
            $this->id,
            $this->username,
            $this->password,
//            $this->roles,
            // see section on salt below
            // $this->salt,
        ));
    }

    /** @see \Serializable::unserialize() */
    public function unserialize($serialized)
    {
        list (
            $this->id,
            $this->username,
            $this->password,
//            $this->roles,
            // see section on salt below
            // $this->salt
            ) = unserialize($serialized, array('allowed_classes' => false));
    }


т.е. как бы id я передаю. Не пойму, почему она все равно ругается на меня.
  • Вопрос задан
  • 149 просмотров
Решения вопроса 1
@hatman Автор вопроса
Как оказалось, нужно было убить сессию пользователя, так как при последующем рендере страницы шел конфликт. Ошибка шла неинформативная.

$this->get('security.token_storage')->setToken(null);
$request->getSession()->invalidate();
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы