@@ -4,7 +4,6 @@ Symfony bundle for [webfactory/content-mapping](https://github.com/webfactory/co
44Synchronizers as services, you can use the provided console commands to list and start them. This is useful e.g. for
55cronjobs.
66
7-
87## Installation
98
109Install 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
6967If 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
7977you'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
8582This 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 ) .
0 commit comments