ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\EagerLoadingExtension::getSerializerGroups PHP Méthode

getSerializerGroups() private méthode

Gets serializer groups if available, if not it returns the $options array.
private getSerializerGroups ( string $resourceClass, array $options, string $context ) : array
$resourceClass string
$options array represents the operation name so that groups are the one of the specific operation
$context string normalization_context or denormalization_context
Résultat array
    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']];
    }