簡體   English   中英

FosUserBundle和自定義用戶注冊

[英]FosUserBundle and custom user registration

我試圖弄清楚FosUserBundle的注冊過程,但一直無法做到。

我希望能夠使用自定義字段手動注冊用戶,並且無法在代碼中看到該用戶。

我在FosUserBundle中有registerAction,並且跟隨它在任何地方都沒有顯示信息實際存儲在數據庫中的位置:

public function registerAction()
    {
        $form = $this->container->get('fos_user.registration.form');
        $formHandler = $this->container->get('fos_user.registration.form.handler');
        $confirmationEnabled = $this->container->getParameter('fos_user.registration.confirmation.enabled');

        $process = $formHandler->process($confirmationEnabled);
        if ($process) {
            $user = $form->getData();

            if ($confirmationEnabled) {
                $this->container->get('session')->set('fos_user_send_confirmation_email/email', $user->getEmail());
                $route = 'fos_user_registration_check_email';
            } else {
                $this->authenticateUser($user);
                $route = 'fos_user_registration_confirmed';
            }

            $this->setFlash('fos_user_success', 'registration.flash.user_created');
            $url = $this->container->get('router')->generate($route);

            return new RedirectResponse($url);
        }

        return $this->container->get('templating')->renderResponse('FOSUserBundle:Registration:register.html.'.$this->getEngine(), array(
            'form' => $form->createView(),
            'theme' => $this->container->getParameter('fos_user.template.theme'),
        ));
    }

如何手動注冊用戶?

謝謝

你有沒有在FOSUserBundle文檔中讀到這個?

使用UserManager

顯然,服務UserManager有責任實際保存和更新用戶,您可以按照指南創建自己的UserManager。

編輯:Symfony已將FOSUserBundle的文檔合並到他們自己的文檔中,因此文檔的新鏈接是: https ://symfony.com/doc/master/bundles/FOSUserBundle/index.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM