私はsonataNotificationBundleを統合し、バックエンドをドクトリンに設定しました。メールはデータベースのnotification__messageテーブルに保存されていますが、送信されていません。
swiftmailer コンシューマーを使用してデータベースからメールを送信するにはどうすればよいですか。以下は構成です
sonata_notification:
backend: sonata.notification.backend.doctrine
backends:
doctrine:
message_manager: sonata.notification.manager.message.default
max_age: 86400 # max age in second
pause: 500000 # delay in microseconds
states: # raising errors level
in_progress: 10
error: 20
open: 100
done: 10000
バックエンド開始コマンドで --type=mailer に言及したにもかかわらず、ログのクエリは常にデフォルトのタイプを検索します
consumer.yml に SwiftMailerConsumer をイベントリスナーとして登録し、
<service id="sonata.notification.consumer.swift_mailer" class="Sonata\NotificationBundle\Consumer\SwiftMailerConsumer">
<tag name="sonata.notification.consumer" type="mailer" />
<tag name="sonata.notification.consumer.event_listener" event="default" method="process" />
<argument type="service" id="mailer" />
</service>
MessageManagerBackend->handle メソッドでは「default」イベントが送出され、
$dispatcher->dispatch($message->getType(), $event);
以下はログです
[2013-07-12 19:55:16] doctrine.DEBUG: t0.type を type1 として、t0.body を body2 として、t0.state を state3 として、t0.restart_count を restart_count4 として、t0.created_at を created_at5 として、t0.updated_at を選択します。 update_at6、t0.started_at AS started_at7、t0.completed_at AS completed_at8、t0.id AS id9 FROM notification__message t0 WHERE t0.state = ? AND t0.type = ? LIMIT 10 [0,"デフォルト"] []
メーラー用に別のバックエンドを作成し、このように config.yml で構成する必要がありますか?
sonata_notification:
backend: sonata.notification.backend.doctrine
consumer:
swift_mailer:
path: %kernel.root_dir%/../vendor/swiftmailer
backends:
doctrine:
message_manager: sonata.notification.manager.message.mailer