Note that there are some explanatory texts on larger screens.

plurals
  1. POHow extends User entity of FOSUserBundle?
    primarykey
    data
    text
    <p>I have my UserBundle who extends the FOSUserBundle and works fine. But now, I want create multiple users entities with différents properties. But the problem is when I create my user enttity who extends my main User entity like this :</p> <pre><code>class User extends BaseUser { protected $id; // The main user class who extends FOSUser entity } class UserB extends User { // } </code></pre> <p>When I do this, I've got an error : `</p> <blockquote> <p>Access level to MyApp\UserBundle\Entity\UserB::$id must be protected (as in class MyApp\UserBundle\Entity\User).</p> </blockquote> <p>And when I create a protected id in my UserB entity I have this: </p> <blockquote> <p>PHP Fatal error: Cannot redeclare MyApp\UserBundle\Entity\UserB::$id.</p> </blockquote> <p>And to finish, I can't delete the id in my User entity less return a Doctrine error :</p> <blockquote> <p>[Doctrine\ORM\Mapping\MappingException]<br> No identifier/primary key specified for Entity 'MTS\UserBundle\Entity\User'. Every Entity must have an identifier/primary key.</p> </blockquote> <p>Someone can help me ?</p> <p>EDIT : Problem solved. My code :</p> <pre><code>/** * MTS\UserBundle\Entity\User * * @ORM\Entity * @ORM\InheritanceType("SINGLE_TABLE") * @ORM\DiscriminatorColumn(name="type", type="string") * @ORM\DiscriminatorMap({"userfb" = "UserFB"}) */ abstract class User extends BaseUser { /** * @var integer $id * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; /** * @var string $type */ private $type; } /** * @ORM\Table() * @ORM\Entity() */ class UserB extends User { // My variables } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload