webfactory / content-mapping-destinationadapter-solarium-bundle
Installs: 10 540
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 9
Forks: 1
Open Issues: 0
Requires
- php: ^7.2|8.0.*|8.1.*|8.2.*|8.3.*
- nelmio/solarium-bundle: ^2.2|^3.0|^4.0|^5.0
- psr/log: ^1.0|^2.0|^3.0
- solarium/solarium: ^4.2|^5.0|^6.0
- symfony/config: ^2.3|^3.0|^4.0|^5.0|^6.0|^7.0
- symfony/console: ^2.3|^3.0|^4.0|^5.0|^6.0|^7.0
- symfony/dependency-injection: ^2.3|^3.0|^4.0|^5.0|^6.0|^7.0
- symfony/http-kernel: ^2.3|^3.0|^4.0|^5.0|^6.0|^7.0
- webfactory/content-mapping-destinationadapter-solarium: ^1.2.0
README
Symfony bundle for webfactory/content-mapping-destinationadapter-solarium, easing your synchronization life via simple configuration, a services and a console command.
Installation
Install the package via composer:
composer require webfactory/content-mapping-destinationadapter-solarium-bundle
and enable two bundles in your app kernel:
<?php // app/AppKernel.php public function registerBundles() { // ... $bundles[] = new Webfactory\ContentMappingDestinationAdapterSolariumBundle\WebfactoryContentMappingDestinationAdapterSolariumBundle(); $bundles[] = new Nelmio\SolariumBundle\NelmioSolariumBundle(); // ... }
and finally, configure the endpoint for the Solarium client (currently, only the default client with the default endpoint is supported):
// app/config.yml nelmio_solarium: endpoints: default: dsn: http://localhost:8983/solr/your-core # for SolariumBundle 3.x (beta) nelmio_solarium: endpoints: default: host: localhost port: 8983 core: your-core
Usage
The bundle provides a service called contentmapping.destinationadapter.solarium
which you can use to define a
Synchronizer service inside the webfactory/content-mapping mini
framework:
<!-- Resources/config/services.xml --> <!-- Synchronizer for MyEntity ---> <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> <!-- other Synchronizers --->
As a bonus, this bundle provides you with a console command for deleting data from the solr index matching a query:
app/bin content-mapping:solarium:delete-from-index [query=*:*]
Credits, Copyright and License
This project was started at webfactory GmbH, Bonn.
Copyright 2015-2022 webfactory GmbH, Bonn. Code released under the MIT license.