private function getSerializerGroups(string $resourceClass, array $options, string $context) : array
{
$resourceMetadata = $this->resourceMetadataFactory->create($resourceClass);
if (isset($options['collection_operation_name'])) {
$context = $resourceMetadata->getCollectionOperationAttribute($options['collection_operation_name'], $context, null, true);
} elseif (isset($options['item_operation_name'])) {
$context = $resourceMetadata->getItemOperationAttribute($options['item_operation_name'], $context, null, true);
} else {
$context = $resourceMetadata->getAttribute($context);
}
if (empty($context['groups'])) {
return $options;
}
return ['serializer_groups' => $context['groups']];
}