Skip to content

Commit 5d56389

Browse files
committed
Provides an integration with the Symfony Messenger component
1 parent f8693d1 commit 5d56389

File tree

5 files changed

+22
-1
lines changed

5 files changed

+22
-1
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"symfony/framework-bundle": "^3.3 || ^4.0",
6161
"symfony/mercure": "*",
6262
"symfony/mercure-bundle": "*",
63-
"symfony/messenger": "^4.1",
63+
"symfony/messenger": "^4.2",
6464
"symfony/phpunit-bridge": "^3.3 || ^4.0",
6565
"symfony/routing": "^3.3 || ^4.0",
6666
"symfony/security": "^3.0 || ^4.0",

src/Annotation/ApiResource.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
* @Attribute("itemOperations", type="array"),
4343
* @Attribute("maximumItemsPerPage", type="int"),
4444
* @Attribute("mercure", type="mixed"),
45+
* @Attribute("messenger", type="bool"),
4546
* @Attribute("normalizationContext", type="array"),
4647
* @Attribute("order", type="array"),
4748
* @Attribute("outputClass", type="mixed"),
@@ -183,6 +184,13 @@ final class ApiResource
183184
*/
184185
private $mercure;
185186

187+
/**
188+
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
189+
*
190+
* @var bool
191+
*/
192+
private $messenger;
193+
186194
/**
187195
* @see https://github.com/Haehnchen/idea-php-annotation-plugin/issues/112
188196
*

src/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
3838
use Symfony\Component\Finder\Finder;
3939
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
40+
use Symfony\Component\Messenger\MessageBusInterface;
4041
use Symfony\Component\Validator\Validator\ValidatorInterface;
4142
use Symfony\Component\Yaml\Yaml;
4243

@@ -145,6 +146,10 @@ public function load(array $configs, ContainerBuilder $container)
145146
$this->registerValidatorConfiguration($container, $config);
146147
$this->registerDataCollectorConfiguration($container, $config, $loader);
147148
$this->registerMercureConfiguration($container, $config, $loader, $useDoctrine);
149+
150+
if (interface_exists(MessageBusInterface::class)) {
151+
$loader->load('messenger.xml');
152+
}
148153
}
149154

150155
/**

tests/Annotation/ApiResourceTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,15 @@ public function testConstruct()
3838
'formats' => ['foo', 'bar' => ['application/bar']],
3939
'filters' => ['foo', 'bar'],
4040
'graphql' => ['query' => ['normalization_context' => ['groups' => ['foo', 'bar']]]],
41+
'inputClass' => 'Foo',
4142
'iri' => 'http://example.com/res',
4243
'itemOperations' => ['foo' => ['bar']],
4344
'maximumItemsPerPage' => 42,
4445
'mercure' => '[\'foo\', object.owner]',
46+
'messenger' => true,
4547
'normalizationContext' => ['groups' => ['bar']],
4648
'order' => ['foo', 'bar' => 'ASC'],
49+
'outputClass' => 'Bar',
4750
'paginationClientEnabled' => true,
4851
'paginationClientItemsPerPage' => true,
4952
'paginationClientPartial' => true,
@@ -74,10 +77,13 @@ public function testConstruct()
7477
'force_eager' => false,
7578
'formats' => ['foo', 'bar' => ['application/bar']],
7679
'filters' => ['foo', 'bar'],
80+
'input_class' => 'Foo',
7781
'maximum_items_per_page' => 42,
7882
'mercure' => '[\'foo\', object.owner]',
83+
'messenger' => true,
7984
'normalization_context' => ['groups' => ['bar']],
8085
'order' => ['foo', 'bar' => 'ASC'],
86+
'output_class' => 'Bar',
8187
'pagination_client_enabled' => true,
8288
'pagination_client_items_per_page' => true,
8389
'pagination_client_partial' => true,

tests/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,7 @@ private function getBaseContainerBuilderProphecy()
767767
'api_platform.validator',
768768
'api_platform.mercure.listener.response.add_link_header',
769769
'api_platform.doctrine.listener.mercure.publish',
770+
'api_platform.messenger.data_persister',
770771
];
771772

772773
foreach ($definitions as $definition) {
@@ -775,6 +776,7 @@ private function getBaseContainerBuilderProphecy()
775776

776777
$aliases = [
777778
'api_platform.http_cache.purger' => 'api_platform.http_cache.purger.varnish',
779+
'api_platform.message_bus' => 'message_bus',
778780
EagerLoadingExtension::class => 'api_platform.doctrine.orm.query_extension.eager_loading',
779781
FilterExtension::class => 'api_platform.doctrine.orm.query_extension.filter',
780782
FilterEagerLoadingExtension::class => 'api_platform.doctrine.orm.query_extension.filter_eager_loading',

0 commit comments

Comments
 (0)