aboutsummaryrefslogblamecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Helper/EntityTimestampsTrait.php
blob: 1b1ff54a6ebd8dd0f88e4197f1029d712c8bb376 (plain) (tree)























                                                       
<?php

namespace Wallabag\CoreBundle\Helper;

use Doctrine\ORM\Mapping as ORM;

/**
 * Trait to handle created & updated date of an Entity.
 */
trait EntityTimestampsTrait
{
    /**
     * @ORM\PrePersist
     * @ORM\PreUpdate
     */
    public function timestamps()
    {
        if (null === $this->createdAt) {
            $this->createdAt = new \DateTime();
        }

        $this->updatedAt = new \DateTime();
    }
}