DEV Community

Discussion on: Improve your factories in Symfony

Collapse
 
vasilvestre profile image
Valentin Silvestre • Edited

I love this pattern ! It's really clean.
You could even simplify it using tagged_iterator.

_instanceof:
        App\ChannelHandlerInterface:
            tags: ['app.channel_handler']

App\ChannelFactory:
    arguments:
      - !tagged_iterator app.channel_handler
Enter fullscreen mode Exit fullscreen mode

Thanks to DI feature, you do not have to declare anything manually !

The idea come from Thibault Richard (github.com/t-richard) :)

Collapse
 
mguinea profile image
Marc Guinea

Wow! looks awesome! even better, thanks for sharing

Collapse
 
vasilvestre profile image
Valentin Silvestre

I think you could update your post with it ;)

Thread Thread
 
mguinea profile image
Marc Guinea

Done! many thanks :)