public function annotationStampUpdatedOn(AnnotationEventArgs $eventArgs)
 {
     $metadata = $eventArgs->getMetadata();
     $stampMetadata = $this->getStampMetadata($metadata);
     $stampMetadata['updatedOn'] = $eventArgs->getReflection()->getName();
     $metadata->setStamp($stampMetadata);
 }
 /**
  *
  * @param \Zoop\Shard\Annotation\AnnotationEventArgs $eventArgs
  */
 public function annotationCryptBlockCipher(AnnotationEventArgs $eventArgs)
 {
     $annotation = $eventArgs->getAnnotation();
     $metadata = $eventArgs->getMetadata();
     $cryptMetadata = $this->getCryptMetadata($metadata);
     $cryptMetadata['blockCipher'][$eventArgs->getReflection()->getName()] = ['service' => $annotation->service, 'key' => $annotation->key, 'salt' => $annotation->salt];
     $metadata->setCrypt($cryptMetadata);
 }
 /**
  *
  * @param \Zoop\Shard\Annotation\AnnotationEventArgs $eventArgs
  */
 public function annotationState(AnnotationEventArgs $eventArgs)
 {
     $field = $eventArgs->getReflection()->getName();
     $metadata = $eventArgs->getMetadata();
     $eventManager = $eventArgs->getEventManager();
     $metadata->addProperty('state', true);
     $metadata->setState([$field => $eventArgs->getAnnotation()->value]);
     //Add sythentic annotation to create extra permission that will allow
     //updates on the state field when access control is enabled.
     $permissionAnnotation = new Shard\Permission\Basic(['roles' => BasicPermission::WILD, 'allow' => Actions::update($field)]);
     // Raise annotation event
     $eventManager->dispatchEvent($permissionAnnotation::EVENT, new AnnotationEventArgs($metadata, EventType::DOCUMENT, $permissionAnnotation, $metadata->getReflectionClass(), $eventManager));
 }
 /**
  *
  * @param \Zoop\Shard\Annotation\AnnotationEventArgs $eventArgs
  */
 public function annotationAccessControl(AnnotationEventArgs $eventArgs)
 {
     $annotation = $eventArgs->getAnnotation();
     $metadata = $eventArgs->getMetadata();
     if ($annotation->value) {
         $eventManager = $eventArgs->getEventManager();
         foreach ($annotation->value as $permissionAnnotation) {
             if (defined(get_class($permissionAnnotation) . '::EVENT')) {
                 // Raise annotation event
                 $eventManager->dispatchEvent($permissionAnnotation::EVENT, new AnnotationEventArgs($metadata, EventType::DOCUMENT, $permissionAnnotation, $eventArgs->getReflection(), $eventManager));
             }
         }
     }
 }
 /**
  *
  * @param \Zoop\Shard\Annotation\AnnotationEventArgs $eventArgs
  */
 public function annotationStatePermission(AnnotationEventArgs $eventArgs)
 {
     $annotation = $eventArgs->getAnnotation();
     $metadata = $eventArgs->getMetadata();
     $config = ['factory' => 'Zoop\\Shard\\State\\AccessControl\\StatePermissionFactory', 'options' => []];
     if (is_array($annotation->states)) {
         $config['options']['states'] = $annotation->states;
     } else {
         $config['options']['states'] = [$annotation->states];
     }
     if (isset($annotation->roles)) {
         if (is_array($annotation->roles)) {
             $config['options']['roles'] = $annotation->roles;
         } else {
             $config['options']['roles'] = [$annotation->roles];
         }
     } else {
         $config['options']['roles'] = [];
     }
     if (isset($annotation->allow)) {
         if (is_array($annotation->allow)) {
             $config['options']['allow'] = $annotation->allow;
         } else {
             $config['options']['allow'] = [$annotation->allow];
         }
     } else {
         $config['options']['allow'] = [];
     }
     if (isset($annotation->deny)) {
         if (is_array($annotation->deny)) {
             $config['options']['deny'] = $annotation->deny;
         } else {
             $config['options']['deny'] = [$annotation->deny];
         }
     } else {
         $config['options']['deny'] = [];
     }
     if (!$metadata->hasProperty('permissions')) {
         $metadata->addProperty('permissions', true);
         $metadata->setPermissions([]);
     }
     $permissionsMetadata = $metadata->getPermissions();
     $permissionsMetadata[] = $config;
     $metadata->setPermissions($permissionsMetadata);
 }
 public function annotationOwner(AnnotationEventArgs $eventArgs)
 {
     $metadata = $eventArgs->getMetadata();
     $metadata->addProperty('owner', true);
     $metadata->setOwner($eventArgs->getReflection()->getName());
 }
 /**
  *
  * @param \Zoop\Shard\Annotation\AnnotationEventArgs $eventArgs
  */
 public function annotationSoftDeleteRestoredOn(AnnotationEventArgs $eventArgs)
 {
     $metadata = $eventArgs->getMetadata();
     $softDeleteMetadata = $this->getSoftDeleteMetadata($metadata);
     $softDeleteMetadata['restoredOn'] = $eventArgs->getReflection()->getName();
     $metadata->setSoftDelete($softDeleteMetadata);
 }
 /**
  *
  * @param \Zoop\Shard\Annotation\AnnotationEventArgs $eventArgs
  */
 public function annotationFreezeThawedOn(AnnotationEventArgs $eventArgs)
 {
     $metadata = $eventArgs->getMetadata();
     $freezeMetadata = $this->getFreezeMetadata($metadata);
     $freezeMetadata['thawedOn'] = $eventArgs->getReflection()->getName();
     $metadata->setFreeze($freezeMetadata);
 }
 /**
  *
  * @param \Zoop\Shard\Annotation\AnnotationEventArgs $eventArgs
  */
 public function annotationValidator(AnnotationEventArgs $eventArgs)
 {
     $annotation = $eventArgs->getAnnotation();
     if ($eventArgs->getEventType() == EventType::DOCUMENT) {
         $this->setDocumentValidator($eventArgs, ['class' => $annotation->class, 'options' => $annotation->options]);
     } else {
         $this->setFieldValidator($eventArgs, ['class' => $annotation->class, 'options' => $annotation->options]);
     }
 }
Esempio n. 10
0
 /**
  *
  * @param \Zoop\Shard\Annotation\AnnotationEventArgs $eventArgs
  */
 public function annotationUnserializerCollection(AnnotationEventArgs $eventArgs)
 {
     $metadata = $eventArgs->getMetadata();
     $annotation = $eventArgs->getAnnotation();
     $serializeMetadata = $this->getSerializerMetadata($metadata);
     $serializeMetadata['fields'][$eventArgs->getReflection()->getName()]['collectionType'] = $annotation->type;
     $metadata->setSerializer($serializeMetadata);
 }
Esempio n. 11
0
 /**
  *
  * @param \Zoop\Shard\Annotation\EventArgs $eventArgs
  */
 public function annotationZones(AnnotationEventArgs $eventArgs)
 {
     $metadata = $eventArgs->getMetadata();
     $metadata->addProperty('zones', true);
     $metadata->setZones($eventArgs->getReflection()->getName());
 }