Get serialization context groups in controller

I have the problem that depending on user rights, there are different context groups used, and I can’t find the place where the context groups are set.

For debugging issues I’m searching an possibility to find out which serialization context group an api call is using. This is my code:


namespace AppBundleControllerApiUpload;

use AppBundleEntityUploadUploadRepository;
use AppBundleEntityUploadUploadType;
use AppBundleEntityUploadUploadTypeRepository;

use DoctrineORMORMException;
use GuzzleHttpPsr7UploadedFile;
use SymfonyBundleFrameworkBundleControllerController;
use NelmioApiDocBundleAnnotationApiDoc;
use ApiPlatformCoreAnnotationApiResource;
use SymfonyComponentHttpFoundationJsonResponse;
use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentRoutingAnnotationRoute;
use SensioBundleFrameworkExtraBundleConfigurationMethod;
use AppBundleGeneralRegistry;
use SymfonyComponentSecurityCoreExceptionBadCredentialsException;
use SymfonyComponentSerializerNormalizerDataUriNormalizer;
use AppBundleEntityUploadUpload;
use AppBundleEntityApplicationApplicationData;
use SymfonyComponentHttpFoundationBinaryFileResponse;
use SymfonyComponentSerializerSerializer;

 * Class UploadController
 * @package AppBundleControllerApiUpload
 * @ApiDoc()
 * @ApiResource(attributes={"pagination_enabled"=true})
class UploadController extends Controller
     * Get an upload.
     * @ApiDoc(
     *     resource=true,
     *     description="gets an upload",
     * )
     * @Route(
     *     name="getUploadSpecial",
     *     path="/fileuploads/{id}",
     *     defaults={"_api_resource_class"=Upload::class, "_api_item_operation_name"="getUpload"}
     * )
     * @Method("GET")
     * @param Upload $data
     * @return null|string
    public function getUploadAction($data)
        // here I'd like to return the serialization context group
        return $data;

Is there the possibility to get the serialization context group in the controller?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *