$unitOfWork = $entityManager->getUnitOfWork();
$unitOfWork->computeChangeSets();
$changesets = $unitOfWork->getEntityChangeSet($article);
namespace AppBundle\Entity;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\HasLifecycleCallbacks
*/
abstract class EntityBase
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var DateTime
*
* @ORM\Column(name="created_at", type="datetime")
*/
protected $createdAt;
/**
* @var DateTime
* @ORM\Column(name="updated_at", type="datetime")
*/
protected $updatedAt;
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
*
* @return \DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
*
* @return \DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
public function setId($id)
{
$this->id = $id;
}
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
}
public function setUpdatedAt($updatedAt)
{
$this->updatedAt = $updatedAt;
}
/**
*
* @ORM\PrePersist
* @ORM\PreUpdate
*/
public function updatedTimestamps()
{
$this->setUpdatedAt(new DateTime('now'));
if ($this->getCreatedAt() == null) {
$this->setCreatedAt(new DateTime('now'));
}
}
}