0

我正在使用 easyadmin 和 fosuserbundle。每次我尝试更新(更改)用户密码时,什么都没有发生,相同的旧密码仍然相同。我想也许我错过了一些配置。

配置.yml

easyadmin:
        Admin:      
            class: AppBundle\Entity\User
            form:
                fields: 
                    - username
                    - email
                    - { property: 'plainPassword' , type: 'text'}

用户.php:

  <?php
// src/AppBundle/Entity/User.php

namespace AppBundle\Entity;

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

use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Security\Core\Util\SecureRandom;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Doctrine\Common\Collections\ArrayCollection;
/**
 * @ORM\Entity
 * @ORM\Table(name="fos_user")
 */
/**
 * @Vich\Uploadable
 * @ORM\Entity()
 * @ORM\HasLifecycleCallbacks()
 * @ORM\Table(name="user")
 *
 * @UniqueEntity("email")
 * 
 */
class User extends BaseUser
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;


    /**
     * @ORM\Column(type="string", length=255,nullable=true)
     * 
     */
    public $nom;           


    /**
     * @ORM\Column(type="string",nullable=true,length=255,nullable=true)
    */
    public $prenom;   

    /**
     * @ORM\Column(type="string",nullable=true,length=255,nullable=true)
    */
    public $adresse;         

          /**
     * @ORM\Column(type="string", length=255,nullable=true)
     * 
     * @Assert\Range(
     *      min = 00000000,
     *      max = 99999999,minMessage="Entrer un numero de cin correct svp",maxMessage="Entrer un numero tel correct svp"
     * )
     */ 
    protected $phone;

    /**
     * @var Devise[]
     *
     * @ORM\OneToMany(targetEntity="Devise", mappedBy="buyer")
     */
    private $purchases;

    /**
     * The creation date of the product.
     *
     * @var \DateTime
     * @ORM\Column(type="datetime", name="created_at")
     */
    private $createdAt = null;


    public function __construct()
    {
        parent::__construct();
        // your own logic
        $this->purchases = new ArrayCollection();
 $this->createdAt = new \DateTime();
    }
    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }
   /**
     * Set referance 
     *
     * @param string $referance 
     * 
     */
    public function setReferance($referance )
    {if($this->referance==NULL)        $referance ='2';
        $this->referance  = $referance ;
        return $this;
    }
    /**
     * Get referance 
     *
     * @return string 
     */
    public function getReferance ()
    {
        return $this->referance ;
    }



    /**
     * Set forename
     *
     * @param string $forname
     * @return User
     */
    public function setForename($forename)
    {
        $this->forname = $forename;
        return $this;
    }
    /**
     * Get forename
     *
     * @return string 
     */
    public function getForename()
    {
        return $this->forname;
    }
    /**
     * Asks whether the user is granted a particular role
     * 
     * @return boolean
     */
    public function isGranted($role)
    {
        return in_array($role, $this->getRoles());
    }
    /**
     * Set nickname
     *
     * @param string $nickname
     * @return User
     */
    public function setNickname($nickname)
    {
        $this->nickname = $nickname;
        return $this;
    }
    /**
     * Get nickname
     *
     * @return string 
     */
    public function getNickname()
    {
        return $this->nickname;
    }
    /**
     * Set lastEdited
     *
     * @param \DateTime $lastEdited
     * @return User
     */
    public function setLastEdited($lastEdited)
    {
        $this->lastEdited = $lastEdited;
        return $this;
    }
    /**
     * Get lastEdited
     *
     * @return \DateTime 
     */
    public function getLastEdited()
    {
        return $this->lastEdited;
    }
    /**
     * @ORM\PrePersist()
     * @ORM\PreUpdate()
     */
    public function setLastEditedValueAsNow() {
        $this->setLastEdited(new \DateTime());
    }

    /**
     * Set surname
     *
     * @param string $surname
     * @return User
     */
    public function setSurname($surname)
    {
        $this->surname = $surname;
        return $this;
    }
    /**
     * Get surname
     *
     * @return string 
     */
    public function getSurname()
    {
        return $this->surname;
    }

    /**
     * Set updatedAt
     *
     * @param \DateTime $updatedAt
     *
     * @return Utilisateurs
     */
    public function setUpdatedAt($updatedAt)
    {
        $this->updatedAt = $updatedAt;
        return $this;
    }
    /**
     * Get updatedAt
     *
     * @return \DateTime
     */
    public function getUpdatedAt()
    {
        return $this->updatedAt;
    }
    public function __toString()
    {if ($this->prenom != null && $this->nom!= null && $this->phone != null) {
        return 'prenom&nom :'.$this->prenom.' '.$this->nom.'  |  phone : '.$this->phone ;
    }
      else  return 'id :'.$this->id.' |  username : '.$this->username ; }
    /**
     * Set nom
     *
     * @param string $nom
     *
     * @return Utilisateurs
     */
    public function setNom($nom)
    {
        $this->nom = $nom;
        return $this;
    }
    /**
     * Get nom
     *
     * @return string
     */
    public function getNom()
    {
        return $this->nom;
    }
    /**
     * Set prenom
     *
     * @param string $prenom
     *
     * @return Utilisateurs
     */
    public function setPrenom($prenom)
    {
        $this->prenom = $prenom;
        return $this;
    }
    /**
     * Get prenom
     *
     * @return string
     */
    public function getPrenom()
    {
        return $this->prenom;
    }
    /**
     * Set ville
     *
     * @param string $ville
     *
     * @return Utilisateurs
     */
    public function setVille($ville)
    {
        $this->ville = $ville;
        return $this;
    }
    /**
     * Get ville
     *
     * @return string
     */
    public function getVille()
    {
        return $this->ville;
    }
    /**
     * Set class
     *
     * @param string $class
     *
     * @return Utilisateurs
     */
    public function setClass($class)
    {
        $this->class = $class;
        return $this;
    }
    /**
     * Get class
     *
     * @return string
     */
    public function getClass()
    {
        return $this->class;
    }
    /**
     * Set phone
     *
     * @param string $phone
     *
     * @return Utilisateurs
     */
    public function setPhone($phone)
    {
        $this->phone = $phone;
        return $this;
    }
    /**
     * Get phone
     *
     * @return string
     */
    public function getPhone()
    {
        return $this->phone;
    }

    /**
     * Add purchase
     *
     * @param \AppBundle\Entity\Devise $purchase
     *
     * @return User
     */
    public function addPurchase(\AppBundle\Entity\Devise $purchase)
    {
        $this->purchases[] = $purchase;

        return $this;
    }

    /**
     * Remove purchase
     *
     * @param \AppBundle\Entity\Devise $purchase
     */
    public function removePurchase(\AppBundle\Entity\Devise $purchase)
    {
        $this->purchases->removeElement($purchase);
    }

    /**
     * Get purchases
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getPurchases()
    {
        return $this->purchases;
    }

    /**
     * Set adresse
     *
     * @param string $adresse
     *
     * @return User
     */
    public function setAdresse($adresse)
    {
        $this->adresse = $adresse;

        return $this;
    }

    /**
     * Get adresse
     *
     * @return string
     */
    public function getAdresse()
    {
        return $this->adresse;
    }

    /**
     * Set createdAt
     *
     * @param \DateTime $createdAt
     *
     * @return User
     */
    public function setCreatedAt($createdAt)
    {
        $this->createdAt = $createdAt;

        return $this;
    }

    /**
     * Get createdAt
     *
     * @return \DateTime
     */
    public function getCreatedAt()
    {
        return $this->createdAt;
    }

        public function serialize()
    {
        return serialize(array(
            $this->id,
            $this->username,
            $this->password,
        ));
    }
    public function unserialize($serialized)
    {
        list(
            $this->id,
            $this->username,
            $this->password) = unserialize($serialized);
    }
}
4

0 回答 0