Bravo3\Orm\Services\Aspect\CreateModifySubscriber::updateTimeStamps PHP Method

updateTimeStamps() public method

Check a pre-persist event for a CreateModifyTrait and update timestamps
public updateTimeStamps ( Bravo3\Orm\Events\PersistEvent $event )
$event Bravo3\Orm\Events\PersistEvent
    public function updateTimeStamps(PersistEvent $event)
    {
        $entity = $event->getEntity();
        if (!$entity instanceof CreateModifyInterface) {
            return;
        }
        $current_time = new \DateTime();
        // Force last-modified to be the current time
        $entity->setLastModified($current_time);
        // If the time created is still null, set it to the current time
        if (!$entity->getTimeCreated()) {
            $entity->setTimeCreated($current_time);
        }
    }