Skip to content

Instantly share code, notes, and snippets.

@hpatoio
Last active December 12, 2015 10:59
Show Gist options
  • Select an option

  • Save hpatoio/4762796 to your computer and use it in GitHub Desktop.

Select an option

Save hpatoio/4762796 to your computer and use it in GitHub Desktop.
User class with property password_changed_at
<?php
namespace Hpatoio\UserBundle\Entity;
use FOS\UserBundle\Entity\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="fos_user")
*/
class User extends BaseUser
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var date_time
*
* @ORM\Column(name="password_changed_at", type="datetime")
*/
protected $password_changed_at;
public function __construct()
{
parent::__construct();
$today = new \DateTime();
$this->setPasswordChangedAt($today);
}
public function setPlainPassword($password)
{
$today = new \DateTime();
$this->setPasswordChangedAt($today);
parent::setPlainPassword($password);
}
/**
* @var date_time
*
* @ORM\Column(name="password_changed_at", type="datetime")
*/
protected $password_changed_at;
/**
* Set password_changed_at
*
* @param \DateTime $passwordChangedAt
* @return User
*/
public function setPasswordChangedAt($passwordChangedAt)
{
$this->password_changed_at = $passwordChangedAt;
return $this;
}
/**
* Get password_changed_at
*
* @return \DateTime
*/
public function getPasswordChangedAt()
{
return $this->password_changed_at;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment