webfactory / content-mapping-bundle
webfactory/content-mapping的Symfony包。
1.7.0
2024-04-22 12:37 UTC
Requires
- php: 7.2.*|7.4.*|8.0.*|8.1.*|8.2.*|8.3.*
- symfony/config: ^2.4|^3.0|^4.0|^5.0|^6.0|^7.0
- symfony/console: ^2.4|^3.0|^4.0|^5.0|^6.0|^7.0
- symfony/dependency-injection: ^2.4|^3.0|^4.0|^5.0|^6.0|^7.0
- symfony/http-kernel: ^2.4|^3.0|^4.0|^5.0|^6.0|^7.0
- webfactory/content-mapping: ^3.0
README
为webfactory/content-mapping提供的Symfony包。如果您将同步器配置为服务,可以使用提供的控制台命令列出和启动它们。这在例如cron作业中很有用。
安装
使用composer安装包
composer require webfactory/content-mapping-bundle
并在您的应用内核中启用该包
<?php // app/AppKernel.php public function registerBundles() { // ... $bundles[] = new Webfactory\ContentMappingBundle\WebfactoryContentMappingBundle(); // ... }
用法
首先,在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 --->
如果您已像示例中那样标记了您的服务,可以使用控制台命令
app/console content-mapping:list-synchronizers
列出您注册的同步器,通过它们的对象类标识,并且
app/console content-mapping:synchronize
启动它们。使用-o objectclass
仅启动具有指定objectclass
的同步器,并使用-f
强制在目标系统中更新,即使没有检测到更改。请注意,objectclass
不是您要同步的实体类的名称,而是您在服务定义中定义的值(见上文)。请注意,您的objectclass
中的反斜杠需要转义(使用反斜杠)。
致谢,版权和许可证
该项目始于webfactory GmbH,波恩。
版权所有 2015-2022 webfactory GmbH,波恩。代码在MIT许可证下发布。