src/Sulu/Component/Persistence/EventSubscriber/ORM/TimestampableSubscriber.php
private function handleTimestamp(LifecycleEventArgs $event)
    {
        $entity = $event->getObject();

        if (!$entity instanceof TimestampableInterface) {
            return;
        }

        $meta = $event->getObjectManager()->getClassMetadata(get_class($entity));

        $created = $meta->getFieldValue($entity, self::CREATED_FIELD);
        if (null === $created) {
            $meta->setFieldValue($entity, self::CREATED_FIELD, new \DateTime());
        }

        $meta->setFieldValue($entity, self::CHANGED_FIELD, new \DateTime());
    }
private function handleTimestamp(LifecycleEventArgs $event)
    {
        $entity = $event->getObject();

        if (!$entity instanceof TimestampableInterface) {
            return;
        }

        $meta = $event->getObjectManager()->getClassMetadata(get_class($entity));

        $created = $meta->getFieldValue($entity, self::CREATED_FIELD);
        if (null === $created) {
            $meta->setFieldValue($entity, self::CREATED_FIELD, new \DateTime());
        }

        $meta->setFieldValue($entity, self::CHANGED_FIELD, new \DateTime());
    }
private function handleTimestamp ( LifecycleEventArgs $ event ) { $ entity = $ event -> getObject ( ) ; if ( ! $ entity instanceof TimestampableInterface ) { return ; } $ meta = $ event -> getObjectManager ( ) -> getClassMetadata ( get_class ( $ entity ) ) ; $ created = $ meta -> getFieldValue ( $ entity , self :: CREATED_FIELD ) ; if ( null === $ created ) { $ meta -> setFieldValue ( $ entity , self :: CREATED_FIELD , new \ DateTime ( ) ) ; } $ meta -> setFieldValue ( $ entity , self :: CHANGED_FIELD , new \ DateTime ( ) ) ; }
Set the timestamps. If created is NULL then set it. Always
set the changed field.

@param LifecycleEventArgs $event
Set the timestamps . If created is NULL then set it . Always set the changed field .