Example #1
0
 /**
  *
  * @param \Zoop\Shard\Annotation\AnnotationEventArgs $eventArgs
  */
 public function getRoles(GetRolesEventArgs $eventArgs)
 {
     $user = $eventArgs->getUser();
     if (isset($user) && $user instanceof RoleAwareUserInterface) {
         $eventArgs->setRoles(array_merge($eventArgs->getRoles(), $user->getRoles()));
     }
 }
Example #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();
     }
     $ownerField = $metadata->getOwner();
     if (isset($document) && $ownerField && isset($username) && $metadata->getFieldValue($document, $ownerField) == $username) {
         $eventArgs->addRole(self::OWNER);
     }
 }
Example #3
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);
         }
     }
 }