Skip to content

Commit 1dc274c

Browse files
authored
Allow Symfony 8.x to be used (#8)
(internal Case 204755)
1 parent 8a43c14 commit 1dc274c

File tree

2 files changed

+40
-44
lines changed

2 files changed

+40
-44
lines changed

README.md

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ Symfony bundle for [webfactory/content-mapping](https://github.com/webfactory/co
44
Synchronizers as services, you can use the provided console commands to list and start them. This is useful e.g. for
55
cronjobs.
66

7-
87
## Installation
98

109
Install the package via composer
@@ -25,45 +24,44 @@ public function registerBundles()
2524
}
2625
```
2726

28-
2927
## Usage
3028

31-
First, register your Synchronizers as a service, e.g. in your services.xml:
32-
33-
```xml
34-
<!-- Synchronizer for MyEntity --->
35-
<service class="Webfactory\ContentMapping\Synchronizer">
36-
<!-- SourceAdapter -->
37-
<argument type="service">
38-
<service class="Webfactory\ContentMapping\SourceAdapter\Doctrine\GenericDoctrineSourceAdapter">
39-
<!-- Doctrine Repository -->
40-
<argument type="service">
41-
<service class="MyVendor\MyBundle\Entity\MyEntityRepository" factory-service="doctrine.orm.entity_manager" factory-method="getRepository">
42-
<argument>MyVendorMyEntityBundle:MyEntity</argument>
43-
</service>
44-
</argument>
45-
<!-- Name of the repository method to query -->
46-
<argument type="string">findForSolrIndex</argument>
47-
</service>
48-
</argument>
49-
50-
<!-- Mapper -->
51-
<argument type="service">
52-
<service class="MyVendor\MyBundle\ContentMapping\MyEntityMapper" />
53-
</argument>
54-
55-
<!-- DestinationAdapter -->
56-
<argument type="service" id="contentmapping.destinationadapter.solarium"/>
57-
58-
<!-- PSR3-logger -->
59-
<argument type="service" id="logger" />
60-
<tag name="monolog.logger" channel="solr" />
61-
62-
<!-- Tag to mark the service as a Synchronizer -->
63-
<tag name="contentmapping.synchronizer" objectclass="\JugendFuerEuropa\Bundle\JugendInAktionBundle\Entity\Mitarbeiter" />
64-
</service>
29+
First, register your Synchronizers as a service, e.g. in your `config/services.php`:
6530

66-
<!-- other Synchronizers --->
31+
```php
32+
<?php
33+
34+
use MyVendor\MyBundle\ContentMapping\MyEntityMapper;
35+
use MyVendor\MyBundle\Entity\MyEntity;
36+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
37+
use Webfactory\ContentMapping\SourceAdapter\Doctrine\GenericDoctrineSourceAdapter;
38+
use Webfactory\ContentMapping\Synchronizer;
39+
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
40+
41+
return static function (ContainerConfigurator $container): void {
42+
$services = $container->services();
43+
44+
$services->set('my_entity.source_adapter', GenericDoctrineSourceAdapter::class)
45+
->args([
46+
service('doctrine.orm.entity_manager')->call('getRepository', [MyEntity::class]), // Doctrine Repository
47+
'findForSolrIndex', // Name of the repository method to query
48+
]);
49+
50+
$services->set(MyEntityMapper::class)
51+
->autowire();
52+
53+
$services->set('my_entity.synchronizer', Synchronizer::class)
54+
->args([
55+
service('my_entity.source_adapter'), // SourceAdapter
56+
service(MyEntityMapper::class), // Mapper
57+
service('contentmapping.destinationadapter.solarium'), // DestinationAdapter
58+
service('logger'), // PSR3-logger
59+
])
60+
->tag('monolog.logger', ['channel' => 'solr'])
61+
->tag('contentmapping.synchronizer', ['objectclass' => MyEntity::class]);
62+
63+
// other Synchronizers...
64+
};
6765
```
6866

6967
If you've tagged your service as in the example above, you can use the console command
@@ -79,12 +77,10 @@ the destination systems even if no changes are detected. Be aware that `objectcl
7977
you'd like to synchronize, but the value you defined in the service definition (see above). Note that backslashes in your
8078
`objectclass` need to be escaped (with backslashes).
8179

82-
8380
## Credits, Copyright and License
8481

8582
This project was started at webfactory GmbH, Bonn.
8683

8784
- <https://www.webfactory.de>
88-
- <https://twitter.com/webfactory>
8985

90-
Copyright 2015-2022 webfactory GmbH, Bonn. Code released under [the MIT license](LICENSE).
86+
Copyright 2015-2025 webfactory GmbH, Bonn. Code released under [the MIT license](LICENSE).

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313

1414
"require": {
1515
"php": ">= 8.1",
16-
"symfony/config": "^6.4|^7.0",
17-
"symfony/console": "^6.4|^7.0",
18-
"symfony/dependency-injection": "^6.4|^7.0",
19-
"symfony/http-kernel": "^6.4|^7.0",
16+
"symfony/config": "^6.4 || ^7.3 || ^8.0",
17+
"symfony/console": "^6.4 || ^7.3 || ^8.0",
18+
"symfony/dependency-injection": "^6.4 || ^7.3 || ^8.0",
19+
"symfony/http-kernel": "^6.4 || ^7.3 || ^8.0",
2020
"webfactory/content-mapping": "^3.8"
2121
},
2222

0 commit comments

Comments
 (0)