| @@ 8-33 (lines=26) @@ | ||
| 5 | use Psr\Log\LoggerInterface; | |
| 6 | use Happyr\SimpleBusBundle\Message\Command\Ping; | |
| 7 | ||
| 8 | class PingHandler | |
| 9 | { | |
| 10 | /** | |
| 11 | * @var LoggerInterface | |
| 12 | */ | |
| 13 | private $logger; | |
| 14 | ||
| 15 | /** | |
| 16 | * @param LoggerInterface $logger | |
| 17 | */ | |
| 18 | public function __construct(LoggerInterface $logger = null) | |
| 19 |     { | |
| 20 | $this->logger = $logger; | |
| 21 | } | |
| 22 | ||
| 23 | public function handle(Ping $command) | |
| 24 |     { | |
| 25 | $data = $command->getData(); | |
| 26 | ||
| 27 |         if ($this->logger !== null) { | |
| 28 |             $this->logger->error('Ping command handler works!', ['data' => $data]); | |
| 29 | } | |
| 30 | ||
| 31 | return; | |
| 32 | } | |
| 33 | } | |
| 34 | ||
| @@ 8-33 (lines=26) @@ | ||
| 5 | use Psr\Log\LoggerInterface; | |
| 6 | use Happyr\SimpleBusBundle\Message\Event\Pong; | |
| 7 | ||
| 8 | class WhenPongWriteLog | |
| 9 | { | |
| 10 | /** | |
| 11 | * @var LoggerInterface | |
| 12 | */ | |
| 13 | private $logger; | |
| 14 | ||
| 15 | /** | |
| 16 | * @param LoggerInterface $logger | |
| 17 | */ | |
| 18 | public function __construct(LoggerInterface $logger = null) | |
| 19 |     { | |
| 20 | $this->logger = $logger; | |
| 21 | } | |
| 22 | ||
| 23 | public function notify(Pong $event) | |
| 24 |     { | |
| 25 | $data = $event->getData(); | |
| 26 | ||
| 27 |         if ($this->logger !== null) { | |
| 28 |             $this->logger->error('Pong event subscriber works!', ['data' => $data]); | |
| 29 | } | |
| 30 | ||
| 31 | return; | |
| 32 | } | |
| 33 | } | |
| 34 | ||