コード例 #1
0
 /**
  *
  * @param \Zoop\Shard\Annotation\AnnotationEventArgs $eventArgs
  */
 public function getRoles(GetRolesEventArgs $eventArgs)
 {
     $document = $eventArgs->getDocument();
     $metadata = $eventArgs->getMetadata();
     if ($user = $eventArgs->getUser()) {
         $username = $user->getUsername();
     }
     $ownerField = $metadata->getOwner();
     if (isset($document) && $ownerField && isset($username) && $metadata->getFieldValue($document, $ownerField) == $username) {
         $eventArgs->addRole(self::OWNER);
     }
 }
コード例 #2
0
 /**
  *
  * @param \Zoop\Shard\Annotation\AnnotationEventArgs $eventArgs
  */
 public function getRoles(GetRolesEventArgs $eventArgs)
 {
     $document = $eventArgs->getDocument();
     $metadata = $eventArgs->getMetadata();
     if ($user = $eventArgs->getUser()) {
         $username = $user->getUsername();
     }
     if (isset($document) && isset($username) && isset($metadata->stamp)) {
         if (isset($metadata->stamp['createdBy']) && $metadata->getFieldValue($document, $metadata->stamp['createdBy']) == $username) {
             $eventArgs->addRole(self::CREATOR);
         }
         if (isset($metadata->stamp['updatedBy']) && $metadata->getFieldValue($document, $metadata->stamp['updatedBy']) == $username) {
             $eventArgs->addRole(self::UPDATER);
         }
     }
 }