- Issue created by @Peacog
- πͺπΈSpain Peacog
Peacog β changed the visibility of the branch 3454659-duplicate-detection-service to hidden.
- πͺπΈSpain Peacog
Peacog β changed the visibility of the branch 3454659-duplicate-detection-service to active.
- πͺπΈSpain Peacog
Peacog β changed the visibility of the branch 3454659-duplicate-detection-service to hidden.
- πͺπΈSpain Peacog
Peacog β changed the visibility of the branch 3454659-implement-duplicate-detection to hidden.
- πͺπΈSpain Peacog
Peacog β changed the visibility of the branch 3454659-implement-duplicate-detection to active.
- πͺπΈSpain Peacog
Peacog β changed the visibility of the branch 2.0.x to hidden.
- @peacog opened merge request.
- Status changed to Needs review
7 months ago 3:20pm 14 June 2024 - πͺπΈSpain Peacog
Here's an example of the custom pre-import event that uses the service in this patch.
<?php namespace Drupal\my_custom_migrate\EventSubscriber; use Drupal\migrate\Event\MigrateImportEvent; use Drupal\migrate_file_to_media\Services\DuplicateDetectionService; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Drupal\migrate\Event\MigrateEvents; /** * Custom migrate event subscriber. */ class MyCustomMigrateSubscriber implements EventSubscriberInterface { /** * The duplicate file detection service. * * @var \Drupal\migrate_file_to_media\Services\DuplicateDetectionService */ protected DuplicateDetectionService $duplicateDetectionService; /** * Constructs a MyCustomMigrateSubscriber object. * * @param \Drupal\migrate_file_to_media\Services\DuplicateDetectionService $duplicateDetectionService * The search links service. */ public function __construct(DuplicateDetectionService $duplicateDetectionService) { $this->duplicateDetectionService = $duplicateDetectionService; } /** * Run migrate:duplicate-file-detection before migrate_file_to_media * migrations. ** * @param \Drupal\migrate\Event\MigrateImportEvent $event * Response event. */ public function onPreImport(MigrateImportEvent $event) { $config = $event->getMigration()->getPluginDefinition(); if (($config['source']['plugin'] ?? '') !== 'media_entity_generator_d7') { return; } // Run the migrate:duplicate-file-detection command for the migration. $this->duplicateDetectionService->duplicateFileDetection($config['id'], [FALSE, TRUE]); } /** * {@inheritdoc} */ public static function getSubscribedEvents() { return [ MigrateEvents::PRE_IMPORT => ['onPreImport'], ]; } }
- Status changed to Needs work
24 days ago 8:21am 3 December 2024