1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Zenstruck\Messenger\Test\Tests\Fixture; |
4
|
|
|
|
5
|
|
|
use Symfony\Bundle\FrameworkBundle\FrameworkBundle; |
6
|
|
|
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; |
7
|
|
|
use Symfony\Component\Config\Loader\LoaderInterface; |
8
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
9
|
|
|
use Symfony\Component\HttpFoundation\Response; |
10
|
|
|
use Symfony\Component\HttpKernel\Kernel as BaseKernel; |
11
|
|
|
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; |
12
|
|
|
use Symfony\Component\Routing\RouteCollectionBuilder; |
13
|
|
|
use Zenstruck\Messenger\Test\Tests\Fixture\Messenger\MessageA; |
14
|
|
|
use Zenstruck\Messenger\Test\ZenstruckMessengerTestBundle; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @author Kevin Bond <[email protected]> |
18
|
|
|
*/ |
19
|
|
|
class Kernel extends BaseKernel |
20
|
|
|
{ |
21
|
|
|
use MicroKernelTrait; |
|
|
|
|
22
|
|
|
|
23
|
|
|
public function dispatch(): Response |
24
|
|
|
{ |
25
|
|
|
$this->getContainer()->get('message_bus')->dispatch(new MessageA()); |
26
|
|
|
|
27
|
|
|
return new Response(); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function registerBundles(): iterable |
31
|
|
|
{ |
32
|
|
|
yield new FrameworkBundle(); |
33
|
|
|
yield new ZenstruckMessengerTestBundle(); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader): void |
|
|
|
|
37
|
|
|
{ |
38
|
|
|
$loader->load(\sprintf('%s/config/%s.yaml', __DIR__, $this->getEnvironment())); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @param RouteCollectionBuilder|RoutingConfigurator $routes |
43
|
|
|
*/ |
44
|
|
|
protected function configureRoutes($routes): void // @phpstan-ignore-line |
45
|
|
|
{ |
46
|
|
|
if ($routes instanceof RouteCollectionBuilder) { // @phpstan-ignore-line |
47
|
|
|
$routes->add('/dispatch', 'kernel::dispatch'); // @phpstan-ignore-line |
48
|
|
|
|
49
|
|
|
return; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
$routes->add('dispatch', '/dispatch')->controller('kernel::dispatch'); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|