예제 #1
0
 /**
  *
  * @param \Zoop\Shard\Freeze\FreezerEventArgs $eventArgs
  */
 public function postThaw(FreezerEventArgs $eventArgs)
 {
     $document = $eventArgs->getDocument();
     $metadata = $eventArgs->getMetadata();
     $freezeMetadata = $metadata->getFreeze();
     if (isset($freezeMetadata['thawedBy'])) {
         $metadata->setFieldValue($document, $freezeMetadata['thawedBy'], $this->getUsername());
     }
     if (isset($freezeMetadata['thawedOn'])) {
         $metadata->setFieldValue($document, $freezeMetadata['thawedOn'], time());
     }
 }
예제 #2
0
 /**
  *
  * @param  \Zoop\Shard\Freeze\FreezerEventArgs $eventArgs
  * @return type
  */
 public function preThaw(FreezerEventArgs $eventArgs)
 {
     if (!($accessController = $this->getAccessController())) {
         //Access control is not enabled
         return;
     }
     $document = $eventArgs->getDocument();
     $metadata = $eventArgs->getMetadata();
     if (!$accessController->areAllowed([Actions::THAW], $metadata, $document)->getAllowed()) {
         //stop thaw
         $this->getFreezer()->freeze($document, $metadata);
         $eventArgs->getEventManager()->dispatchEvent(Events::THAW_DENIED, new AccessControlEventArgs($document, Actions::THAW));
         $eventArgs->setReject(true);
     }
 }