Problem/Motivation
As a developer, I want a queue worker that performs the per-item migration — upload to DAM, change the bundle, populate the DAM fields — resolving dynamic metadata through a mapper, so that each media entity is migrated atomically and safely via cron or Drush with metadata intact.
Acceptance Criteria
Metadata Mapper (MigrationMetadataMapper, service acquia_dam_migration_tools.metadata_mapper):
- Resolves the stored mapping at upload time, reads Drupal field values via
getValue()+getMainPropertyName()(single- and multi-value → string arrays), casts to string, drops empty/NULL values, and returns thefieldsstructure getMetadataFields(EntityInterface $media, string $media_type_id);ALT_TEXT_FIELDspecial-cases the alt-text mapping (getAltTextValues()reading the source field'salt); no static container access
Queue Worker (MediaMigrationQueueWorker):
- Extends
QueueWorkerBase, IDacquia_dam_media_migration,cron = {"time" = 60}, implementsContainerFactoryPluginInterface processItem()— validates payload (media_id,media_type_id); loads media; skips with a log when already migrated (DB check on the asset-id table); loads source file viasource_field_name; collects alt/title forfield_media_image- Uploads via
AcquiaDamUploadService::uploadToDam()(W1) passing['fields' => $this->metadataMapper->getMetadataFields($media, $media_type_id)]alongside filename/profile/description; throws on missing file/URI or failed upload - On success:
changeMediaBundle()(transactional DB update ofmedia+media_field_data), reload, setacquia_dam_asset_id(asset_id/version_id/external_id), set target managed field (display= 1 whensync;alt/titleforacquia_dam_managed_image), save - Progress counters (
updateSuccessCount/updateFailureCount) written under a lock (LockBackendInterface) - Injects:
AcquiaDamUploadService,EntityTypeManager,State,LoggerChannelInterface,FileSystem,LockBackendInterface,MigrationMetadataMapper, database,MigrationQueueService,AcquiaDamMigrationUtilityService
Shared Scaffold Updates:
.services.yml← updated —metadata_mapperservice registration + worker constructor wiring
Tests
- MigrationMetadataMapperTest (unit) — mapping resolution, multi-value fields, casting, empty-value drop, alt-text mapping
- MediaMigrationQueueWorkerTest (kernel) — missing
media_id; missingmedia_type_id; media not found; file not found; skips already-migrated; success (bundle change + asset id + progress); upload fails and re-throws; progress counters increment (upload service mocked)
Issue fork acquia_dam-3618421
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
rajeshreeputraMR merged!