/** * * @param \Sds\DoctrineExtensions\Annotation\AnnotationEventArgs $eventArgs */ public function annotationBasicPermission(AnnotationEventArgs $eventArgs) { $annotation = $eventArgs->getAnnotation(); $metadata = $eventArgs->getMetadata(); if (!isset($metadata->permissions)) { $metadata->permissions = []; } $metadata->permissions[] = ['factory' => 'Sds\\DoctrineExtensions\\AccessControl\\BasicPermissionFactory', 'options' => ['roles' => is_array($annotation->roles) ? $annotation->roles : [$annotation->roles], 'allow' => is_array($annotation->allow) ? $annotation->allow : [$annotation->allow], 'deny' => is_array($annotation->deny) ? $annotation->deny : [$annotation->deny]]]; }
/** * * @param \Sds\DoctrineExtensions\Annotation\AnnotationEventArgs $eventArgs */ public function annotationRestCache(AnnotationEventArgs $eventArgs) { $annotation = $eventArgs->getAnnotation(); $metadata = $eventArgs->getMetadata(); if (!isset($metadata->rest)) { $metadata->rest = []; } $cache = []; if ($annotation->public) { $cache['public'] = true; } if ($annotation->private) { $cache['private'] = true; } if ($annotation->noCache) { $cache['no-cache'] = true; } if ($annotation->maxAge) { $cache['max-age'] = true; } $metadata->rest = array_merge($metadata->rest, ['cache' => $cache]); }
/** * * @param \Sds\DoctrineExtensions\Annotation\AnnotationEventArgs $eventArgs */ public function annotationRoles(AnnotationEventArgs $eventArgs) { if ($eventArgs->getAnnotation()->value) { $eventArgs->getMetadata()->roles = $eventArgs->getReflection()->getName(); } }
/** * * @param \Sds\DoctrineExtensions\Annotation\AnnotationEventArgs $eventArgs */ public function annotationReadonly(AnnotationEventArgs $eventArgs) { $annotation = $eventArgs->getAnnotation(); $eventArgs->getMetadata()->fieldMappings[$eventArgs->getReflection()->getName()]['readonly'] = true; }
/** * * @param \Sds\DoctrineExtensions\Annotation\AnnotationEventArgs $eventArgs */ public function annotationDojoJsonRest(AnnotationEventArgs $eventArgs) { $annotation = $eventArgs->getAnnotation(); if ($annotation->generate) { $metadata = $eventArgs->getMetadata(); $metadata->generator[Generator\JsonRest::getResourceName($metadata->name)] = ['event' => Generator\JsonRest::event, 'options' => ['mixins' => $annotation->mixins, 'params' => $annotation->params]]; } }
/** * * @param \Sds\DoctrineExtensions\Annotation\AnnotationEventArgs $eventArgs */ public function annotationAccessControlIgnoreUpdate(AnnotationEventArgs $eventArgs) { if ($eventArgs->getAnnotation()->value) { $eventArgs->getMetadata()->accessControl['ignoreUpdate'][] = $eventArgs->getReflection()->getName(); } }
/** * * @param \Sds\DoctrineExtensions\Annotation\AnnotationEventArgs $eventArgs */ public function annotationSerializerReferenceSerializer(AnnotationEventArgs $eventArgs) { $metadata = $eventArgs->getMetadata(); $annotation = $eventArgs->getAnnotation(); $this->createMetadata($metadata); $metadata->serializer['fields'][$eventArgs->getReflection()->getName()]['referenceSerializer'] = $annotation->value; }
/** * * @param \Sds\DoctrineExtensions\Annotation\AnnotationEventArgs $eventArgs */ public function annotationValidator(AnnotationEventArgs $eventArgs) { $annotation = $eventArgs->getAnnotation(); switch ($eventArgs->getEventType()) { case EventType::document: $this->addDocumentValidator($eventArgs, ['class' => $annotation->class, 'options' => $annotation->options]); break; break; case EventType::field: $this->addFieldValidator($eventArgs, ['class' => $annotation->class, 'options' => $annotation->options]); break; } }