Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extending the admin User entity 3.2.*@dev #484

Merged
merged 1 commit into from
Jun 10, 2015

Conversation

wimvds
Copy link
Contributor

@wimvds wimvds commented Jun 10, 2015

Hello,
I've updated kunstmaan bundles from 3.0 to 3.2.*@dev.
all works great but i have a problem with custom user entity.
i have extended the original entity by this article:

http://bundles.kunstmaan.be/news/extending-the-admin-user-entity

but in new version i have some errors:
1 on user page it tries to show entities from original db table
2 on add/edit i have this error

 Error: Call to protected method Sandbox\WebsiteBundle\Entity\User::getFormTypeClass() from context 'Kunstmaan\UserManagementBundle\Controller\UsersController' 

and if i change the protected method to public i get

 Attempted to load class "UserType" from namespace "SandBox\WebsiteBundle\Form".

Did you forget a "use" statement for "Kunstmaan\AdminBundle\Form\UserType"?

my method :

    public function getFormTypeClass()
    {
        return 'SandBox\WebsiteBundle\Form\UserType';
    }

that file with that namespace exist(and it worked in prev version)

Stack Trace
in vendor/kunstmaan/bundles-cms/src/Kunstmaan/UserManagementBundle/Controller/UsersController.php at line 89  -
        /* @var $em EntityManager */
        $em                = $this->getDoctrine()->getManager();
        $user              = $this->getUserClassInstance();
        $formTypeClassName = $user->getFormTypeClass();
        $formType          = new $formTypeClassName();
        $formType->setLangs($this->container->getParameter('kunstmaan_admin.admin_locales'));

how can i fix this?

@krispypen
Copy link
Contributor

@konstantinsp

Can you check if the parameter for the custom user class is defined like this? https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/master/src/Kunstmaan/UserManagementBundle/Controller/UsersController.php#L67

Can you also post your SandBox\WebsiteBundle\Form\UserType? Strange that it doesn't find the class.

The method getFormTypeClass() should indeed be public, as in the default User class: https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/master/src/Kunstmaan/AdminBundle/Entity/User.php
We have to make that abstract protected methods in BaseUser public indeed.

@konstantinsp
Copy link
Contributor Author

@krispypen

here is code from my config.yml

fos_user:
    user_class: Sandbox\WebsiteBundle\Entity\User

parameters:
    kunstmaan_user_management.user_admin_list_configurator.class: Sandbox\WebsiteBundle\AdminList\UserAdminListConfigurator
    fos_user.model.user.class: Sandbox\WebsiteBundle\Entity\User

and the user type class

namespace Sandbox\WebsiteBundle\Form;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class UserType extends \Kunstmaan\AdminBundle\Form\UserType{
    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('name');
        parent::buildForm($builder, $options);
    }
    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return 'markmedia_user';
    }
    /**
     * {@inheritdoc}
     */
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        parent::setDefaultOptions($resolver);
    }
}

fix symfony dependency
@wimvds wimvds force-pushed the fix-base-user-visibility-484 branch from ccb976e to 007d45a Compare June 10, 2015 14:25
@krispypen
Copy link
Contributor

hmm, looks all ok, maybe you have a folder named "form" instead of "Form" and you are using OSX? :)

@konstantinsp
Copy link
Contributor Author

@krispypen
folder names are okey. it was working correctly in previous version...

krispypen added a commit that referenced this pull request Jun 10, 2015
@krispypen krispypen merged commit 4b7f70f into Kunstmaan:master Jun 10, 2015
@konstantinsp
Copy link
Contributor Author

also it is not working only on /admin/settings/users/ page.
because i can log in to admin with my custom entity.
will you check what is wrong with that page?

@getvois
Copy link

getvois commented Jun 19, 2015

Any more help with this one? We cannot manage users at the moment.
Adding users = Fatal error: Class 'SandBox\WebsiteBundle\Form\UserType' not found in vendor/kunstmaan/bundles-cms/src/Kunstmaan/UserManagementBundle/Controller/UsersController.php on line 90.

@roderik roderik modified the milestone: 3.2.0 Jul 6, 2015
@wimvds wimvds deleted the fix-base-user-visibility-484 branch October 7, 2015 14:04
@mtnorthrop
Copy link
Contributor

I was having a similar problem with the old admin users showing up on the settings page, instead of my custom, extended user entities.

In the end, the problem was that I forgot to include this method in my custom UserAdminListConfigurator:

    /**
     * Get bundle name
     *
     * @return string
     */
    public function getBundleName()
    {
        return 'CompanyYourBundle';
    }

When I added the getBundleName() method and returned my bundle name, everything worked correctly.

I'm just leaving this here in case anybody in the future runs into a similar problem.

@KevinSleegers
Copy link

I have followed all the steps of https://bundles.kunstmaan.be/news/extending-the-admin-user-entity, and checked that the getBundleName() function is present, but still the old admin users are showing up in my settings page.

Everything else is working fine, but the new users just don't show up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants