Example #1
0
 /**
  *
  * @param \Zoop\Shard\Stamp\CreateEventArgs $eventArgs
  */
 public function create(CreateEventArgs $eventArgs)
 {
     $document = $eventArgs->getDocument();
     $metadata = $eventArgs->getMetadata();
     if (!($ownerField = $metadata->getOwner())) {
         return;
     }
     $owner = $metadata->getFieldValue($document, $ownerField);
     if (!isset($owner)) {
         $metadata->setFieldValue($document, $ownerField, $this->getUsername());
         $eventArgs->addRecompute($ownerField);
     }
 }
Example #2
0
 /**
  *
  * @param \Zoop\Shard\Stamp\CreateEventArgs $eventArgs
  */
 public function create(CreateEventArgs $eventArgs)
 {
     $document = $eventArgs->getDocument();
     $metadata = $eventArgs->getMetadata();
     $stampMetadata = $metadata->getStamp();
     if (isset($stampMetadata['createdBy'])) {
         $metadata->setFieldValue($document, $stampMetadata['createdBy'], $this->getUsername());
         $eventArgs->addRecompute($stampMetadata['createdBy']);
     }
     if (isset($stampMetadata['createdOn'])) {
         $metadata->setFieldValue($document, $stampMetadata['createdOn'], time());
         $eventArgs->addRecompute($stampMetadata['createdOn']);
     }
     if (isset($stampMetadata['updatedBy'])) {
         $metadata->setFieldValue($document, $stampMetadata['updatedBy'], $this->getUsername());
         $eventArgs->addRecompute($stampMetadata['updatedBy']);
     }
     if (isset($stampMetadata['updatedOn'])) {
         $metadata->setFieldValue($document, $stampMetadata['updatedOn'], time());
         $eventArgs->addRecompute($stampMetadata['updatedOn']);
     }
 }