1

I would like to not use some default fields giving by the Sonata User bundle. Such as facebook, gplus or twitters fields.

I extended the SonataUserBundle in Application\Sonata\UserBundle with Easy-Extends.

And created a new User entity extenting the BaseUser :

class User extends BaseUser

I deleted the xml doctrine config since i'm using annotations.

So it does recognize my custom fields such as "city" and "address".

But i have all the fields from BaseUser, how can i get rid of unnecessary fields?

<?php
namespace Application\Sonata\UserBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Sonata\UserBundle\Entity\BaseUser as BaseUser;

/**
 * @ORM\Entity
 * @ORM\Table(name="fos_user_user")
 */
class User extends BaseUser
{

    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(type="string", length=64, nullable=false, name="city")
     */
    protected $city;

    /**
     * @ORM\Column(type="string", length=255, nullable=false, name="address")
     */
    protected $address;

}
Brieuc
  • 3,994
  • 9
  • 37
  • 70

1 Answers1

1

Sonata UserBundle seems to extend FOSUserBundle:

use FOS\UserBundle\Entity\User as AbstractedUser;
use Sonata\UserBundle\Model\UserInterface;

abstract class User extends AbstractedUser implements UserInterface

So, I think you should be able to do the same; instead of extending Sonata User, extend FOSUser and implement the UserInterface. That way you should be able to get rid of the undesired fields, as long as they are in sonata's User model.

Javier C. H.
  • 2,124
  • 2
  • 19
  • 30
  • Thank you, it did work well ;). I ran into some troubles because some methods from the vendor folder were not implemented but i just had to add them in my User entity. – Brieuc Feb 12 '15 at 13:58