I am using Messenger in Symfony to send request to create archive of documents
In controller action:
$bus->dispatch(
new ArchiveRequest(
\App\Archiving\SomeSpecialArchiveBuilder::class,
$this->getRequestJsonContent()
)
);
In ArchiveRequestHandler
I want somehow to instantiate this special class and autowire services to it.
class ArchiveRequestHandler implements MessageHandlerInterface
{
public function __invoke(
ArchiveRequest $archiveRequest
)
{
// How can I instantiate special implementation of ArchiveBuilderInterface here and autowire services from container?
}
}