Override Symfony getter and setter generator method

311 Views Asked by At

I have to code on an existing project where the getter and setter in entity files are in Pascal Case (more commonly known as Upper Camel Case where the first letter of the first word is capitalized). e.g. public function GetId(..., public function SetId(...

The project follows strictly Pascal Case naming style even for functions.

When the entities were generated, the getters and setters were renamed manually by the developers.

Symfony make:entity generates getters and setters in camel case.

I would like to know where the getter and setter generators are located in symfony and if it is possible to override/extend the classes in order to make them generate in pascal case so that I or another developer does not hav to update the new getters and setter to pascal case manually

Maybe it only need to be set in a config file but I am not sure

1

There are 1 best solutions below

2
Olexandr Shaposhnyk On

You can change the MakeEntity class code, the line that is responsible for the formation of style methods is 618 (https://github.com/symfony/maker-bundle/blob/main/src/Maker/MakeEntity.php)

Or create your own class, the only difference will be a different format of method name (https://symfony.com/bundles/SymfonyMakerBundle/current/index.html).