minor #27100 [Messenger] Late collect & clone messages (ogizanagi)
This PR was merged into the 4.1-dev branch.
Discussion
----------
[Messenger] Late collect & clone messages
| Q | A
| ------------- | ---
| Branch? | master <!-- see below -->
| Bug fix? | no
| New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks? | no <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass? | yes <!-- please add some, will be required by reviewers -->
| Fixed tickets | N/A <!-- #-prefixed issue number(s), if any -->
| License | MIT
| Doc PR | N/A
Commits
-------
eb943619b1
[Messenger] Late collect & clone messages
This commit is contained in:
commit
74aa51507f
@ -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