content-mapping-bundle
Symfony bundle for webfactory/content-mapping. If you configure your
Synchronizers as services, you can use the provided console commands to list and start them. This is useful e.g. for
cronjobs., (*1)
Installation
Install the package via composer, (*2)
composer require webfactory/content-mapping-bundle
and enable the bundle in your app kernel:, (*3)
<?php
// app/AppKernel.php
public function registerBundles()
{
// ...
$bundles[] = new Webfactory\ContentMappingBundle\WebfactoryContentMappingBundle();
// ...
}
Usage
First, register your Synchronizers as a service, e.g. in your services.xml:, (*4)
<service class="Webfactory\ContentMapping\Synchronizer">
<!-- SourceAdapter -->
<argument type="service">
<service class="Webfactory\ContentMapping\SourceAdapter\Doctrine\GenericDoctrineSourceAdapter">
<!-- Doctrine Repository -->
<argument type="service">
<service class="MyVendor\MyBundle\Entity\MyEntityRepository" factory-service="doctrine.orm.entity_manager" factory-method="getRepository">
<argument>MyVendorMyEntityBundle:MyEntity</argument>
</service>
</argument>
<!-- Name of the repository method to query -->
<argument type="string">findForSolrIndex</argument>
</service>
</argument>
<!-- Mapper -->
<argument type="service">
<service class="MyVendor\MyBundle\ContentMapping\MyEntityMapper" />
</argument>
<!-- DestinationAdapter -->
<argument type="service" id="contentmapping.destinationadapter.solarium"/>
<!-- PSR3-logger -->
<argument type="service" id="logger" />
<tag name="monolog.logger" channel="solr" />
<!-- Tag to mark the service as a Synchronizer -->
<tag name="contentmapping.synchronizer" objectclass="\JugendFuerEuropa\Bundle\JugendInAktionBundle\Entity\Mitarbeiter" />
</service>
If you've tagged your service as in the example above, you can use the console command, (*5)
app/console content-mapping:list-synchronizers
to list your registered synchronizers denoted by their objectclass, and, (*6)
app/console content-mapping:synchronize
to start them. Use -o objectclass to start only the Synchronizer for the objectclass and -f to force updates in
the destination systems even if no changes are detected. Be aware that objectclass is not the name of your entity class
you'd like to synchronize, but the value you defined in the service definition (see above). Note that backslashes in your
objectclass need to be escaped (with backslashes)., (*7)
Credits, Copyright and License
This project was started at webfactory GmbH, Bonn., (*8)
Copyright 2015-2022 webfactory GmbH, Bonn. Code released under the MIT license., (*9)