src/Sulu/Component/DocumentManager/Subscriber/Behavior/Audit/TimestampSubscriber.php
public function setTimestampsOnNode(
        LocalizedTimestampBehavior $document,
        NodeInterface $node,
        DocumentAccessor $accessor,
        $locale,
        $timestamp = null
    ) {
        if (!$document instanceof TimestampBehavior && !$locale) {
            return;
        }

        $encoding = $this->getPropertyEncoding($document);

        $createdPropertyName = $this->propertyEncoder->encode($encoding, static::CREATED, $locale);
        if (!$node->hasProperty($createdPropertyName)) {
            $createdTimestamp = $document->getCreated() ?: $timestamp;
            $accessor->set(static::CREATED, $createdTimestamp);
            $node->setProperty($createdPropertyName, $createdTimestamp);
        }

        $changedTimestamp = $timestamp ?: $document->getChanged();
        $accessor->set(static::CHANGED, $changedTimestamp);
        $node->setProperty($this->propertyEncoder->encode($encoding, static::CHANGED, $locale), $changedTimestamp);
    }
public function setTimestampsOnNode(
        LocalizedTimestampBehavior $document,
        NodeInterface $node,
        DocumentAccessor $accessor,
        $locale,
        $timestamp = null
    ) {
        if (!$document instanceof TimestampBehavior && !$locale) {
            return;
        }

        $encoding = $this->getPropertyEncoding($document);

        $createdPropertyName = $this->propertyEncoder->encode($encoding, static::CREATED, $locale);
        if (!$node->hasProperty($createdPropertyName)) {
            $createdTimestamp = $document->getCreated() ?: $timestamp;
            $accessor->set(static::CREATED, $createdTimestamp);
            $node->setProperty($createdPropertyName, $createdTimestamp);
        }

        $changedTimestamp = $timestamp ?: $document->getChanged();
        $accessor->set(static::CHANGED, $changedTimestamp);
        $node->setProperty($this->propertyEncoder->encode($encoding, static::CHANGED, $locale), $changedTimestamp);
    }
public function setTimestampsOnNode ( LocalizedTimestampBehavior $ document , NodeInterface $ node , DocumentAccessor $ accessor , $ locale , $ timestamp = null ) { if ( ! $ document instanceof TimestampBehavior && ! $ locale ) { return ; } $ encoding = $ this -> getPropertyEncoding ( $ document ) ; $ createdPropertyName = $ this -> propertyEncoder -> encode ( $ encoding , static :: CREATED , $ locale ) ; if ( ! $ node -> hasProperty ( $ createdPropertyName ) ) { $ createdTimestamp = $ document -> getCreated ( ) ? : $ timestamp ; $ accessor -> set ( static :: CREATED , $ createdTimestamp ) ; $ node -> setProperty ( $ createdPropertyName , $ createdTimestamp ) ; } $ changedTimestamp = $ timestamp ? : $ document -> getChanged ( ) ; $ accessor -> set ( static :: CHANGED , $ changedTimestamp ) ; $ node -> setProperty ( $ this -> propertyEncoder -> encode ( $ encoding , static :: CHANGED , $ locale ) , $ changedTimestamp ) ; }
Set the timestamps on the node.

@param LocalizedTimestampBehavior $document
@param NodeInterface $node
@param DocumentAccessor $accessor
@param string $locale
@param \DateTime|null $timestamp The timestamp to set, will use the documents timestamps if null is provided
Set the timestamps on the node .