Skip to content

Support toggling underscore detection on all attributes in normalizer #12212

Closed
@atrauzzi

Description

@atrauzzi

I noticed that the GetSetMethodNormalizer that comes with Serializer doesn't support toggling the detection and conversion of underscores from all fields provided.

I've mitigated this by creating my own subclass as follows:

class GetSetMethodNormalizer extends Base {

    protected function formatAttribute($attributeName) {
        return preg_replace_callback(
            '/(^|_|\.)+(.)/',
            function ($match) {
                return ('.' === $match[1] ? '_' : '') . strtoupper($match[2]);
            },
            $attributeName
        );
    }

}

This appears to have handled things so far, but I'm wondering if it might be nice to formalize this as a setting in GetSetMethodNormalizer?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions