简体   繁体   中英

Missing database columns with FOSUserBundle and FR3DLdapBundle

  • I followed the instructions from the FOSUserBundle documentation ( documentation ) and the FR3DLdapBundle ( documentation )
    • FOSUserBundle requires to extend the BaseUser class whereas FR3DLdapBundle requires the User Class to implement the LdapUserInterface interface
    • In my case this results in a class like this:

use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
use FR3D\LdapBundle\Model\LdapUserInterface;

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

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

private $dn;

/**
 * the constructor
 */
public function __construct() {
    parent::__construct();
    // your own logic
}

/**
 * {@inheritDoc}
 */
public function getDn() {
    return $this->dn;
}

/**
 * {@inheritDoc}
 */
public function setDn($dn) {
    $this->dn = $dn;
}

}
  • If i update my schema via php app/console doctrine:schema:update --em=someEm Doctrine inserts the new table. However it only inserts the id column, not the inherited columns as well
  • I don't know if this is a FOSUserBundle bug or FR3DLdapBundle bug
  • If I completely remove the FR3DLdapBundle part it does not work either
  • Thus I think it's some kind of bug in FOSUserBundle
  • Does anyone have an idea?

Thanks a lot in advance!

FOSUserBundle is in an state of transition right now so it depends a bit on exactly what version you have.

You probably need:

use FOS\UserBundle\Entity\User as BaseUser;  // Note Entity instead of Model

To get the base attributes. They are shifting things to the Model which explains why you may have seen Model\\User in the documentation. But no stable release has been made yet.

You could try changing composer.json to: "friendsofsymfony/user-bundle": "dev-master", and doing an update. Or just do an update if you are already using dev-master.

After which the Model base should work. However, some of your other code might stop working.

It's all very unstable right now.

Of course you also have to have your doctrine mappings set right:

           mappings:
                FOSUserBundle: ~
                MyBundle: ~

But I assume you have this because you first got FOSUserBundle working before you tried adding Ldap. You did right?

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM