我遇到了唯一约束验证问题。
这是我的用户类
ul#navmenu {
width: 645px;
margin: 0px auto;
}
ul#navmenu, ul.sub1, ul.sub2 {
list-style-type: none;
font-size: 9pt;
}
ul#navmenu li {
width: 125px;
text-align: center;
position: relative;
float: left;
margin-right: 4px;
}
ul#navmenu a {
text-decoration: none;
display: block;
width: 125px;
height: 25px;
line-height: 25px;
background-color: blue;
color:#fff;
border: 1px solid #CCC;
border-radius: 5px;
}
ul#navmenu .sub1 li a,
ul#navmenu .sub2 li a
{
background:#fff;
color:#000;
}
ul#navmenu .sub1 li {
}
ul#navmenu .sub1 a {
margin-top: 5px;
}
ul#navmenu .sub2 a {
margin-left: 3px;
}
ul#navmenu li:hover > a {
background-color: #CFC;
}
ul#navmenu li:hover a:hover {
background-color: #FF0;
}
ul#navmenu ul.sub1 {
display: none;
position: absolute;
top: 26px;
left: 0px;
}
ul#navmenu ul.sub2 {
display: none;
position: absolute;
top: 0px;
left: 126px;
}
ul#navmenu li:hover .sub1 {
display: block;
}
ul#navmenu .sub1 li:hover .sub2 {
display: block;
}
这是我的教条
的YAML文件 <?php
namespace Uber\UberGamesBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* User
*/
class User implements UserInterface, \Serializable
{
/**
* @var integer
*/
private $id;
/**
* @var string
*/
private $username;
/**
* @var string
*/
private $email;
/**
* @var string
*/
private $password;
/**
* @var \DateTime
*/
private $fechaInscripcion;
/**
* @var boolean
*/
private $esAdministrador;
private $isActive;
public function __construct()
{
$this->isActive = true;
}
public function getSalt()
{
// you *may* need a real salt depending on your encoder
// see section on salt below
return null;
}
public function eraseCredentials()
{
}
/** @see \Serializable::serialize() */
public function serialize()
{
return serialize(array(
$this->id,
$this->username,
$this->password,
// see section on salt below
// $this->salt,
));
}
/** @see \Serializable::unserialize() */
public function unserialize($serialized)
{
list (
$this->id,
$this->username,
$this->password,
// see section on salt below
// $this->salt
) = unserialize($serialized);
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set username
*
* @param string $username
* @return User
*/
public function setUsername($username)
{
$this->username = $username;
return $this;
}
/**
* Get username
*
* @return string
*/
public function getUsername()
{
return $this->username;
}
/**
* Set email
*
* @param string $email
* @return User
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}
/**
* Get email
*
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* Set password
*
* @param string $password
* @return User
*/
public function setPassword($password)
{
$this->password = $password;
return $this;
}
/**
* Get password
*
* @return string
*/
public function getPassword()
{
return $this->password;
}
/**
* Set fechaInscripcion
*
* @param \DateTime $fechaInscripcion
* @return User
*/
public function setFechaInscripcion($fechaInscripcion)
{
$this->fechaInscripcion = $fechaInscripcion;
return $this;
}
/**
* Get fechaInscripcion
*
* @return \DateTime
*/
public function getFechaInscripcion()
{
return $this->fechaInscripcion;
}
/**
* Set esAdministrador
*
* @param boolean $esAdministrador
* @return User
*/
public function setEsAdministrador($esAdministrador)
{
$this->esAdministrador = $esAdministrador;
return $this;
}
/**
* Get esAdministrador
*
* @return boolean
*/
public function getEsAdministrador()
{
return $this->esAdministrador;
}
/**
* Set isActive
*
* @param boolean $isActive
* @return User
*/
public function setIsActive($isActive)
{
$this->isActive = $isActive;
return $this;
}
/**
* Get isActive
*
* @return boolean
*/
public function getIsActive()
{
return $this->isActive;
}
public function getRoles()
{
$roles = array('ROLE_USER');
if($this->getEsAdministrador())
{
$roles[] = 'ROLE_ADMIN';
}
return $roles;
}
}
但我无法使用户名和电子邮件变得独一无二。 添加具有相同用户名或电子邮件的用户甚至不会引发数据库异常。 symfony2和bundle更新了,架构也是如此。
(我知道其他主题的细节必须在此代码中予以纠正,即使我可以使用捆绑包,但请让我们专注于独特的问题:))