所以我有一個自定義的Drupal 8遷移,我們從XML導入節點 - 一切都很好。現在我想添加一個預導入功能,以便在遷移之前。在Drupal 7 Migrate中有preImport() - Drupal 8的方法是什麼?我發現這篇文章關於Events added to migration process,但它仍然不清楚如何繼續......感謝您的任何提示!遷移預導入事件/事件偵聽器
0
A
回答
0
您需要創建自己的事件訂戶,這裏的簡短說明:https://www.chapterthree.com/blog/how-to-register-event-subscriber-drupal8
這裏的EventSubscriber(my_migration/src目錄/ EventSubscriber/PreImportEvent.php)的具體例子:
<?php
namespace Drupal\my_migration\EventSubscriber;
use Drupal\migrate\Event\MigrateEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Class PreImportEvent
*
* @package Drupal\my_migration\EventSubscriber
*/
class PreImportEvent implements EventSubscriberInterface {
/**
* @return mixed
*/
public static function getSubscribedEvents() {
$events[MigrateEvents::PRE_IMPORT][] = [
'preImport',
0,
];
return $events;
}
/**
* @param $event
*/
public function preImport($event) {
// Do whatever you want with $event
}
}
現在您需要爲您的EventSubscriber(my_migration/my_migration.services.yml)註冊服務:
services:
my_migration.subscriber.pre_import:
class: Drupal\my_migration\EventSubscriber\PreImportEvent
tags:
- { name: event_subscriber }
注意:如果你需要改變您的每個字段的遷移基數,您最好使用進程插件(https://www.drupal.org/docs/8/api/migrate-api/migrate-process-plugins)。
相關問題
- 1. 事件偵聽器
- 2. 將事件偵聽器傳遞給事件偵聽器?
- 3. JW6事件 - 事件偵聽
- 4. 事件偵聽器5
- 5. 事件偵聽器在evently
- 6. 蠟染事件偵聽器
- 7. ZF3 onRoute事件偵聽器
- 8. reactjs事件偵聽器window.resize
- 9. 事件偵聽環
- 10. 添加事件偵聽器,以形成由事件監聽器
- 11. 將一個事件偵聽器更改爲另一個事件偵聽器?
- 12. Flex移動偵聽事件<s:View>
- 13. 事件偵聽通知其他事件
- 14. NodeJS事件循環與事件偵聽
- 15. 瀏覽器和viewer.container事件偵聽器
- 16. 的Symfony2式事件偵聽
- 17. JavaScript事件偵聽非輸入元素
- 18. 如何刪除事件偵聽器?
- 19. 如何「範圍」事件偵聽器?
- 20. XMLHTTPRequest事件偵聽器不工作?
- 21. jQuery keypress()事件偵聽器問題
- 22. ActionScript中,對象和事件偵聽器
- 23. Hibernate事件偵聽器 - postFlush等效
- 24. 將事件偵聽器添加到iframe
- 25. TypeScript自定義事件偵聽器
- 26. while循環忽略事件偵聽器
- 27. 添加事件偵聽器的錯誤
- 28. Android - 如何偵聽器系統事件?
- 29. 重複事件偵聽器的數量?
- 30. 如何刪除事件偵聽器?