Beispiel #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);
     }
 }
Beispiel #2
0
 public function create(CreateEventArgs $eventArgs)
 {
     if ($eventArgs->getReject()) {
         //don't do anything if the create has already been rejected
         return;
     }
     $document = $eventArgs->getDocument();
     //Check create permissions
     if ($this->getAccessController()->areAllowed([Actions::CREATE], $eventArgs->getMetadata(), $document)->getAllowed()) {
         return;
     }
     $eventArgs->setReject(true);
     $eventArgs->getEventManager()->dispatchEvent(AccessControlEvents::CREATE_DENIED, new EventArgs($document, Actions::CREATE));
 }
Beispiel #3
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']);
     }
 }
Beispiel #4
0
 public function create(CreateEventArgs $eventArgs)
 {
     if ($eventArgs->getReject()) {
         return;
     }
     $metadata = $eventArgs->getMetadata();
     if (!($stateMetadata = $metadata->getState())) {
         return;
     }
     $field = array_keys($stateMetadata)[0];
     $document = $eventArgs->getDocument();
     if (count($stateMetadata[$field]) > 0 && !in_array($metadata->getFieldValue($document, $field), $stateMetadata[$field])) {
         $eventArgs->getEventManager()->dispatchEvent(Events::BAD_STATE, $eventArgs);
         $eventArgs->setReject(true);
     }
 }