public function onPostAuthorizationProcess(OAuthEvent $event) { if ($event->isAuthorizedClient()) { if (null !== ($client = $event->getClient())) { $user = $this->getUser($event); $user->addClient($client); $client->addUser($user); $this->em->persist($user); $this->em->persist($client); $this->em->flush(); } } }