PHP code example of webfactory / content-mapping-bundle
1. Go to this page and download the library: Download webfactory/content-mapping-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
webfactory / content-mapping-bundle example snippets
// app/AppKernel.php
public function registerBundles()
{
// ...
$bundles[] = new Webfactory\ContentMappingBundle\WebfactoryContentMappingBundle();
// ...
}
use MyVendor\MyBundle\ContentMapping\MyEntityMapper;
use MyVendor\MyBundle\Entity\MyEntity;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Webfactory\ContentMapping\SourceAdapter\Doctrine\GenericDoctrineSourceAdapter;
use Webfactory\ContentMapping\Synchronizer;
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
return static function (ContainerConfigurator $container): void {
$services = $container->services();
$services->set('my_entity.source_adapter', GenericDoctrineSourceAdapter::class)
->args([
service('doctrine.orm.entity_manager')->call('getRepository', [MyEntity::class]), // Doctrine Repository
'findForSolrIndex', // Name of the repository method to query
]);
$services->set(MyEntityMapper::class)
->autowire();
$services->set('my_entity.synchronizer', Synchronizer::class)
->args([
service('my_entity.source_adapter'), // SourceAdapter
service(MyEntityMapper::class), // Mapper
service('contentmapping.destinationadapter.solarium'), // DestinationAdapter
service('logger'), // PSR3-logger
])
->tag('monolog.logger', ['channel' => 'solr'])
->tag('contentmapping.synchronizer', ['objectclass' => MyEntity::class]);
// other Synchronizers...
};
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.