ApiPlatform\Core\Metadata\Property\Factory\SerializerPropertyMetadataFactory::getEffectiveSerializerGroups PHP Méthode

getEffectiveSerializerGroups() private méthode

Groups are extracted in the following order: - From the "serializer_groups" key of the $options array. - From metadata of the given operation ("collection_operation_name" and "item_operation_name" keys). - From metadata of the current resource.
private getEffectiveSerializerGroups ( array $options, string $resourceClass ) : array
$options array
$resourceClass string
Résultat array
    private function getEffectiveSerializerGroups(array $options, string $resourceClass) : array
    {
        if (isset($options['serializer_groups'])) {
            return [$options['serializer_groups'], $options['serializer_groups']];
        }
        $resourceMetadata = $this->resourceMetadataFactory->create($resourceClass);
        if (isset($options['collection_operation_name'])) {
            $normalizationContext = $resourceMetadata->getCollectionOperationAttribute($options['collection_operation_name'], 'normalization_context', null, true);
            $denormalizationContext = $resourceMetadata->getCollectionOperationAttribute($options['collection_operation_name'], 'denormalization_context', null, true);
        } elseif (isset($options['item_operation_name'])) {
            $normalizationContext = $resourceMetadata->getItemOperationAttribute($options['item_operation_name'], 'normalization_context', null, true);
            $denormalizationContext = $resourceMetadata->getItemOperationAttribute($options['item_operation_name'], 'denormalization_context', null, true);
        } else {
            $normalizationContext = $resourceMetadata->getAttribute('normalization_context');
            $denormalizationContext = $resourceMetadata->getAttribute('denormalization_context');
        }
        return [$normalizationContext['groups'] ?? null, $denormalizationContext['groups'] ?? null];
    }