FractalBundle icon indicating copy to clipboard operation
FractalBundle copied to clipboard

Is it possible to "auto" register the transformer without manual register it?

Open fd6130 opened this issue 5 years ago • 0 comments

Not sure does anybody notice this kind of issue or not...

We have to manual register the transformer as a service otherwise we can't use it like this: $resource = new Collection($users, 'app.transformer.user');

The registeration is kind of redundant cause you need to register for each transformer.

To avoid creating a service definition for each transformer, my alternative way is to make Transformer/ public in config/services.yaml:

config/services.yaml

App\Transformer\:
        resource: '../src/Transformer'
        public: true

and use class name instead of service id: $resource = new Collection($users, UserTransformer:class);

But what i am thinking is, it is possible for us to somehow "auto" register it without adding those config by ourself?

fd6130 avatar Oct 26 '20 17:10 fd6130