Using Symfony 4.1, SonataUserBundle with FOSUserBundle (Current)
Followed the instructions, created wrapper class for User, added ORM tablename hint as well.
namespace App\Application\Sonata\UserBundle\Entity;
use Sonata\UserBundle\Entity\BaseUser as BaseUser;
use Doctrine\ORM\Mapping as ORM;
/**
* This file has been generated by the SonataEasyExtendsBundle.
* @ORM\Entity(name="aegis_user")
* @link https://sonata-project.org/easy-extends
*
* References:
* @link http://www.doctrine-project.org/projects/orm/2.0/docs/reference/working-with-objects/en
*/
class User extends BaseUser
{
/**
* @var int $id
*/
protected $id;
/**
* Get id.
*
* @return int $id
*/
public function getId()
{
return $this->id;
}
}
However, the table names generated (doctrine migration) are still fos_user_user, fos_user_group etc.
$this->addSql('CREATE TABLE fos_user_group (id INT ...
$this->addSql('CREATE TABLE fos_user_user (id INT ...
$this->addSql('CREATE TABLE fos_user_user_group (user_id INT ...
I need the table name prefix at least to change to xxx_user, xxx_group.
How do I change the names of the tables that FosUserBundle generates without modifying the bundle code ?
Thanks.
You are searching for
* @ORM\Table(name="table_name")
not
* @ORM\Entity(name="aegis_user")
To change group table name you have to edit sonata user config
config/packages/sonata_user.yaml
table:
user_group: "my_custom_user_group_association_table_name"
for more details it's documented here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.