[Messenger] Late collect & clone messages
This commit is contained in:
parent
295eaed098
commit
eb943619b1
@ -14,6 +14,7 @@ namespace Symfony\Component\Messenger\DataCollector;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
|
||||
use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface;
|
||||
use Symfony\Component\Messenger\TraceableMessageBus;
|
||||
|
||||
/**
|
||||
@ -21,7 +22,7 @@ use Symfony\Component\Messenger\TraceableMessageBus;
|
||||
*
|
||||
* @experimental in 4.1
|
||||
*/
|
||||
class MessengerDataCollector extends DataCollector
|
||||
class MessengerDataCollector extends DataCollector implements LateDataCollectorInterface
|
||||
{
|
||||
private $traceableBuses = array();
|
||||
|
||||
@ -34,6 +35,14 @@ class MessengerDataCollector extends DataCollector
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function collect(Request $request, Response $response, \Exception $exception = null)
|
||||
{
|
||||
// Noop. Everything is collected live by the traceable buses & cloned as late as possible.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function lateCollect()
|
||||
{
|
||||
$this->data = array('messages' => array());
|
||||
|
||||
|
@ -12,8 +12,6 @@
|
||||
namespace Symfony\Component\Messenger\Tests\DataCollector;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Messenger\DataCollector\MessengerDataCollector;
|
||||
use Symfony\Component\Messenger\MessageBusInterface;
|
||||
use Symfony\Component\Messenger\Tests\Fixtures\DummyMessage;
|
||||
@ -43,7 +41,7 @@ class MessengerDataCollectorTest extends TestCase
|
||||
|
||||
$bus->dispatch($message);
|
||||
|
||||
$collector->collect(Request::create('/'), new Response());
|
||||
$collector->lateCollect();
|
||||
|
||||
$messages = $collector->getMessages();
|
||||
$this->assertCount(1, $messages);
|
||||
@ -120,7 +118,7 @@ DUMP
|
||||
// Ignore.
|
||||
}
|
||||
|
||||
$collector->collect(Request::create('/'), new Response());
|
||||
$collector->lateCollect();
|
||||
|
||||
$messages = $collector->getMessages();
|
||||
$this->assertCount(1, $messages);
|
||||
|
Reference in New Issue
Block a user