Trying to create new user type in sylius user bundle


#1
sylius_user:
    resources:
        owner:
            user:
                classes:
                    model: App\Entity\User\OwnerUser
                    repository: Sylius\Bundle\UserBundle\Doctrine\ORM\UserRepository
                    form: Sylius\Bundle\CoreBundle\Form\Type\User\AdminUserType
        admin:
            user:
                classes:
                    model: App\Entity\User\AdminUser
        shop:
            user:
                classes:
                    model: App\Entity\User\ShopUser
        oauth:
            user:
                classes:
                    model: App\Entity\User\UserOAuth

show this error after trying to open customer list in admin

No mapping found for field ‘customer’ on a class ‘App\Entity\User\OwnerUser’.

after tracking code I find this user field in Customer entity targetEntity changed to App\Entity\User\OwnerUser
i forced this by

//$class->reflFields[$field]->setValue($entity, $this->getEntityPersister($assoc['targetEntity'])->loadOneToOneEntity($assoc, $entity));

                        try {
                            $class->reflFields[$field]->setValue($entity, $this->getEntityPersister($assoc['targetEntity'])->loadOneToOneEntity($assoc, $entity));

                        } catch (\Exception $exception) {
                            $assoc['targetEntity'] = ShopUser::class;

                            $class->reflFields[$field]->setValue($entity, $this->getEntityPersister($assoc['targetEntity'])->loadOneToOneEntity($assoc, $entity));
                        }

in vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php


#2

You are using a repository and a form type configured for another entity.