Open tacman opened 5 years ago
yay, + one. We need this for symfony 4.3+.
Let me help here, feel free to add this to the documentation:
services.yaml:
MartinGeorgiev\SocialPost\Publisher: '@social_post'
In your Controller:
use MartinGeorgiev\SocialPost\Publisher as SocialPublisher;
use MartinGeorgiev\SocialPost\Message as SocialMessage;
...
public function myFunction (SocialPublisher $publisher) {
...
$post = new SocialMessage('post content here');
$publisher->publish($post);
...
}
Is you want to use it in a service, just pass SocialPublisher to the __construct method. Hope this helps.
Can you add an example in the documentation showing how to call the service via Dependency Injection, that than through the container?
That's Symfony's best practice recommendations now.
Thanks.