0

ユーザーに異なるログイン/登録ページ/フォームを提供したいのですが、ユーザーは同じクラスです。データベースに追加のテーブルを設定したくありません。

pugx_multi_user:
  users:
    medics:
        entity:
          class: MedAppBundle\Entity\User
        registration:
          form:
            type: MedAppBundle\Form\MedicRegistrationType
            name: app_medics_registration
            validation_groups:  [Registration, Default]
          template: MedAppBundle:Registration:registerMedic.html.twig
        profile:
          form:
            type: MedAppBundle\Form\ProfileType
            validation_groups:  [Profile, Default]
    patients:
        entity:
          class: MedAppBundle\Entity\User
        registration:
          form:
            type: MedAppBundle\Form\PatientsRegistrationType
          template: MedAppBundle:Registration:registerPacient.html.twig
        profile:
          form:
            type: MedAppBundle\Form\ProfileType
            validation_groups:  [Profile, Default]

そして、ここに登録クラスがあります:

class RegController extends Controller
{


    public function registerPatientAction()
    {
        return $this->container
            ->get('pugx_multi_user.registration_manager')
            ->register('MedAppBundle\Entity\User');
    }


    public function registerMedicAction()
    {
        return $this->container
            ->get('pugx_multi_user.registration_manager')
            ->register('MedAppBundle\Entity\User');
    }

残念ながら、フォームはすべて、最後のタイプのユーザー、つまり pacients になります。UserDiscriminatorこの構成は、主に、ユーザー タイプ名ではなくクラスごとに値を取得するため、機能しません。

役立つ構成はありますか、またはこれを達成する方法を知っている人はいますか?

4

1 に答える 1

0

PuGXMultiUserBundle意味がないので、必要に応じて使用しないでください。

を使用してFOSUserBundle、登録/ログイン テンプレート用の追加のルートを作成し、適切な FOSUser-Controller-Action でそれらをすべて設定するだけです。

したがって、すべての登録フォームは FOS 登録アクションに、すべてのログイン フォームは fos-register アクションに登録されます (FOS ルーティング ファイル内でログイン/登録に F​​OS が使用しているアクションを調べることができます)。

于 2016-04-29T17:16:20.670 に答える