From e0d0cd5417ae3957eec000ff8a01ac11ee3062ea Mon Sep 17 00:00:00 2001 From: Lars Kemper Date: Mon, 18 Aug 2025 13:10:26 +0200 Subject: [PATCH 01/46] feat: add migration logging required fields (#38) --- .gitignore | 37 +- phpstan-baseline.neon | 635 ++++++++++++------ phpstan.neon.dist | 15 + ...gration1754896654TruncateMigrationLogs.php | 26 + ...897550AddRequiredFieldsToMigrationLogs.php | 172 +++++ src/Migration/History/HistoryService.php | 44 +- .../Log/AssociationRequiredMissingLog.php | 67 +- src/Migration/Logging/Log/BaseRunLogEntry.php | 29 +- .../Logging/Log/CannotConvertChildEntity.php | 67 +- .../Logging/Log/CannotConvertEntity.php | 64 +- .../Logging/Log/CannotGetFileRunLog.php | 77 +-- .../Logging/Log/CannotReadEntityCountLog.php | 52 +- .../Logging/Log/DataSetNotFoundLog.php | 47 +- src/Migration/Logging/Log/DebugLog.php | 19 +- .../Logging/Log/DocumentTypeNotSupported.php | 43 +- .../Logging/Log/EmptyNecessaryFieldRunLog.php | 67 +- .../Logging/Log/EntityAlreadyExistsRunLog.php | 64 +- src/Migration/Logging/Log/ExceptionRunLog.php | 55 +- .../Logging/Log/FieldReassignedRunLog.php | 70 +- .../Logging/Log/InvalidUnserializedData.php | 48 +- .../Logging/Log/LogEntryInterface.php | 23 +- .../Logging/Log/MessageQueueExceptionLog.php | 52 +- .../Logging/Log/MimeTypeErrorLog.php | 38 +- .../Logging/Log/ProcessorNotFoundLog.php | 62 +- .../Logging/Log/RunAbortedAutomatically.php | 49 +- .../Logging/Log/TemporaryFileErrorLog.php | 38 +- .../Logging/Log/ThemeCompilingErrorRunLog.php | 39 +- .../Logging/Log/UnknownEntityLog.php | 70 +- .../Logging/Log/UnsupportedObjectType.php | 45 +- .../Logging/Log/WriteExceptionRunLog.php | 43 +- src/Migration/Logging/LoggingService.php | 12 +- .../SwagMigrationLoggingDefinition.php | 17 +- .../Logging/SwagMigrationLoggingEntity.php | 118 +--- .../Processor/HttpDownloadServiceBase.php | 45 +- .../Handler/ProcessMediaHandler.php | 6 +- src/Migration/MigrationContext.php | 4 +- src/Migration/MigrationContextInterface.php | 2 +- src/Migration/Run/RunService.php | 5 +- .../Service/MediaFileProcessorService.php | 26 +- .../Service/MigrationDataConverter.php | 14 +- .../Service/MigrationDataFetcher.php | 5 +- src/Migration/Service/MigrationDataWriter.php | 20 +- .../Subscriber/MessageQueueSubscriber.php | 17 +- .../Shopware/Converter/CategoryConverter.php | 4 +- .../Converter/CrossSellingConverter.php | 8 +- .../Shopware/Converter/CustomerConverter.php | 78 ++- .../Shopware/Converter/LanguageConverter.php | 4 +- .../MainVariantRelationConverter.php | 12 +- .../NewsletterRecipientConverter.php | 42 +- .../Converter/NumberRangeConverter.php | 20 +- .../Shopware/Converter/OrderConverter.php | 84 ++- .../Converter/OrderDocumentConverter.php | 17 +- .../Shopware/Converter/ProductConverter.php | 46 +- .../Converter/ProductReviewConverter.php | 27 +- .../Shopware/Converter/PromotionConverter.php | 39 +- .../PropertyGroupOptionConverter.php | 9 +- .../Converter/SalesChannelConverter.php | 26 +- .../Shopware/Converter/SeoUrlConverter.php | 20 +- .../Converter/ShippingMethodConverter.php | 46 +- .../Converter/TranslationConverter.php | 74 +- .../Gateway/Api/Reader/TableCountReader.php | 5 +- .../Gateway/Local/Reader/AttributeReader.php | 2 +- .../Log/DeactivatedPackLanguageLog.php | 45 +- .../Logging/Log/InvalidEmailAddressLog.php | 45 +- .../Log/UnsupportedMailTemplateType.php | 42 +- .../Log/UnsupportedNumberRangeTypeLog.php | 44 +- .../UnsupportedShippingCalculationType.php | 44 +- .../Log/UnsupportedShippingPriceLog.php | 44 +- .../Shopware/Media/LocalMediaProcessor.php | 31 +- .../Media/LocalOrderDocumentProcessor.php | 13 +- .../Media/LocalProductDownloadProcessor.php | 15 +- .../Media/Strategy/Md5StrategyResolver.php | 2 +- .../Media/Strategy/PlainStrategyResolver.php | 2 +- .../Converter/DocumentBaseConfigConverter.php | 9 +- .../Shopware6/Converter/DocumentConverter.php | 9 +- .../Converter/MailTemplateConverter.php | 5 +- .../Converter/MediaFolderConverter.php | 6 +- .../Converter/NumberRangeConverter.php | 6 +- .../Shopware6/Converter/ShopwareConverter.php | 6 +- .../Log/UnsupportedDocumentTypeLog.php | 41 +- .../Log/UnsupportedMediaDefaultFolderLog.php | 41 +- .../HttpOrderDocumentGenerationService.php | 7 +- .../Controller/HistoryControllerTest.php | 13 +- .../Migration/Logging/LoggingServiceTest.php | 4 +- .../Process/HttpDownloadServiceBaseTest.php | 23 +- .../Processor/AbortingProcessorTest.php | 4 + .../Services/MigrationDataProcessingTest.php | 5 +- .../Services/MigrationDataWriterTest.php | 1 - tests/Migration/Services/RunServiceTest.php | 2 +- .../Subscriber/MessageQueueSubscriberTest.php | 6 +- .../Local/CategoryAttributeReaderTest.php | 8 +- .../Local/CustomerAttributeReaderTest.php | 5 +- .../CustomerGroupAttributeReaderTest.php | 5 +- .../Local/ManufacturerAttributeReaderTest.php | 5 +- .../Local/OrderAttributeReaderTest.php | 8 +- .../OrderDocumentAttributeReaderTest.php | 5 +- .../Local/ProductAttributeReaderTest.php | 8 +- .../Local/ProductPriceAttributeReaderTest.php | 5 +- .../Converter/OrderDocumentConverterTest.php | 13 +- .../Converter/CategoryConverterTest.php | 2 - .../Converter/CrossSellingConverterTest.php | 6 +- .../Converter/CustomerConverterTest.php | 60 +- .../Converter/LanguageConverterTest.php | 2 +- .../MainVariantRelationConverterTest.php | 16 +- .../NewsletterRecipientConverterTest.php | 8 +- .../Converter/OrderConverterTest.php | 19 +- .../Converter/ProductConverterTest.php | 4 +- .../Converter/PromotionConverterTest.php | 15 - .../Converter/SalesChannelConverterTest.php | 4 +- .../Converter/ShippingMethodConverterTest.php | 10 +- .../Converter/TranslationConverterTest.php | 27 +- .../Converter/SalesChannelConverterTest.php | 2 +- .../Converter/ShopwareConverterTest.php | 6 +- .../Gateway/Api/Shopware6ApiGatewayTest.php | 2 - .../MailTemplate/02-MailTypeNotExists/log.php | 1 - .../03-UnknownDefaultFolder/log.php | 1 - .../NumberRange/02-TypeNotExists/log.php | 1 - .../02-MissingLanguages/log.php | 6 +- .../tests/MigrationByUiFlow.spec.ts | 4 + ...n-log-sw5-SwagMigrationAssistant-linux.txt | 6 +- 120 files changed, 1742 insertions(+), 2048 deletions(-) create mode 100644 src/Core/Migration/Migration1754896654TruncateMigrationLogs.php create mode 100644 src/Core/Migration/Migration1754897550AddRequiredFieldsToMigrationLogs.php diff --git a/.gitignore b/.gitignore index 5d53cb79f..ba9a778e3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1,32 @@ -.idea -.vscode -coverage/ -.phpunit.cache -.phpunit.result.cache -vendor -node_modules -phpstan.neon +# ide +.idea/ +.vscode/ + +# os +.DS_Store + +# node +node_modules/ *.hot-update.js -/var/ + +# php +vendor/ +phpstan.neon composer.lock -src/Resources/public/administration/ +.phpunit.cache +.phpunit.result.cache + +# tests +coverage/ + +# build src/Resources/public/static/ +src/Resources/public/administration/ +src/Resources/app/administration/.tmp + +# runtime +/var/ .env + +# plugin /migration_assistant.cache diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 1d01cf86e..823a26edd 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -2,1025 +2,1230 @@ parameters: ignoreErrors: - message: '#^Property SwagMigrationAssistant\\Migration\\Converter\\Converter\:\:\$mainMapping \(array\{id\: string, connectionId\: string, oldIdentifier\: string\|null, entityUuid\: string\|null, entityValue\: string\|null, checksum\: string\|null, additionalData\: array\\|null\}\|null\) does not accept array\{additionalData\: non\-empty\-array\\}\|array\{id\: string, connectionId\: string, oldIdentifier\: string\|null, entityUuid\: string\|null, entityValue\: string\|null, checksum\: string\|null, additionalData\: non\-empty\-array\\}\.$#' + identifier: assign.propertyType count: 1 path: src/Migration/Converter/Converter.php - message: '#^Property SwagMigrationAssistant\\Migration\\Converter\\Converter\:\:\$mainMapping \(array\{id\: string, connectionId\: string, oldIdentifier\: string\|null, entityUuid\: string\|null, entityValue\: string\|null, checksum\: string\|null, additionalData\: array\\|null\}\|null\) does not accept array\{checksum\: string\}\|array\{id\: string, connectionId\: string, oldIdentifier\: string\|null, entityUuid\: string\|null, entityValue\: string\|null, checksum\: string, additionalData\: array\\|null\}\.$#' + identifier: assign.propertyType count: 1 path: src/Migration/Converter/Converter.php - - message: "#^swag_migration_data\\.run association has a configured autoload\\=\\=\\=true, this is forbidden for platform integrations$#" + message: '#^swag_migration_data\.run association has a configured autoload\=\=\=true, this is forbidden for platform integrations$#' + identifier: shopware.associationAutoload count: 1 path: src/Migration/Data/SwagMigrationDataDefinition.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\History\\\\HistoryService\\:\\:extractBucketInformation\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\History\\HistoryService\:\:extractBucketInformation\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/History/HistoryService.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\History\\\\HistoryService\\:\\:getGroupedLogsOfRun\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\History\\HistoryService\:\:getGroupedLogsOfRun\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/History/HistoryService.php - - message: "#^Provide more specific return type \"SwagMigrationAssistant\\\\Migration\\\\Logging\\\\SwagMigrationLoggingCollection\" over abstract one$#" + message: '#^Provide more specific return type "SwagMigrationAssistant\\Migration\\Logging\\SwagMigrationLoggingCollection" over abstract one$#' + identifier: typePerfect.narrowReturnObjectType count: 1 path: src/Migration/History/HistoryService.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\History\\\\HistoryServiceInterface\\:\\:getGroupedLogsOfRun\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\History\\HistoryServiceInterface\:\:getGroupedLogsOfRun\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/History/HistoryServiceInterface.php - - message: "#^Property SwagMigrationAssistant\\\\Migration\\\\Logging\\\\LoggingService\\:\\:\\$logging type has no value type specified in iterable type array\\.$#" + message: '#^Property SwagMigrationAssistant\\Migration\\Logging\\LoggingService\:\:\$logging type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Logging/LoggingService.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Logging\\\\SwagMigrationLoggingEntity\\:\\:getParameters\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/Migration/Logging/SwagMigrationLoggingEntity.php - - - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Logging\\\\SwagMigrationLoggingEntity\\:\\:setParameters\\(\\) has parameter \\$parameters with no value type specified in iterable type array\\.$#" - count: 1 - path: src/Migration/Logging/SwagMigrationLoggingEntity.php - - - - message: "#^Property SwagMigrationAssistant\\\\Migration\\\\Logging\\\\SwagMigrationLoggingEntity\\:\\:\\$parameters type has no value type specified in iterable type array\\.$#" - count: 1 - path: src/Migration/Logging/SwagMigrationLoggingEntity.php - - - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Mapping\\\\MappingDeltaResult\\:\\:__construct\\(\\) has parameter \\$migrationData with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Mapping\\MappingDeltaResult\:\:__construct\(\) has parameter \$migrationData with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Mapping/MappingDeltaResult.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Mapping\\\\MappingDeltaResult\\:\\:__construct\\(\\) has parameter \\$preloadIds with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Mapping\\MappingDeltaResult\:\:__construct\(\) has parameter \$preloadIds with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Mapping/MappingDeltaResult.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Mapping\\\\MappingDeltaResult\\:\\:getMigrationData\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Mapping\\MappingDeltaResult\:\:getMigrationData\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Mapping/MappingDeltaResult.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Mapping\\\\MappingDeltaResult\\:\\:getPreloadIds\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Mapping\\MappingDeltaResult\:\:getPreloadIds\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Mapping/MappingDeltaResult.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Mapping\\\\MappingService\\:\\:getMappings\\(\\) has parameter \\$ids with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Mapping\\MappingService\:\:getMappings\(\) has parameter \$ids with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Mapping/MappingService.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Mapping\\\\MappingService\\:\\:getUuidsByEntity\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Mapping\\MappingService\:\:getUuidsByEntity\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Mapping/MappingService.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Mapping\\\\MappingService\\:\\:preloadMappings\\(\\) has parameter \\$mappingIds with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Mapping\\MappingService\:\:preloadMappings\(\) has parameter \$mappingIds with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Mapping/MappingService.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Mapping\\\\MappingService\\:\\:saveListMapping\\(\\) has parameter \\$mapping with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Mapping\\MappingService\:\:saveListMapping\(\) has parameter \$mapping with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Mapping/MappingService.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Mapping\\\\MappingService\\:\\:saveMapping\\(\\) has parameter \\$mapping with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Mapping\\MappingService\:\:saveMapping\(\) has parameter \$mapping with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Mapping/MappingService.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Mapping\\\\MappingService\\:\\:updateMapping\\(\\) has parameter \\$updateData with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Mapping\\MappingService\:\:updateMapping\(\) has parameter \$updateData with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Mapping/MappingService.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Mapping\\\\MappingService\\:\\:updateMapping\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Mapping\\MappingService\:\:updateMapping\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Mapping/MappingService.php - - message: "#^Property SwagMigrationAssistant\\\\Migration\\\\Mapping\\\\MappingService\\:\\:\\$languageData type has no value type specified in iterable type array\\.$#" + message: '#^Property SwagMigrationAssistant\\Migration\\Mapping\\MappingService\:\:\$languageData type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Mapping/MappingService.php - - message: "#^Property SwagMigrationAssistant\\\\Migration\\\\Mapping\\\\MappingService\\:\\:\\$locales type has no value type specified in iterable type array\\.$#" + message: '#^Property SwagMigrationAssistant\\Migration\\Mapping\\MappingService\:\:\$locales type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Mapping/MappingService.php - - message: "#^Property SwagMigrationAssistant\\\\Migration\\\\Mapping\\\\MappingService\\:\\:\\$mappings type has no value type specified in iterable type array\\.$#" + message: '#^Property SwagMigrationAssistant\\Migration\\Mapping\\MappingService\:\:\$mappings type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Mapping/MappingService.php - - message: "#^Property SwagMigrationAssistant\\\\Migration\\\\Mapping\\\\MappingService\\:\\:\\$migratedSalesChannels type has no value type specified in iterable type array\\.$#" + message: '#^Property SwagMigrationAssistant\\Migration\\Mapping\\MappingService\:\:\$migratedSalesChannels type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Mapping/MappingService.php - - message: "#^Property SwagMigrationAssistant\\\\Migration\\\\Mapping\\\\MappingService\\:\\:\\$writeArray type has no value type specified in iterable type array\\.$#" + message: '#^Property SwagMigrationAssistant\\Migration\\Mapping\\MappingService\:\:\$writeArray type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Mapping/MappingService.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Mapping\\\\MappingServiceInterface\\:\\:getMappings\\(\\) has parameter \\$ids with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Mapping\\MappingServiceInterface\:\:getMappings\(\) has parameter \$ids with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Mapping/MappingServiceInterface.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Mapping\\\\MappingServiceInterface\\:\\:getUuidsByEntity\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Mapping\\MappingServiceInterface\:\:getUuidsByEntity\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Mapping/MappingServiceInterface.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Mapping\\\\MappingServiceInterface\\:\\:preloadMappings\\(\\) has parameter \\$mappingIds with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Mapping\\MappingServiceInterface\:\:preloadMappings\(\) has parameter \$mappingIds with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Mapping/MappingServiceInterface.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Mapping\\\\MappingServiceInterface\\:\\:updateMapping\\(\\) has parameter \\$updateData with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Mapping\\MappingServiceInterface\:\:updateMapping\(\) has parameter \$updateData with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Mapping/MappingServiceInterface.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Mapping\\\\MappingServiceInterface\\:\\:updateMapping\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Mapping\\MappingServiceInterface\:\:updateMapping\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Mapping/MappingServiceInterface.php - - message: "#^Class SwagMigrationAssistant\\\\Migration\\\\Mapping\\\\SwagMigrationMappingCollection extends generic class Shopware\\\\Core\\\\Framework\\\\DataAbstractionLayer\\\\EntityCollection but does not specify its types\\: TElement$#" + message: '#^Class SwagMigrationAssistant\\Migration\\Mapping\\SwagMigrationMappingCollection extends generic class Shopware\\Core\\Framework\\DataAbstractionLayer\\EntityCollection but does not specify its types\: TElement$#' + identifier: missingType.generics count: 1 path: src/Migration/Mapping/SwagMigrationMappingCollection.php - - message: "#^Change \"defineFields\\(\\)\" method visibility to \"protected\" to respect parent method visibility\\.$#" + message: '#^Change "defineFields\(\)" method visibility to "protected" to respect parent method visibility\.$#' + identifier: symplify.parentMethodVisibilityOverride count: 1 path: src/Migration/Mapping/SwagMigrationMappingDefinition.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Media\\\\MediaFileService\\:\\:saveMediaFile\\(\\) has parameter \\$mediaFile with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Media\\MediaFileService\:\:saveMediaFile\(\) has parameter \$mediaFile with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Media/MediaFileService.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Media\\\\MediaFileService\\:\\:saveWrittenFlag\\(\\) has parameter \\$mediaUuids with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Media\\MediaFileService\:\:saveWrittenFlag\(\) has parameter \$mediaUuids with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Media/MediaFileService.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Media\\\\MediaFileService\\:\\:setWrittenFlag\\(\\) has parameter \\$converted with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Media\\MediaFileService\:\:setWrittenFlag\(\) has parameter \$converted with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Media/MediaFileService.php - - message: "#^Property SwagMigrationAssistant\\\\Migration\\\\Media\\\\MediaFileService\\:\\:\\$uuids type has no value type specified in iterable type array\\.$#" + message: '#^Property SwagMigrationAssistant\\Migration\\Media\\MediaFileService\:\:\$uuids type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Media/MediaFileService.php - - message: "#^Property SwagMigrationAssistant\\\\Migration\\\\Media\\\\MediaFileService\\:\\:\\$writeArray type has no value type specified in iterable type array\\.$#" + message: '#^Property SwagMigrationAssistant\\Migration\\Media\\MediaFileService\:\:\$writeArray type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Media/MediaFileService.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Media\\\\MediaFileServiceInterface\\:\\:saveMediaFile\\(\\) has parameter \\$mediaFile with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Media\\MediaFileServiceInterface\:\:saveMediaFile\(\) has parameter \$mediaFile with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Media/MediaFileServiceInterface.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Media\\\\MediaFileServiceInterface\\:\\:setWrittenFlag\\(\\) has parameter \\$converted with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Media\\MediaFileServiceInterface\:\:setWrittenFlag\(\) has parameter \$converted with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Media/MediaFileServiceInterface.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Media\\\\MediaProcessWorkloadStruct\\:\\:__construct\\(\\) has parameter \\$additionalData with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Media\\MediaProcessWorkloadStruct\:\:__construct\(\) has parameter \$additionalData with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Media/MediaProcessWorkloadStruct.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Media\\\\MediaProcessWorkloadStruct\\:\\:getAdditionalData\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Media\\MediaProcessWorkloadStruct\:\:getAdditionalData\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Media/MediaProcessWorkloadStruct.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Media\\\\MediaProcessWorkloadStruct\\:\\:setAdditionalData\\(\\) has parameter \\$additionalData with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Media\\MediaProcessWorkloadStruct\:\:setAdditionalData\(\) has parameter \$additionalData with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Media/MediaProcessWorkloadStruct.php - - message: "#^Property SwagMigrationAssistant\\\\Migration\\\\Media\\\\MediaProcessWorkloadStruct\\:\\:\\$additionalData type has no value type specified in iterable type array\\.$#" + message: '#^Property SwagMigrationAssistant\\Migration\\Media\\MediaProcessWorkloadStruct\:\:\$additionalData type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Media/MediaProcessWorkloadStruct.php - - message: "#^Class SwagMigrationAssistant\\\\Migration\\\\Media\\\\SwagMigrationMediaFileCollection extends generic class Shopware\\\\Core\\\\Framework\\\\DataAbstractionLayer\\\\EntityCollection but does not specify its types\\: TElement$#" + message: '#^Class SwagMigrationAssistant\\Migration\\Media\\SwagMigrationMediaFileCollection extends generic class Shopware\\Core\\Framework\\DataAbstractionLayer\\EntityCollection but does not specify its types\: TElement$#' + identifier: missingType.generics count: 1 path: src/Migration/Media/SwagMigrationMediaFileCollection.php - - message: "#^Change \"defineFields\\(\\)\" method visibility to \"protected\" to respect parent method visibility\\.$#" + message: '#^Change "defineFields\(\)" method visibility to "protected" to respect parent method visibility\.$#' + identifier: symplify.parentMethodVisibilityOverride count: 1 path: src/Migration/Media/SwagMigrationMediaFileDefinition.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\MessageQueue\\\\OrderCountIndexer\\:\\:updateCustomer\\(\\) has parameter \\$ids with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\MessageQueue\\OrderCountIndexer\:\:updateCustomer\(\) has parameter \$ids with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/MessageQueue/OrderCountIndexer.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Run\\\\RunProgress\\:\\:setEntities\\(\\) has parameter \\$entities with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Run\\RunProgress\:\:setEntities\(\) has parameter \$entities with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Run/RunProgress.php - - message: "#^swag_migration_run\\.connection association has a configured autoload\\=\\=\\=true, this is forbidden for platform integrations$#" + message: '#^swag_migration_run\.connection association has a configured autoload\=\=\=true, this is forbidden for platform integrations$#' + identifier: shopware.associationAutoload count: 1 path: src/Migration/Run/SwagMigrationRunDefinition.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Run\\\\SwagMigrationRunEntity\\:\\:getEnvironmentInformation\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Run\\SwagMigrationRunEntity\:\:getEnvironmentInformation\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Run/SwagMigrationRunEntity.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Run\\\\SwagMigrationRunEntity\\:\\:getTotals\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Run\\SwagMigrationRunEntity\:\:getTotals\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Run/SwagMigrationRunEntity.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Run\\\\SwagMigrationRunEntity\\:\\:setEnvironmentInformation\\(\\) has parameter \\$environmentInformation with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Run\\SwagMigrationRunEntity\:\:setEnvironmentInformation\(\) has parameter \$environmentInformation with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Run/SwagMigrationRunEntity.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Run\\\\SwagMigrationRunEntity\\:\\:setTotals\\(\\) has parameter \\$totals with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Run\\SwagMigrationRunEntity\:\:setTotals\(\) has parameter \$totals with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Run/SwagMigrationRunEntity.php - - message: "#^Property SwagMigrationAssistant\\\\Migration\\\\Run\\\\SwagMigrationRunEntity\\:\\:\\$environmentInformation type has no value type specified in iterable type array\\.$#" + message: '#^Property SwagMigrationAssistant\\Migration\\Run\\SwagMigrationRunEntity\:\:\$environmentInformation type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Run/SwagMigrationRunEntity.php - - message: "#^Property SwagMigrationAssistant\\\\Migration\\\\Run\\\\SwagMigrationRunEntity\\:\\:\\$totals type has no value type specified in iterable type array\\.$#" + message: '#^Property SwagMigrationAssistant\\Migration\\Run\\SwagMigrationRunEntity\:\:\$totals type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Run/SwagMigrationRunEntity.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Service\\\\MigrationDataConverter\\:\\:convert\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Service\\MigrationDataConverter\:\:convert\(\) has parameter \$data with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Service/MigrationDataConverter.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Service\\\\MigrationDataConverter\\:\\:convertData\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Service\\MigrationDataConverter\:\:convertData\(\) has parameter \$data with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Service/MigrationDataConverter.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Service\\\\MigrationDataConverter\\:\\:convertData\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Service\\MigrationDataConverter\:\:convertData\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Service/MigrationDataConverter.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Service\\\\MigrationDataConverter\\:\\:filterDeltas\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Service\\MigrationDataConverter\:\:filterDeltas\(\) has parameter \$data with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Service/MigrationDataConverter.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Service\\\\MigrationDataConverterInterface\\:\\:convert\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Service\\MigrationDataConverterInterface\:\:convert\(\) has parameter \$data with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Service/MigrationDataConverterInterface.php - - message: "#^Class SwagMigrationAssistant\\\\Migration\\\\Setting\\\\GeneralSettingCollection extends generic class Shopware\\\\Core\\\\Framework\\\\DataAbstractionLayer\\\\EntityCollection but does not specify its types\\: TElement$#" + message: '#^Class SwagMigrationAssistant\\Migration\\Setting\\GeneralSettingCollection extends generic class Shopware\\Core\\Framework\\DataAbstractionLayer\\EntityCollection but does not specify its types\: TElement$#' + identifier: missingType.generics count: 1 path: src/Migration/Setting/GeneralSettingCollection.php - - message: "#^swag_migration_general_setting\\.selectedConnection association has a configured autoload\\=\\=\\=true, this is forbidden for platform integrations$#" + message: '#^swag_migration_general_setting\.selectedConnection association has a configured autoload\=\=\=true, this is forbidden for platform integrations$#' + identifier: shopware.associationAutoload count: 1 path: src/Migration/Setting/GeneralSettingDefinition.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Writer\\\\TranslationWriter\\:\\:writeData\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Writer\\TranslationWriter\:\:writeData\(\) has parameter \$data with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Writer/TranslationWriter.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Writer\\\\TranslationWriter\\:\\:writeData\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Writer\\TranslationWriter\:\:writeData\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Writer/TranslationWriter.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Writer\\\\WriterInterface\\:\\:writeData\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Writer\\WriterInterface\:\:writeData\(\) has parameter \$data with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Writer/WriterInterface.php - - message: "#^Method SwagMigrationAssistant\\\\Migration\\\\Writer\\\\WriterInterface\\:\\:writeData\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Migration\\Writer\\WriterInterface\:\:writeData\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Migration/Writer/WriterInterface.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Converter\\\\CurrencyConverter\\:\\:getCurrencyTranslation\\(\\) has parameter \\$currency with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Converter\\CurrencyConverter\:\:getCurrencyTranslation\(\) has parameter \$currency with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Converter/CurrencyConverter.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Converter\\\\CurrencyConverter\\:\\:getCurrencyTranslation\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Converter\\CurrencyConverter\:\:getCurrencyTranslation\(\) has parameter \$data with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Converter/CurrencyConverter.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Converter\\\\CustomerGroupConverter\\:\\:getCustomerGroupTranslation\\(\\) has parameter \\$customerGroup with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Converter\\CustomerGroupConverter\:\:getCustomerGroupTranslation\(\) has parameter \$customerGroup with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Converter/CustomerGroupConverter.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Converter\\\\CustomerGroupConverter\\:\\:getCustomerGroupTranslation\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Converter\\CustomerGroupConverter\:\:getCustomerGroupTranslation\(\) has parameter \$data with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Converter/CustomerGroupConverter.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Converter\\\\MediaConverter\\:\\:getMediaTranslation\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Converter\\MediaConverter\:\:getMediaTranslation\(\) has parameter \$data with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Converter/MediaConverter.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Converter\\\\MediaConverter\\:\\:getMediaTranslation\\(\\) has parameter \\$media with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Converter\\MediaConverter\:\:getMediaTranslation\(\) has parameter \$media with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Converter/MediaConverter.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Converter\\\\MediaFolderConverter\\:\\:getConfiguration\\(\\) has parameter \\$setting with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Converter\\MediaFolderConverter\:\:getConfiguration\(\) has parameter \$setting with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Converter/MediaFolderConverter.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Converter\\\\MediaFolderConverter\\:\\:getConfiguration\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Converter\\MediaFolderConverter\:\:getConfiguration\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Converter/MediaFolderConverter.php - - message: "#^Call to an undefined method Shopware\\\\Core\\\\Framework\\\\DataAbstractionLayer\\\\Entity\\:\\:getLanguageId\\(\\)\\.$#" + message: '#^Call to an undefined method Shopware\\Core\\Framework\\DataAbstractionLayer\\Entity\:\:getLanguageId\(\)\.$#' + identifier: method.notFound count: 1 path: src/Profile/Shopware/Converter/SalesChannelConverter.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Converter\\\\SalesChannelConverter\\:\\:__construct\\(\\) has parameter \\$languagePackRepo with generic class Shopware\\\\Core\\\\Framework\\\\DataAbstractionLayer\\\\EntityRepository but does not specify its types\\: TEntityCollection$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Converter\\SalesChannelConverter\:\:__construct\(\) has parameter \$languagePackRepo with generic class Shopware\\Core\\Framework\\DataAbstractionLayer\\EntityRepository but does not specify its types\: TEntityCollection$#' + identifier: missingType.generics count: 1 path: src/Profile/Shopware/Converter/SalesChannelConverter.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Api\\\\Reader\\\\TableCountReader\\:\\:logExceptions\\(\\) has parameter \\$exceptionArray with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Api\\Reader\\TableCountReader\:\:logExceptions\(\) has parameter \$exceptionArray with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Api/Reader/TableCountReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Api\\\\Reader\\\\TableCountReader\\:\\:prepareTotals\\(\\) has parameter \\$result with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Api\\Reader\\TableCountReader\:\:prepareTotals\(\) has parameter \$result with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Api/Reader/TableCountReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Api\\\\Reader\\\\TableCountReader\\:\\:readTotals\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Api\\Reader\\TableCountReader\:\:readTotals\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Api/Reader/TableCountReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Api\\\\Reader\\\\TableReader\\:\\:read\\(\\) has parameter \\$filter with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Api\\Reader\\TableReader\:\:read\(\) has parameter \$filter with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Api/Reader/TableReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Api\\\\Reader\\\\TableReader\\:\\:read\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Api\\Reader\\TableReader\:\:read\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Api/Reader/TableReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Api\\\\ShopwareApiGateway\\:\\:readTable\\(\\) has parameter \\$filter with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Api\\ShopwareApiGateway\:\:readTable\(\) has parameter \$filter with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Api/ShopwareApiGateway.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Api\\\\ShopwareApiGateway\\:\\:readTable\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Api\\ShopwareApiGateway\:\:readTable\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Api/ShopwareApiGateway.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\CategoryReader\\:\\:fetchData\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\CategoryReader\:\:fetchData\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/CategoryReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\CategoryReader\\:\\:fetchMainCategoryLocales\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\CategoryReader\:\:fetchMainCategoryLocales\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/CategoryReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\CategoryReader\\:\\:generateAllLocales\\(\\) has parameter \\$categories with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\CategoryReader\:\:generateAllLocales\(\) has parameter \$categories with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/CategoryReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\CategoryReader\\:\\:generateAllLocales\\(\\) has parameter \\$mainCategoryLocales with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\CategoryReader\:\:generateAllLocales\(\) has parameter \$mainCategoryLocales with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/CategoryReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\CategoryReader\\:\\:generateAllLocales\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\CategoryReader\:\:generateAllLocales\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/CategoryReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\CategoryReader\\:\\:getIgnoredCategories\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\CategoryReader\:\:getIgnoredCategories\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/CategoryReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\CrossSellingReader\\:\\:enrichWithPositionData\\(\\) has parameter \\$fetchedCrossSelling with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\CrossSellingReader\:\:enrichWithPositionData\(\) has parameter \$fetchedCrossSelling with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/CrossSellingReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\CrossSellingReader\\:\\:fetchData\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\CrossSellingReader\:\:fetchData\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/CrossSellingReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\CurrencyReader\\:\\:fetchData\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\CurrencyReader\:\:fetchData\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/CurrencyReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\CustomerGroupReader\\:\\:fetchCustomerGroupDiscounts\\(\\) has parameter \\$groupIds with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\CustomerGroupReader\:\:fetchCustomerGroupDiscounts\(\) has parameter \$groupIds with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/CustomerGroupReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\CustomerGroupReader\\:\\:fetchCustomerGroupDiscounts\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\CustomerGroupReader\:\:fetchCustomerGroupDiscounts\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/CustomerGroupReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\CustomerGroupReader\\:\\:fetchCustomerGroups\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\CustomerGroupReader\:\:fetchCustomerGroups\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/CustomerGroupReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\LanguageReader\\:\\:appendAssociatedData\\(\\) has parameter \\$locales with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\LanguageReader\:\:appendAssociatedData\(\) has parameter \$locales with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/LanguageReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\LanguageReader\\:\\:appendAssociatedData\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\LanguageReader\:\:appendAssociatedData\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/LanguageReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\LanguageReader\\:\\:fetchLocales\\(\\) has parameter \\$fetchedShopLocaleIds with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\LanguageReader\:\:fetchLocales\(\) has parameter \$fetchedShopLocaleIds with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/LanguageReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\LanguageReader\\:\\:fetchLocales\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\LanguageReader\:\:fetchLocales\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/LanguageReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\LanguageReader\\:\\:fetchShopLocaleIds\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\LanguageReader\:\:fetchShopLocaleIds\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/LanguageReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\LanguageReader\\:\\:fetchTranslations\\(\\) has parameter \\$locales with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\LanguageReader\:\:fetchTranslations\(\) has parameter \$locales with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/LanguageReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\LanguageReader\\:\\:fetchTranslations\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\LanguageReader\:\:fetchTranslations\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/LanguageReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\MainVariantRelationReader\\:\\:fetchMainVariantRelations\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\MainVariantRelationReader\:\:fetchMainVariantRelations\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/MainVariantRelationReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\MediaAlbumReader\\:\\:fetchAlbums\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\MediaAlbumReader\:\:fetchAlbums\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/MediaAlbumReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\MediaAlbumReader\\:\\:getChildAlbums\\(\\) has parameter \\$mediaAlbums with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\MediaAlbumReader\:\:getChildAlbums\(\) has parameter \$mediaAlbums with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/MediaAlbumReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\MediaAlbumReader\\:\\:getChildAlbums\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\MediaAlbumReader\:\:getChildAlbums\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/MediaAlbumReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\MediaAlbumReader\\:\\:prepareMediaAlbums\\(\\) has parameter \\$mediaAlbums with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\MediaAlbumReader\:\:prepareMediaAlbums\(\) has parameter \$mediaAlbums with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/MediaAlbumReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\MediaAlbumReader\\:\\:prepareMediaAlbums\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\MediaAlbumReader\:\:prepareMediaAlbums\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/MediaAlbumReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\MediaReader\\:\\:fetchData\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\MediaReader\:\:fetchData\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/MediaReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\MediaReader\\:\\:prepareMedia\\(\\) has parameter \\$media with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\MediaReader\:\:prepareMedia\(\) has parameter \$media with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/MediaReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\MediaReader\\:\\:prepareMedia\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\MediaReader\:\:prepareMedia\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/MediaReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\NewsletterRecipientReader\\:\\:addShopAndLocaleByCustomer\\(\\) has parameter \\$item with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\NewsletterRecipientReader\:\:addShopAndLocaleByCustomer\(\) has parameter \$item with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/NewsletterRecipientReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\NewsletterRecipientReader\\:\\:addShopAndLocaleByCustomer\\(\\) has parameter \\$shop with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\NewsletterRecipientReader\:\:addShopAndLocaleByCustomer\(\) has parameter \$shop with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/NewsletterRecipientReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\NewsletterRecipientReader\\:\\:addShopAndLocaleByGroupId\\(\\) has parameter \\$defaultShop with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\NewsletterRecipientReader\:\:addShopAndLocaleByGroupId\(\) has parameter \$defaultShop with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/NewsletterRecipientReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\NewsletterRecipientReader\\:\\:addShopAndLocaleByGroupId\\(\\) has parameter \\$item with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\NewsletterRecipientReader\:\:addShopAndLocaleByGroupId\(\) has parameter \$item with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/NewsletterRecipientReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\NewsletterRecipientReader\\:\\:addShopAndLocaleByGroupId\\(\\) has parameter \\$shops with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\NewsletterRecipientReader\:\:addShopAndLocaleByGroupId\(\) has parameter \$shops with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/NewsletterRecipientReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\NewsletterRecipientReader\\:\\:fetchData\\(\\) has parameter \\$ids with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\NewsletterRecipientReader\:\:fetchData\(\) has parameter \$ids with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/NewsletterRecipientReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\NewsletterRecipientReader\\:\\:fetchData\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\NewsletterRecipientReader\:\:fetchData\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/NewsletterRecipientReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\NewsletterRecipientReader\\:\\:getDefaultShopAndLocaleByGroupId\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\NewsletterRecipientReader\:\:getDefaultShopAndLocaleByGroupId\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/NewsletterRecipientReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\NewsletterRecipientReader\\:\\:getGroupedResult\\(\\) has parameter \\$shops with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\NewsletterRecipientReader\:\:getGroupedResult\(\) has parameter \$shops with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/NewsletterRecipientReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\NewsletterRecipientReader\\:\\:getGroupedResult\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\NewsletterRecipientReader\:\:getGroupedResult\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/NewsletterRecipientReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\NewsletterRecipientReader\\:\\:getShopsAndLocalesByCustomer\\(\\) has parameter \\$ids with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\NewsletterRecipientReader\:\:getShopsAndLocalesByCustomer\(\) has parameter \$ids with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/NewsletterRecipientReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\NewsletterRecipientReader\\:\\:getShopsAndLocalesByCustomer\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\NewsletterRecipientReader\:\:getShopsAndLocalesByCustomer\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/NewsletterRecipientReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\NewsletterRecipientReader\\:\\:getShopsAndLocalesByGroupId\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\NewsletterRecipientReader\:\:getShopsAndLocalesByGroupId\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/NewsletterRecipientReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\OrderDocumentReader\\:\\:fetchDocuments\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\OrderDocumentReader\:\:fetchDocuments\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/OrderDocumentReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\ProductOptionRelationReader\\:\\:fetchData\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\ProductOptionRelationReader\:\:fetchData\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/ProductOptionRelationReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\ProductPropertyRelationReader\\:\\:fetchData\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\ProductPropertyRelationReader\:\:fetchData\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/ProductPropertyRelationReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\ProductReviewReader\\:\\:fetchReviews\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\ProductReviewReader\:\:fetchReviews\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/ProductReviewReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\PromotionReader\\:\\:fetchIndividualCodes\\(\\) has parameter \\$ids with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\PromotionReader\:\:fetchIndividualCodes\(\) has parameter \$ids with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/PromotionReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\PromotionReader\\:\\:fetchIndividualCodes\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\PromotionReader\:\:fetchIndividualCodes\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/PromotionReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\PromotionReader\\:\\:fetchPromotions\\(\\) has parameter \\$ids with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\PromotionReader\:\:fetchPromotions\(\) has parameter \$ids with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/PromotionReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\PromotionReader\\:\\:fetchPromotions\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\PromotionReader\:\:fetchPromotions\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/PromotionReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\PropertyGroupOptionReader\\:\\:fetchData\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\PropertyGroupOptionReader\:\:fetchData\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/PropertyGroupOptionReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\ShippingMethodReader\\:\\:fetchExcludedCategories\\(\\) has parameter \\$shippingMethodIds with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\ShippingMethodReader\:\:fetchExcludedCategories\(\) has parameter \$shippingMethodIds with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/ShippingMethodReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\ShippingMethodReader\\:\\:fetchExcludedCategories\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\ShippingMethodReader\:\:fetchExcludedCategories\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/ShippingMethodReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\ShippingMethodReader\\:\\:fetchPaymentMethods\\(\\) has parameter \\$shippingMethodIds with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\ShippingMethodReader\:\:fetchPaymentMethods\(\) has parameter \$shippingMethodIds with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/ShippingMethodReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\ShippingMethodReader\\:\\:fetchPaymentMethods\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\ShippingMethodReader\:\:fetchPaymentMethods\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/ShippingMethodReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\ShippingMethodReader\\:\\:fetchShippingCosts\\(\\) has parameter \\$shippingMethodIds with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\ShippingMethodReader\:\:fetchShippingCosts\(\) has parameter \$shippingMethodIds with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/ShippingMethodReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\ShippingMethodReader\\:\\:fetchShippingCosts\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\ShippingMethodReader\:\:fetchShippingCosts\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/ShippingMethodReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\ShippingMethodReader\\:\\:fetchShippingCountries\\(\\) has parameter \\$shippingMethodIds with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\ShippingMethodReader\:\:fetchShippingCountries\(\) has parameter \$shippingMethodIds with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/ShippingMethodReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\ShippingMethodReader\\:\\:fetchShippingCountries\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\ShippingMethodReader\:\:fetchShippingCountries\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/ShippingMethodReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\ShippingMethodReader\\:\\:fetchShippingMethods\\(\\) has parameter \\$shippingMethodIds with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\ShippingMethodReader\:\:fetchShippingMethods\(\) has parameter \$shippingMethodIds with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/ShippingMethodReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\ShippingMethodReader\\:\\:fetchShippingMethods\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\ShippingMethodReader\:\:fetchShippingMethods\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/ShippingMethodReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\TableReader\\:\\:read\\(\\) has parameter \\$filter with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\TableReader\:\:read\(\) has parameter \$filter with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/TableReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\TableReader\\:\\:read\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\TableReader\:\:read\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/TableReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\Reader\\\\TranslationReader\\:\\:fetchTranslations\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\Reader\\TranslationReader\:\:fetchTranslations\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/Reader/TranslationReader.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\ShopwareLocalGateway\\:\\:readTable\\(\\) has parameter \\$filter with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\ShopwareLocalGateway\:\:readTable\(\) has parameter \$filter with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/ShopwareLocalGateway.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\Local\\\\ShopwareLocalGateway\\:\\:readTable\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\Local\\ShopwareLocalGateway\:\:readTable\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/Local/ShopwareLocalGateway.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\ShopwareGatewayInterface\\:\\:readTable\\(\\) has parameter \\$filter with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\ShopwareGatewayInterface\:\:readTable\(\) has parameter \$filter with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/ShopwareGatewayInterface.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\ShopwareGatewayInterface\\:\\:readTable\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\ShopwareGatewayInterface\:\:readTable\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/ShopwareGatewayInterface.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\TableCountReaderInterface\\:\\:readTotals\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\TableCountReaderInterface\:\:readTotals\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/TableCountReaderInterface.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\TableReaderInterface\\:\\:read\\(\\) has parameter \\$filter with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\TableReaderInterface\:\:read\(\) has parameter \$filter with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/TableReaderInterface.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Gateway\\\\TableReaderInterface\\:\\:read\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Gateway\\TableReaderInterface\:\:read\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Gateway/TableReaderInterface.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Media\\\\LocalOrderDocumentProcessor\\:\\:copyMediaFiles\\(\\) has parameter \\$media with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Media\\LocalOrderDocumentProcessor\:\:copyMediaFiles\(\) has parameter \$media with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Media/LocalOrderDocumentProcessor.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Media\\\\LocalOrderDocumentProcessor\\:\\:persistFileToMedia\\(\\) has parameter \\$media with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Media\\LocalOrderDocumentProcessor\:\:persistFileToMedia\(\) has parameter \$media with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Media/LocalOrderDocumentProcessor.php - - message: "#^Parameter \\#1 \\$blob of method Shopware\\\\Core\\\\Content\\\\Media\\\\MediaService\\:\\:saveFile\\(\\) expects string, string\\|false given\\.$#" + message: '#^Parameter \#1 \$blob of method Shopware\\Core\\Content\\Media\\MediaService\:\:saveFile\(\) expects string, string\|false given\.$#' + identifier: argument.type count: 3 path: src/Profile/Shopware/Media/LocalOrderDocumentProcessor.php - - message: "#^Parameter \\#3 \\$contentType of method Shopware\\\\Core\\\\Content\\\\Media\\\\MediaService\\:\\:saveFile\\(\\) expects string, string\\|false given\\.$#" + message: '#^Parameter \#3 \$contentType of method Shopware\\Core\\Content\\Media\\MediaService\:\:saveFile\(\) expects string, string\|false given\.$#' + identifier: argument.type count: 3 path: src/Profile/Shopware/Media/LocalOrderDocumentProcessor.php - - message: "#^Parameter \\#4 \\$filename of method Shopware\\\\Core\\\\Content\\\\Media\\\\MediaService\\:\\:saveFile\\(\\) expects string, string\\|null given\\.$#" + message: '#^Parameter \#4 \$filename of method Shopware\\Core\\Content\\Media\\MediaService\:\:saveFile\(\) expects string, string\|null given\.$#' + identifier: argument.type count: 1 path: src/Profile/Shopware/Media/LocalOrderDocumentProcessor.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Media\\\\LocalProductDownloadProcessor\\:\\:copyMediaFiles\\(\\) has parameter \\$media with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Media\\LocalProductDownloadProcessor\:\:copyMediaFiles\(\) has parameter \$media with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Media/LocalProductDownloadProcessor.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware\\\\Media\\\\LocalProductDownloadProcessor\\:\\:persistFileToMedia\\(\\) has parameter \\$media with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware\\Media\\LocalProductDownloadProcessor\:\:persistFileToMedia\(\) has parameter \$media with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware/Media/LocalProductDownloadProcessor.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware6\\\\Converter\\\\CmsPageConverter\\:\\:processSubentities\\(\\) has parameter \\$sections with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware6\\Converter\\CmsPageConverter\:\:processSubentities\(\) has parameter \$sections with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware6/Converter/CmsPageConverter.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware6\\\\Converter\\\\CmsPageConverter\\:\\:updateTranslations\\(\\) has parameter \\$converted with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware6\\Converter\\CmsPageConverter\:\:updateTranslations\(\) has parameter \$converted with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware6/Converter/CmsPageConverter.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware6\\\\Converter\\\\NumberRangeConverter\\:\\:checkForExistingNumberRange\\(\\) has parameter \\$converted with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware6\\Converter\\NumberRangeConverter\:\:checkForExistingNumberRange\(\) has parameter \$converted with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware6/Converter/NumberRangeConverter.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware6\\\\Converter\\\\ProductConverter\\:\\:checkDefaultCurrency\\(\\) has parameter \\$source with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware6\\Converter\\ProductConverter\:\:checkDefaultCurrency\(\) has parameter \$source with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware6/Converter/ProductConverter.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware6\\\\Converter\\\\PropertyGroupConverter\\:\\:convertOption\\(\\) has parameter \\$option with no value type specified in iterable type array\\.$#" + message: '#^Parameter \#1 \$source of method SwagMigrationAssistant\\Profile\\Shopware6\\Converter\\ProductConverter\:\:checkDefaultCurrency\(\) expects array, hasOffsetValue\(string, array\\) given\.$#' + identifier: argument.type + count: 1 + path: src/Profile/Shopware6/Converter/ProductConverter.php + + - + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware6\\Converter\\PropertyGroupConverter\:\:convertOption\(\) has parameter \$option with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware6/Converter/PropertyGroupConverter.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware6\\\\Converter\\\\RuleConverter\\:\\:recursiveAddChildren\\(\\) has parameter \\$parentMap with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware6\\Converter\\RuleConverter\:\:recursiveAddChildren\(\) has parameter \$parentMap with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware6/Converter/RuleConverter.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware6\\\\Converter\\\\RuleConverter\\:\\:recursiveAddChildren\\(\\) has parameter \\$sorted with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware6\\Converter\\RuleConverter\:\:recursiveAddChildren\(\) has parameter \$sorted with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware6/Converter/RuleConverter.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware6\\\\Converter\\\\RuleConverter\\:\\:sortConditions\\(\\) has parameter \\$conditions with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware6\\Converter\\RuleConverter\:\:sortConditions\(\) has parameter \$conditions with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware6/Converter/RuleConverter.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware6\\\\Converter\\\\RuleConverter\\:\\:sortConditions\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware6\\Converter\\RuleConverter\:\:sortConditions\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware6/Converter/RuleConverter.php - - message: "#^Method SwagMigrationAssistant\\\\Profile\\\\Shopware6\\\\Converter\\\\ShopwareMediaConverter\\:\\:updateMediaAssociation\\(\\) has parameter \\$mediaArray with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Profile\\Shopware6\\Converter\\ShopwareMediaConverter\:\:updateMediaAssociation\(\) has parameter \$mediaArray with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: src/Profile/Shopware6/Converter/ShopwareMediaConverter.php - - message: "#^Method SwagMigrationAssistant\\\\Test\\\\DataProvider\\\\Service\\\\EnvironmentServiceTest\\:\\:provideEnvironments\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Test\\DataProvider\\Service\\EnvironmentServiceTest\:\:provideEnvironments\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/DataProvider/Service/EnvironmentServiceTest.php - - message: "#^Property SwagMigrationAssistant\\\\Test\\\\DeprecatedTagTest\\:\\:\\$whiteList type has no value type specified in iterable type array\\.$#" + message: '#^Property SwagMigrationAssistant\\Test\\DeprecatedTagTest\:\:\$whiteList type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/DeprecatedTagTest.php - - message: "#^Method SwagMigrationAssistant\\\\Test\\\\Migration\\\\Converter\\\\ConverterRegistryTest\\:\\:converterProvider\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Test\\Migration\\Converter\\ConverterRegistryTest\:\:converterProvider\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/Migration/Converter/ConverterRegistryTest.php - - message: "#^Call to deprecated method getMockForAbstractClass\\(\\) of class PHPUnit\\\\Framework\\\\TestCase\\.$#" + message: '#^Call to deprecated method getMockForAbstractClass\(\) of class PHPUnit\\Framework\\TestCase\.$#' + identifier: method.deprecated count: 1 path: tests/Migration/Writer/AbstractWriterTest.php - - message: "#^Property SwagMigrationAssistant\\\\Test\\\\Migration\\\\Writer\\\\AbstractWriterTest\\:\\:\\$dataToWrite type has no value type specified in iterable type array\\.$#" + message: '#^Property SwagMigrationAssistant\\Test\\Migration\\Writer\\AbstractWriterTest\:\:\$dataToWrite type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/Migration/Writer/AbstractWriterTest.php - - message: "#^Property SwagMigrationAssistant\\\\Test\\\\Migration\\\\Writer\\\\AbstractWriterTest\\:\\:\\$writeResult type has no value type specified in iterable type array\\.$#" + message: '#^Property SwagMigrationAssistant\\Test\\Migration\\Writer\\AbstractWriterTest\:\:\$writeResult type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/Migration/Writer/AbstractWriterTest.php - - message: "#^Class SwagMigrationAssistant\\\\Test\\\\Mock\\\\DummyCollection implements generic interface IteratorAggregate but does not specify its types\\: TKey, TValue$#" + message: '#^Class SwagMigrationAssistant\\Test\\Mock\\DummyCollection implements generic interface IteratorAggregate but does not specify its types\: TKey, TValue$#' + identifier: missingType.generics count: 1 path: tests/Mock/DummyCollection.php - - message: "#^Method SwagMigrationAssistant\\\\Test\\\\Mock\\\\DummyCollection\\:\\:__construct\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Test\\Mock\\DummyCollection\:\:__construct\(\) has parameter \$data with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/Mock/DummyCollection.php - - message: "#^Method SwagMigrationAssistant\\\\Test\\\\Mock\\\\DummyCollection\\:\\:getIterator\\(\\) return type with generic class ArrayIterator does not specify its types\\: TKey, TValue$#" + message: '#^Method SwagMigrationAssistant\\Test\\Mock\\DummyCollection\:\:getIterator\(\) return type with generic class ArrayIterator does not specify its types\: TKey, TValue$#' + identifier: missingType.generics count: 1 path: tests/Mock/DummyCollection.php - - message: "#^Method SwagMigrationAssistant\\\\Test\\\\Mock\\\\Gateway\\\\Dummy\\\\Api\\\\Reader\\\\ApiDummyReader\\:\\:read\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Test\\Mock\\Gateway\\Dummy\\Api\\Reader\\ApiDummyReader\:\:read\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/Mock/Gateway/Dummy/Api/Reader/ApiDummyReader.php - - message: "#^Method SwagMigrationAssistant\\\\Test\\\\Mock\\\\Gateway\\\\Dummy\\\\Api\\\\Reader\\\\EnvironmentDummyReader\\:\\:read\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Test\\Mock\\Gateway\\Dummy\\Api\\Reader\\EnvironmentDummyReader\:\:read\(\) has parameter \$params with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/Mock/Gateway/Dummy/Api/Reader/EnvironmentDummyReader.php - - message: "#^Method SwagMigrationAssistant\\\\Test\\\\Mock\\\\Gateway\\\\Dummy\\\\Api\\\\Reader\\\\TableCountDummyReader\\:\\:readTotals\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Test\\Mock\\Gateway\\Dummy\\Api\\Reader\\TableCountDummyReader\:\:readTotals\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/Mock/Gateway/Dummy/Api/Reader/TableCountDummyReader.php - - message: "#^Method SwagMigrationAssistant\\\\Test\\\\Mock\\\\Migration\\\\Logging\\\\DummyLoggingService\\:\\:getLoggingArray\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Test\\Mock\\Migration\\Logging\\DummyLoggingService\:\:getLoggingArray\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/Mock/Migration/Logging/DummyLoggingService.php - - message: "#^Method SwagMigrationAssistant\\\\Test\\\\Mock\\\\Migration\\\\Mapping\\\\Dummy6MappingService\\:\\:createListItemMapping\\(\\) has parameter \\$additionalData with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Test\\Mock\\Migration\\Mapping\\Dummy6MappingService\:\:createListItemMapping\(\) has parameter \$additionalData with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/Mock/Migration/Mapping/Dummy6MappingService.php - - message: "#^Method SwagMigrationAssistant\\\\Test\\\\Mock\\\\Migration\\\\Mapping\\\\Dummy6MappingService\\:\\:getMappings\\(\\) has parameter \\$ids with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Test\\Mock\\Migration\\Mapping\\Dummy6MappingService\:\:getMappings\(\) has parameter \$ids with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/Mock/Migration/Mapping/Dummy6MappingService.php - - message: "#^Method SwagMigrationAssistant\\\\Test\\\\Mock\\\\Migration\\\\Mapping\\\\Dummy6MappingService\\:\\:getUuidList\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Test\\Mock\\Migration\\Mapping\\Dummy6MappingService\:\:getUuidList\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/Mock/Migration/Mapping/Dummy6MappingService.php - - message: "#^Method SwagMigrationAssistant\\\\Test\\\\Mock\\\\Migration\\\\Mapping\\\\Dummy6MappingService\\:\\:getUuidsByEntity\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Test\\Mock\\Migration\\Mapping\\Dummy6MappingService\:\:getUuidsByEntity\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/Mock/Migration/Mapping/Dummy6MappingService.php - - message: "#^Method SwagMigrationAssistant\\\\Test\\\\Mock\\\\Migration\\\\Mapping\\\\Dummy6MappingService\\:\\:preloadMappings\\(\\) has parameter \\$mappingIds with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Test\\Mock\\Migration\\Mapping\\Dummy6MappingService\:\:preloadMappings\(\) has parameter \$mappingIds with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/Mock/Migration/Mapping/Dummy6MappingService.php - - message: "#^Method SwagMigrationAssistant\\\\Test\\\\Mock\\\\Migration\\\\Mapping\\\\DummyMappingService\\:\\:createListItemMapping\\(\\) has parameter \\$additionalData with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Test\\Mock\\Migration\\Mapping\\DummyMappingService\:\:createListItemMapping\(\) has parameter \$additionalData with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/Mock/Migration/Mapping/DummyMappingService.php - - message: "#^Method SwagMigrationAssistant\\\\Test\\\\Mock\\\\Migration\\\\Mapping\\\\DummyMappingService\\:\\:getMappingArray\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Test\\Mock\\Migration\\Mapping\\DummyMappingService\:\:getMappingArray\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/Mock/Migration/Mapping/DummyMappingService.php - - message: "#^Method SwagMigrationAssistant\\\\Test\\\\Mock\\\\Migration\\\\Mapping\\\\DummyMappingService\\:\\:getMappings\\(\\) has parameter \\$ids with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Test\\Mock\\Migration\\Mapping\\DummyMappingService\:\:getMappings\(\) has parameter \$ids with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/Mock/Migration/Mapping/DummyMappingService.php - - message: "#^Method SwagMigrationAssistant\\\\Test\\\\Mock\\\\Migration\\\\Mapping\\\\DummyMappingService\\:\\:getUuidList\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Test\\Mock\\Migration\\Mapping\\DummyMappingService\:\:getUuidList\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/Mock/Migration/Mapping/DummyMappingService.php - - message: "#^Method SwagMigrationAssistant\\\\Test\\\\Mock\\\\Migration\\\\Mapping\\\\DummyMappingService\\:\\:getUuidsByEntity\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Test\\Mock\\Migration\\Mapping\\DummyMappingService\:\:getUuidsByEntity\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/Mock/Migration/Mapping/DummyMappingService.php - - message: "#^Method SwagMigrationAssistant\\\\Test\\\\Mock\\\\Migration\\\\Mapping\\\\DummyMappingService\\:\\:saveMapping\\(\\) has parameter \\$mapping with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Test\\Mock\\Migration\\Mapping\\DummyMappingService\:\:saveMapping\(\) has parameter \$mapping with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/Mock/Migration/Mapping/DummyMappingService.php - - message: "#^Method SwagMigrationAssistant\\\\Test\\\\Mock\\\\Migration\\\\Media\\\\DummyMediaFileService\\:\\:getMediaFileArray\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Test\\Mock\\Migration\\Media\\DummyMediaFileService\:\:getMediaFileArray\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/Mock/Migration/Media/DummyMediaFileService.php - - message: "#^Method SwagMigrationAssistant\\\\Test\\\\Mock\\\\Migration\\\\Media\\\\DummyMediaFileService\\:\\:setWrittenFlag\\(\\) has parameter \\$converted with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Test\\Mock\\Migration\\Media\\DummyMediaFileService\:\:setWrittenFlag\(\) has parameter \$converted with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/Mock/Migration/Media/DummyMediaFileService.php - - message: "#^Method SwagMigrationAssistant\\\\Test\\\\Mock\\\\Migration\\\\Writer\\\\DummyWriter\\:\\:writeData\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Test\\Mock\\Migration\\Writer\\DummyWriter\:\:writeData\(\) has parameter \$data with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/Mock/Migration/Writer/DummyWriter.php - - message: "#^Method SwagMigrationAssistant\\\\Test\\\\Mock\\\\Migration\\\\Writer\\\\DummyWriter\\:\\:writeData\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Test\\Mock\\Migration\\Writer\\DummyWriter\:\:writeData\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/Mock/Migration/Writer/DummyWriter.php - - message: "#^Parameter \\#3 \\$body of class GuzzleHttp\\\\Psr7\\\\Response constructor expects Psr\\\\Http\\\\Message\\\\StreamInterface\\|resource\\|string\\|null, string\\|false given\\.$#" + message: '#^Parameter \#3 \$body of class GuzzleHttp\\Psr7\\Response constructor expects Psr\\Http\\Message\\StreamInterface\|resource\|string\|null, string\|false given\.$#' + identifier: argument.type count: 1 path: tests/Profile/Shopware/Gateway/ApiReaderTest.php - - message: "#^Method SwagMigrationAssistant\\\\Test\\\\Profile\\\\Shopware\\\\Gateway\\\\LocalGatewayTest\\:\\:profileProvider\\(\\) return type has no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Test\\Profile\\Shopware\\Gateway\\LocalGatewayTest\:\:profileProvider\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/Profile/Shopware/Gateway/LocalGatewayTest.php - - message: "#^Method SwagMigrationAssistant\\\\Test\\\\Profile\\\\Shopware6\\\\Converter\\\\ProductSortingConverterTest\\:\\:loadMapping\\(\\) has parameter \\$mappingArray with no value type specified in iterable type array\\.$#" + message: '#^Parameter \#1 \$data of method SwagMigrationAssistant\\Profile\\Shopware\\Converter\\ProductConverter\:\:convert\(\) expects array\, array\|ArrayAccess given\.$#' + identifier: argument.type + count: 1 + path: tests/Profile/Shopware55/Converter/ProductConverterTest.php + + - + message: '#^Parameter \#1 \$data of method SwagMigrationAssistant\\Profile\\Shopware\\Converter\\ProductConverter\:\:convert\(\) expects array\, hasOffsetValue\(string, mixed\) given\.$#' + identifier: argument.type + count: 1 + path: tests/Profile/Shopware55/Converter/ProductConverterTest.php + + - + message: '#^Method SwagMigrationAssistant\\Test\\Profile\\Shopware6\\Converter\\ProductSortingConverterTest\:\:loadMapping\(\) has parameter \$mappingArray with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/Profile/Shopware6/Converter/ProductSortingConverterTest.php - - message: "#^Method SwagMigrationAssistant\\\\Test\\\\Profile\\\\Shopware6\\\\Converter\\\\ShopwareConverterTest\\:\\:dataProviderConvert\\(\\) return type has no value type specified in iterable type iterable\\.$#" + message: '#^Method SwagMigrationAssistant\\Test\\Profile\\Shopware6\\Converter\\ShopwareConverterTest\:\:dataProviderConvert\(\) return type has no value type specified in iterable type iterable\.$#' + identifier: missingType.iterableValue count: 1 path: tests/Profile/Shopware6/Converter/ShopwareConverterTest.php - - message: "#^Method SwagMigrationAssistant\\\\Test\\\\Profile\\\\Shopware6\\\\Converter\\\\ShopwareConverterTest\\:\\:loadMapping\\(\\) has parameter \\$mappingArray with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Test\\Profile\\Shopware6\\Converter\\ShopwareConverterTest\:\:loadMapping\(\) has parameter \$mappingArray with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/Profile/Shopware6/Converter/ShopwareConverterTest.php - - message: "#^Method SwagMigrationAssistant\\\\Test\\\\Profile\\\\Shopware6\\\\Gateway\\\\Connection\\\\ConnectionFactoryTests\\:\\:testCreateApiClient\\(\\) has parameter \\$credentials with no value type specified in iterable type array\\.$#" + message: '#^Method SwagMigrationAssistant\\Test\\Profile\\Shopware6\\Gateway\\Connection\\ConnectionFactoryTests\:\:testCreateApiClient\(\) has parameter \$credentials with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/Profile/Shopware6/Gateway/Connection/ConnectionFactoryTests.php diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 3ea33c26a..cfb461fc5 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -49,6 +49,21 @@ parameters: - src/Profile/Shopware/Premapping/PaymentMethodReader.php - tests/Profile/Shopware/Premapping/PaymentMethodReaderTest.php + - # TODO remove this for 6.8 compatibility + message: '#Call to deprecated method __construct\(\) of class Shopware\\Core\\Framework\\DataAbstractionLayer\\EntityDefinition:#' + paths: + - tests/**/*Test.php + + - # TODO remove with #11883 + message: '#Strict comparison using === between SwagMigrationAssistant\\Migration\\Connection\\SwagMigrationConnectionEntity and null will always evaluate to false\.#' + paths: + - **/*.php + + - # TODO remove with #11883 + message: '#Strict comparison using !== between SwagMigrationAssistant\\Migration\\Connection\\SwagMigrationConnectionEntity and null will always evaluate to true\.#' + paths: + - **/*.php + rules: # Shopware core rules - Shopware\Core\DevOps\StaticAnalyze\PHPStan\Rules\Deprecation\DeprecatedMethodsThrowDeprecationRule diff --git a/src/Core/Migration/Migration1754896654TruncateMigrationLogs.php b/src/Core/Migration/Migration1754896654TruncateMigrationLogs.php new file mode 100644 index 000000000..c65673dad --- /dev/null +++ b/src/Core/Migration/Migration1754896654TruncateMigrationLogs.php @@ -0,0 +1,26 @@ + + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace SwagMigrationAssistant\Core\Migration; + +use Doctrine\DBAL\Connection; +use Shopware\Core\Framework\Log\Package; +use Shopware\Core\Framework\Migration\MigrationStep; + +#[Package('fundamentals@after-sales')] +class Migration1754896654TruncateMigrationLogs extends MigrationStep +{ + public function getCreationTimestamp(): int + { + return 1754896654; + } + + public function update(Connection $connection): void + { + $connection->executeStatement('TRUNCATE TABLE `swag_migration_logging`'); + } +} diff --git a/src/Core/Migration/Migration1754897550AddRequiredFieldsToMigrationLogs.php b/src/Core/Migration/Migration1754897550AddRequiredFieldsToMigrationLogs.php new file mode 100644 index 000000000..0e0cf6b92 --- /dev/null +++ b/src/Core/Migration/Migration1754897550AddRequiredFieldsToMigrationLogs.php @@ -0,0 +1,172 @@ + + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace SwagMigrationAssistant\Core\Migration; + +use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Exception; +use Doctrine\DBAL\Platforms\MySQLPlatform; +use Doctrine\DBAL\Schema\AbstractSchemaManager; +use Shopware\Core\Framework\Log\Package; +use Shopware\Core\Framework\Migration\MigrationStep; + +#[Package('fundamentals@after-sales')] +class Migration1754897550AddRequiredFieldsToMigrationLogs extends MigrationStep +{ + public const MIGRATION_LOGGING_TABLE = 'swag_migration_logging'; + + public const REQUIRED_FIELDS = [ + 'id' => 'BINARY(16) NOT NULL', + 'run_id' => null, + 'level' => null, + 'code' => null, + 'profile_name' => 'VARCHAR(255) NOT NULL', + 'gateway_name' => 'VARCHAR(255) NOT NULL', + 'user_fixable' => 'TINYINT(1) NOT NULL DEFAULT 0', + 'auto_increment' => null, + 'created_at' => null, + 'updated_at' => null, + ]; + + public function getCreationTimestamp(): int + { + return 1754897550; + } + + /** + * @throws \Throwable + */ + public function update(Connection $connection): void + { + $schemaManager = $connection->createSchemaManager(); + + if (!$schemaManager->tablesExist([self::MIGRATION_LOGGING_TABLE])) { + return; + } + + $this->dropForeignKeyIfExists($connection, self::MIGRATION_LOGGING_TABLE, 'fk.swag_migration_logging.run_id'); + $this->dropIndexIfExists($connection, self::MIGRATION_LOGGING_TABLE, 'idx.swag_migration_logging.run_id_code'); + $this->dropConstraintIfExists($connection, 'json.swag_migration_logging.log_entry'); + + $this->dropObsoleteColumns($connection, $schemaManager); + $this->addOrModifyRequiredColumns($connection, $schemaManager); + $this->ensureRelations($connection, $schemaManager); + } + + /** + * @param AbstractSchemaManager $schemaManager + */ + private function dropObsoleteColumns(Connection $connection, AbstractSchemaManager $schemaManager): void + { + $columns = $schemaManager->listTableColumns(self::MIGRATION_LOGGING_TABLE); + + foreach ($columns as $column) { + if (!\array_key_exists($column->getName(), self::REQUIRED_FIELDS)) { + $connection->executeStatement( + \sprintf( + 'ALTER TABLE `%s` DROP COLUMN `%s`;', + self::MIGRATION_LOGGING_TABLE, + $column->getName() + ) + ); + } + } + } + + /** + * @param AbstractSchemaManager $schemaManager + */ + private function addOrModifyRequiredColumns(Connection $connection, AbstractSchemaManager $schemaManager): void + { + $columns = $schemaManager->listTableColumns(self::MIGRATION_LOGGING_TABLE); + + foreach (self::REQUIRED_FIELDS as $name => $type) { + if ($type === null) { + continue; + } + + if (!isset($columns[$name])) { + $connection->executeStatement( + \sprintf( + 'ALTER TABLE `%s` ADD COLUMN `%s` %s;', + self::MIGRATION_LOGGING_TABLE, + $name, + $type + ) + ); + } else { + $connection->executeStatement( + \sprintf( + 'ALTER TABLE `%s` MODIFY COLUMN `%s` %s;', + self::MIGRATION_LOGGING_TABLE, + $name, + $type + ) + ); + } + } + } + + /** + * @param AbstractSchemaManager $schemaManager + */ + private function ensureRelations(Connection $connection, AbstractSchemaManager $schemaManager): void + { + // ensure primary key and index + $indexes = $schemaManager->listTableIndexes(self::MIGRATION_LOGGING_TABLE); + + if (isset($indexes['primary'])) { + $connection->executeStatement( + \sprintf( + 'ALTER TABLE `%s` DROP PRIMARY KEY;', + self::MIGRATION_LOGGING_TABLE + ) + ); + } + + $connection->executeStatement( + \sprintf( + 'ALTER TABLE `%s` ADD PRIMARY KEY (`id`);', + self::MIGRATION_LOGGING_TABLE + ) + ); + + $this->dropIndexIfExists( + $connection, + self::MIGRATION_LOGGING_TABLE, + 'idx.run_id' + ); + $connection->executeStatement( + \sprintf( + 'ALTER TABLE `%s` ADD INDEX `idx.run_id` (`run_id`);', + self::MIGRATION_LOGGING_TABLE + ) + ); + + // ensure foreign key constraint + $connection->executeStatement( + \sprintf( + 'ALTER TABLE `%s` ADD CONSTRAINT `fk.swag_migration_logging.run_id` FOREIGN KEY (`run_id`) REFERENCES `swag_migration_run` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE;', + self::MIGRATION_LOGGING_TABLE + ) + ); + } + + private function dropConstraintIfExists(Connection $connection, string $constraintName): void + { + try { + $connection->executeStatement( + \sprintf( + 'ALTER TABLE `%s` DROP CONSTRAINT `%s`;', + self::MIGRATION_LOGGING_TABLE, + $constraintName + ) + ); + } catch (Exception) { + } + } +} diff --git a/src/Migration/History/HistoryService.php b/src/Migration/History/HistoryService.php index 573d36542..668e22dc3 100644 --- a/src/Migration/History/HistoryService.php +++ b/src/Migration/History/HistoryService.php @@ -59,20 +59,8 @@ public function getGroupedLogsOfRun( null, null, new TermsAggregation( - 'titleSnippet', - 'titleSnippet', - null, - null, - new TermsAggregation( - 'entity', - 'entity', - null, - null, - new TermsAggregation( - 'level', - 'level' - ) - ) + 'level', + 'level' ) ) ); @@ -114,8 +102,8 @@ public function downloadLogsOfRun(string $runUuid, Context $context): \Closure foreach ($logChunk->getElements() as $logEntry) { \printf('[%s] %s%s', $logEntry->getLevel(), $logEntry->getCode(), \PHP_EOL); - \printf('%s%s', $logEntry->getTitle(), \PHP_EOL); - \printf('%s%s%s', $logEntry->getDescription(), \PHP_EOL, \PHP_EOL); + \printf('%s%s', $logEntry->getProfileName(), \PHP_EOL); + \printf('%s%s%s', $logEntry->getGatewayName(), \PHP_EOL, \PHP_EOL); } $offset += self::LOG_FETCH_LIMIT; @@ -151,31 +139,25 @@ public function isMediaProcessing(): bool 'SELECT COUNT(id) FROM swag_migration_media_file WHERE processed = 0 and process_failure != 1' )->fetchOne(); - return $unprocessedCount !== '0'; + return (int) $unprocessedCount !== 0; } private function extractBucketInformation(Bucket $bucket): array { - /** @var TermsResult $titleResult */ - $titleResult = $bucket->getResult(); - $titleBucket = $titleResult->getBuckets()[0]; - - /** @var TermsResult $entityResult */ - $entityResult = $titleBucket->getResult(); - $entityString = empty($entityResult->getBuckets()) ? '' : $entityResult->getBuckets()[0]->getKey(); - + /** @var TermsResult|null $levelResult */ + $levelResult = $bucket->getResult(); $levelString = ''; - if ($entityString !== '') { - /** @var TermsResult $levelResult */ - $levelResult = $entityResult->getBuckets()[0]->getResult(); - $levelString = empty($levelResult->getBuckets()) ? '' : $levelResult->getBuckets()[0]->getKey(); + + if ($levelResult !== null) { + $levelBuckets = $levelResult->getBuckets(); + if (!empty($levelBuckets)) { + $levelString = $levelBuckets[0]->getKey(); + } } return [ 'code' => $bucket->getKey(), 'count' => $bucket->getCount(), - 'titleSnippet' => $titleBucket->getKey(), - 'entity' => $entityString, 'level' => $levelString, ]; } diff --git a/src/Migration/Logging/Log/AssociationRequiredMissingLog.php b/src/Migration/Logging/Log/AssociationRequiredMissingLog.php index 6e9ade2ca..e44a8309a 100644 --- a/src/Migration/Logging/Log/AssociationRequiredMissingLog.php +++ b/src/Migration/Logging/Log/AssociationRequiredMissingLog.php @@ -14,69 +14,30 @@ class AssociationRequiredMissingLog extends BaseRunLogEntry { public function __construct( string $runId, - string $entity, - string $sourceId, + string $profileName, + string $gatewayName, + /** @phpstan-ignore property.onlyWritten */ private readonly string $requiredFor, ) { - parent::__construct($runId, $entity, $sourceId); - } - - public function getLevel(): string - { - return self::LOG_LEVEL_WARNING; - } - - public function getCode(): string - { - $entity = $this->getEntity(); - if ($entity === null) { - return 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING'; - } - - return \sprintf('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_%s', \mb_strtoupper($entity)); - } - - public function getTitle(): string - { - $entity = $this->getEntity(); - if ($entity === null) { - return 'Associated not found'; - } - - return \sprintf('Associated %s not found', $entity); + parent::__construct( + $runId, + $profileName, + $gatewayName, + ); } - /** - * @return array{missingEntity: ?string, requiredFor: string, sourceId: ?string} - */ - public function getParameters(): array + public function isUserFixable(): bool { - return [ - 'missingEntity' => $this->getEntity(), - 'requiredFor' => $this->requiredFor, - 'sourceId' => $this->getSourceId(), - ]; + return false; } - public function getDescription(): string - { - $args = $this->getParameters(); - - return \sprintf( - 'The %s with the source id "%s" can not be found but is required for %s.', - $args['missingEntity'], - $args['sourceId'], - $args['requiredFor'] - ); - } - - public function getTitleSnippet(): string + public function getLevel(): string { - return \sprintf('%s.%s.title', $this->getSnippetRoot(), 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING'); + return self::LOG_LEVEL_WARNING; } - public function getDescriptionSnippet(): string + public function getCode(): string { - return \sprintf('%s.%s.description', $this->getSnippetRoot(), 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING'); + return 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING'; } } diff --git a/src/Migration/Logging/Log/BaseRunLogEntry.php b/src/Migration/Logging/Log/BaseRunLogEntry.php index 0d22aa7c5..8435b298d 100644 --- a/src/Migration/Logging/Log/BaseRunLogEntry.php +++ b/src/Migration/Logging/Log/BaseRunLogEntry.php @@ -14,38 +14,23 @@ abstract class BaseRunLogEntry implements LogEntryInterface { public function __construct( protected string $runId, - protected ?string $entity = null, - protected ?string $sourceId = null, + protected string $profileName, + protected string $gatewayName, ) { } - public function getRunId(): ?string + public function getRunId(): string { return $this->runId; } - public function getEntity(): ?string + public function getProfileName(): string { - return $this->entity; + return $this->profileName; } - public function getSourceId(): ?string + public function getGatewayName(): string { - return $this->sourceId; - } - - public function getSnippetRoot(): string - { - return 'swag-migration.index.error'; - } - - public function getTitleSnippet(): string - { - return \sprintf('%s.%s.title', $this->getSnippetRoot(), $this->getCode()); - } - - public function getDescriptionSnippet(): string - { - return \sprintf('%s.%s.description', $this->getSnippetRoot(), $this->getCode()); + return $this->gatewayName; } } diff --git a/src/Migration/Logging/Log/CannotConvertChildEntity.php b/src/Migration/Logging/Log/CannotConvertChildEntity.php index f97224fb3..a1f65ac99 100644 --- a/src/Migration/Logging/Log/CannotConvertChildEntity.php +++ b/src/Migration/Logging/Log/CannotConvertChildEntity.php @@ -14,69 +14,32 @@ class CannotConvertChildEntity extends BaseRunLogEntry { public function __construct( string $runId, - string $entity, + string $profileName, + string $gatewayName, + /** @phpstan-ignore property.onlyWritten */ private readonly string $parentEntity, + /** @phpstan-ignore property.onlyWritten */ private readonly string $parentSourceId, ) { - parent::__construct($runId, $entity, null); - } - - public function getLevel(): string - { - return self::LOG_LEVEL_WARNING; - } - - public function getCode(): string - { - $entity = $this->getEntity(); - if ($entity === null) { - return 'SWAG_MIGRATION_CANNOT_CONVERT_CHILD_ENTITY'; - } - - return \sprintf('SWAG_MIGRATION_CANNOT_CONVERT_CHILD_%s_ENTITY', \mb_strtoupper($entity)); - } - - public function getTitle(): string - { - $entity = $this->getEntity(); - if ($entity === null) { - return 'The child entity could not be converted'; - } - - return \sprintf('The %s child entity could not be converted', $entity); + parent::__construct( + $runId, + $profileName, + $gatewayName, + ); } - /** - * @return array{entity: ?string, parentEntity: string, parentSourceId: string} - */ - public function getParameters(): array + public function isUserFixable(): bool { - return [ - 'entity' => $this->getEntity(), - 'parentEntity' => $this->parentEntity, - 'parentSourceId' => $this->parentSourceId, - ]; + return false; } - public function getDescription(): string - { - $args = $this->getParameters(); - - return \sprintf( - 'The %s child entity from the %s parent entity with the id "%s" could not be converted.', - $args['entity'], - $args['parentEntity'], - $args['parentSourceId'] - ); - } - - public function getTitleSnippet(): string + public function getLevel(): string { - return \sprintf('%s.%s.title', $this->getSnippetRoot(), 'SWAG_MIGRATION_CANNOT_CONVERT_CHILD_ENTITY'); + return self::LOG_LEVEL_WARNING; } - public function getDescriptionSnippet(): string + public function getCode(): string { - return \sprintf('%s.%s.description', $this->getSnippetRoot(), 'SWAG_MIGRATION_CANNOT_CONVERT_CHILD_ENTITY'); + return 'SWAG_MIGRATION_CANNOT_CONVERT_CHILD_ENTITY'; } } diff --git a/src/Migration/Logging/Log/CannotConvertEntity.php b/src/Migration/Logging/Log/CannotConvertEntity.php index 12588ae3d..86aae32f4 100644 --- a/src/Migration/Logging/Log/CannotConvertEntity.php +++ b/src/Migration/Logging/Log/CannotConvertEntity.php @@ -14,66 +14,28 @@ class CannotConvertEntity extends BaseRunLogEntry { public function __construct( string $runId, - string $entity, - string $sourceId, + string $profileName, + string $gatewayName, ) { - parent::__construct($runId, $entity, $sourceId); - } - - public function getLevel(): string - { - return self::LOG_LEVEL_WARNING; - } - - public function getCode(): string - { - $entity = $this->getEntity(); - if ($entity === null) { - return 'SWAG_MIGRATION_CANNOT_CONVERT'; - } - - return \sprintf('SWAG_MIGRATION_CANNOT_CONVERT_%s', \mb_strtoupper($entity)); - } - - public function getTitle(): string - { - $entity = $this->getEntity(); - if ($entity === null) { - return 'The entity could not be converted'; - } - - return \sprintf('The %s entity could not be converted', $entity); + parent::__construct( + $runId, + $profileName, + $gatewayName, + ); } - /** - * @return array{entity: ?string, sourceId: ?string} - */ - public function getParameters(): array + public function isUserFixable(): bool { - return [ - 'entity' => $this->getEntity(), - 'sourceId' => $this->getSourceId(), - ]; + return false; } - public function getDescription(): string - { - $args = $this->getParameters(); - - return \sprintf( - 'The %s entity with the source id "%s" could not be converted.', - $args['entity'], - $args['sourceId'] ?? 'null' - ); - } - - public function getTitleSnippet(): string + public function getLevel(): string { - return \sprintf('%s.%s.title', $this->getSnippetRoot(), 'SWAG_MIGRATION_CANNOT_CONVERT_ENTITY'); + return self::LOG_LEVEL_WARNING; } - public function getDescriptionSnippet(): string + public function getCode(): string { - return \sprintf('%s.%s.description', $this->getSnippetRoot(), 'SWAG_MIGRATION_CANNOT_CONVERT_ENTITY'); + return 'SWAG_MIGRATION_CANNOT_CONVERT'; } } diff --git a/src/Migration/Logging/Log/CannotGetFileRunLog.php b/src/Migration/Logging/Log/CannotGetFileRunLog.php index 56397ae6e..86a039a78 100644 --- a/src/Migration/Logging/Log/CannotGetFileRunLog.php +++ b/src/Migration/Logging/Log/CannotGetFileRunLog.php @@ -15,79 +15,32 @@ class CannotGetFileRunLog extends BaseRunLogEntry { public function __construct( string $runId, - string $entity, - string $sourceId, + string $profileName, + string $gatewayName, + /** @phpstan-ignore property.onlyWritten */ private readonly string $uri, + /** @phpstan-ignore property.onlyWritten */ private readonly ?RequestException $requestException = null, ) { - parent::__construct($runId, $entity, $sourceId); - } - - public function getLevel(): string - { - return self::LOG_LEVEL_WARNING; - } - - public function getCode(): string - { - $entity = $this->getEntity(); - if ($entity === null) { - return 'SWAG_MIGRATION_CANNOT_GET_FILE'; - } - - return \sprintf('SWAG_MIGRATION_CANNOT_GET_%s_FILE', \mb_strtoupper($entity)); - } - - public function getTitle(): string - { - $entity = $this->getEntity(); - if ($entity === null) { - return 'The file cannot be downloaded / copied'; - } - - return \sprintf('The %s file cannot be downloaded / copied', $entity); - } - - /** - * @return array{entity: ?string, sourceId: ?string, uri: string} - */ - public function getParameters(): array - { - return [ - 'entity' => $this->getEntity(), - 'sourceId' => $this->getSourceId(), - 'uri' => $this->uri, - ]; + parent::__construct( + $runId, + $profileName, + $gatewayName, + ); } - public function getDescription(): string + public function isUserFixable(): bool { - $args = $this->getParameters(); - - $description = \sprintf( - 'The %s file with the uri "%s" and media id "%s" cannot be downloaded / copied.', - $args['entity'], - $args['uri'], - $args['sourceId'] - ); - - if ($this->requestException !== null) { - $description .= \sprintf( - ' The following request error occurred: %s', - $this->requestException->getMessage() - ); - } - - return $description; + return false; } - public function getTitleSnippet(): string + public function getLevel(): string { - return \sprintf('%s.%s.title', $this->getSnippetRoot(), 'SWAG_MIGRATION_CANNOT_GET_FILE'); + return self::LOG_LEVEL_WARNING; } - public function getDescriptionSnippet(): string + public function getCode(): string { - return \sprintf('%s.%s.description', $this->getSnippetRoot(), 'SWAG_MIGRATION_CANNOT_GET_FILE'); + return 'SWAG_MIGRATION_CANNOT_GET_FILE'; } } diff --git a/src/Migration/Logging/Log/CannotReadEntityCountLog.php b/src/Migration/Logging/Log/CannotReadEntityCountLog.php index e3e55641b..1cf9a9146 100644 --- a/src/Migration/Logging/Log/CannotReadEntityCountLog.php +++ b/src/Migration/Logging/Log/CannotReadEntityCountLog.php @@ -13,14 +13,28 @@ class CannotReadEntityCountLog extends BaseRunLogEntry { public function __construct( - string $runUuid, - string $entity, + string $runId, + string $profileName, + string $gatewayName, + /** @phpstan-ignore property.onlyWritten */ private readonly string $table, + /** @phpstan-ignore property.onlyWritten */ private readonly ?string $condition, + /** @phpstan-ignore property.onlyWritten */ private readonly string $exceptionCode, + /** @phpstan-ignore property.onlyWritten */ private readonly string $exceptionMessage, ) { - parent::__construct($runUuid, $entity); + parent::__construct( + $runId, + $profileName, + $gatewayName, + ); + } + + public function isUserFixable(): bool + { + return false; } public function getLevel(): string @@ -32,36 +46,4 @@ public function getCode(): string { return 'SWAG_MIGRATION__COULD_NOT_READ_ENTITY_COUNT'; } - - public function getTitle(): string - { - return 'Could not read entity count'; - } - - /** - * @return array{entity: ?string, table: string, condition: ?string, exceptionCode: string, exceptionMessage: string} - */ - public function getParameters(): array - { - return [ - 'entity' => $this->getEntity(), - 'table' => $this->table, - 'condition' => $this->condition, - 'exceptionCode' => $this->exceptionCode, - 'exceptionMessage' => $this->exceptionMessage, - ]; - } - - public function getDescription(): string - { - $args = $this->getParameters(); - - return \sprintf( - 'Total count for entity %s could not be read. Make sure the table %s exists in your source system and the optional condition "%s" is valid. Exception message: %s', - $args['entity'], - $args['table'], - $args['condition'], - $args['exceptionMessage'] - ); - } } diff --git a/src/Migration/Logging/Log/DataSetNotFoundLog.php b/src/Migration/Logging/Log/DataSetNotFoundLog.php index 1119a2bbd..31804ad7b 100644 --- a/src/Migration/Logging/Log/DataSetNotFoundLog.php +++ b/src/Migration/Logging/Log/DataSetNotFoundLog.php @@ -13,12 +13,20 @@ class DataSetNotFoundLog extends BaseRunLogEntry { public function __construct( - string $runUuid, - string $entity, - string $sourceId, - private readonly string $profileName, + string $runId, + string $profileName, + string $gatewayName, ) { - parent::__construct($runUuid, $entity, $sourceId); + parent::__construct( + $runId, + $profileName, + $gatewayName, + ); + } + + public function isUserFixable(): bool + { + return false; } public function getLevel(): string @@ -30,33 +38,4 @@ public function getCode(): string { return 'SWAG_MIGRATION__DATASET_NOT_FOUND'; } - - public function getTitle(): string - { - return 'DataSet not found'; - } - - /** - * @return array{profileName: string, entity: ?string, sourceId: ?string} - */ - public function getParameters(): array - { - return [ - 'profileName' => $this->profileName, - 'entity' => $this->getEntity(), - 'sourceId' => $this->getSourceId(), - ]; - } - - public function getDescription(): string - { - $args = $this->getParameters(); - - return \sprintf( - 'DataSet for profile "%s" and entity "%s" not found. Entity with id "%s" could not be processed.', - $args['profileName'], - $args['entity'], - $args['sourceId'] - ); - } } diff --git a/src/Migration/Logging/Log/DebugLog.php b/src/Migration/Logging/Log/DebugLog.php index e916e2295..f29f9d959 100644 --- a/src/Migration/Logging/Log/DebugLog.php +++ b/src/Migration/Logging/Log/DebugLog.php @@ -16,11 +16,26 @@ class DebugLog implements LogEntryInterface * @param array $logData */ public function __construct( + private readonly string $runId, private readonly array $logData, - private readonly ?string $runId, ) { } + public function isUserFixable(): bool + { + return false; + } + + public function getProfileName(): string + { + return 'Debug Profile'; + } + + public function getGatewayName(): string + { + return 'Debug Gateway'; + } + public function getLevel(): string { return self::LOG_LEVEL_DEBUG; @@ -76,7 +91,7 @@ public function getSourceId(): ?string return null; } - public function getRunId(): ?string + public function getRunId(): string { return $this->runId; } diff --git a/src/Migration/Logging/Log/DocumentTypeNotSupported.php b/src/Migration/Logging/Log/DocumentTypeNotSupported.php index 09338f098..98f6ad858 100644 --- a/src/Migration/Logging/Log/DocumentTypeNotSupported.php +++ b/src/Migration/Logging/Log/DocumentTypeNotSupported.php @@ -8,17 +8,27 @@ namespace SwagMigrationAssistant\Migration\Logging\Log; use Shopware\Core\Framework\Log\Package; -use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; #[Package('fundamentals@after-sales')] class DocumentTypeNotSupported extends BaseRunLogEntry { public function __construct( string $runId, - string $sourceId, + string $profileName, + string $gatewayName, + /** @phpstan-ignore property.onlyWritten */ private readonly string $type, ) { - parent::__construct($runId, DefaultEntities::ORDER_DOCUMENT, $sourceId); + parent::__construct( + $runId, + $profileName, + $gatewayName, + ); + } + + public function isUserFixable(): bool + { + return false; } public function getLevel(): string @@ -30,31 +40,4 @@ public function getCode(): string { return 'SWAG_MIGRATION__DOCUMENT_TYPE_NOT_SUPPORTED'; } - - public function getTitle(): string - { - return 'Document type is not supported'; - } - - /** - * @return array{sourceId: ?string, type: string} - */ - public function getParameters(): array - { - return [ - 'sourceId' => $this->getSourceId(), - 'type' => $this->type, - ]; - } - - public function getDescription(): string - { - $args = $this->getParameters(); - - return \sprintf( - 'The document with the source id "%s" has the document type "%s", which just got migrated but is still missing a document renderer. If you want to generate documents of this type, please follow this documentation: https://developer.shopware.com/docs/guides/plugins/plugins/checkout/document/add-custom-document-type.html', - $args['sourceId'], - $args['type'] - ); - } } diff --git a/src/Migration/Logging/Log/EmptyNecessaryFieldRunLog.php b/src/Migration/Logging/Log/EmptyNecessaryFieldRunLog.php index ccfce6da1..6394f0fdc 100644 --- a/src/Migration/Logging/Log/EmptyNecessaryFieldRunLog.php +++ b/src/Migration/Logging/Log/EmptyNecessaryFieldRunLog.php @@ -14,69 +14,30 @@ class EmptyNecessaryFieldRunLog extends BaseRunLogEntry { public function __construct( string $runId, - string $entity, - string $sourceId, + string $profileName, + string $gatewayName, + /** @phpstan-ignore property.onlyWritten */ private readonly string $emptyField, ) { - parent::__construct($runId, $entity, $sourceId); - } - - public function getCode(): string - { - $entity = $this->getEntity(); - if ($entity === null) { - return 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'; - } - - return \sprintf('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_%s', \mb_strtoupper($entity)); - } - - public function getLevel(): string - { - return self::LOG_LEVEL_WARNING; - } - - public function getTitle(): string - { - $entity = $this->getEntity(); - if ($entity === null) { - return 'The entity has one or more empty necessary fields'; - } - - return \sprintf('The %s entity has one or more empty necessary fields', $entity); + parent::__construct( + $runId, + $profileName, + $gatewayName, + ); } - /** - * @return array{entity: ?string, sourceId: ?string, emptyField: string} - */ - public function getParameters(): array + public function isUserFixable(): bool { - return [ - 'entity' => $this->getEntity(), - 'sourceId' => $this->getSourceId(), - 'emptyField' => $this->emptyField, - ]; + return false; } - public function getDescription(): string - { - $args = $this->getParameters(); - - return \sprintf( - 'The %s entity with the source id %s does not have the necessary data for the field(s): %s', - $args['entity'], - $args['sourceId'], - $args['emptyField'] - ); - } - - public function getTitleSnippet(): string + public function getCode(): string { - return \sprintf('%s.%s.title', $this->getSnippetRoot(), 'SWAG_MIGRATION__SHOPWARE_EMPTY_NECESSARY_DATA_FIELDS'); + return 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'; } - public function getDescriptionSnippet(): string + public function getLevel(): string { - return \sprintf('%s.%s.description', $this->getSnippetRoot(), 'SWAG_MIGRATION__SHOPWARE_EMPTY_NECESSARY_DATA_FIELDS'); + return self::LOG_LEVEL_WARNING; } } diff --git a/src/Migration/Logging/Log/EntityAlreadyExistsRunLog.php b/src/Migration/Logging/Log/EntityAlreadyExistsRunLog.php index f176f71fc..1a6b62c6e 100644 --- a/src/Migration/Logging/Log/EntityAlreadyExistsRunLog.php +++ b/src/Migration/Logging/Log/EntityAlreadyExistsRunLog.php @@ -14,66 +14,28 @@ class EntityAlreadyExistsRunLog extends BaseRunLogEntry { public function __construct( string $runId, - string $entity, - string $sourceId, + string $profileName, + string $gatewayName, ) { - parent::__construct($runId, $entity, $sourceId); - } - - public function getLevel(): string - { - return self::LOG_LEVEL_INFO; - } - - public function getCode(): string - { - $entity = $this->getEntity(); - if ($entity === null) { - return 'SWAG_MIGRATION_ENTITY_ALREADY_EXISTS'; - } - - return \sprintf('SWAG_MIGRATION_%s_ENTITY_ALREADY_EXISTS', \mb_strtoupper($entity)); - } - - public function getTitle(): string - { - $entity = $this->getEntity(); - if ($entity === null) { - return 'The entity already exists'; - } - - return \sprintf('The %s entity already exists', $entity); + parent::__construct( + $runId, + $profileName, + $gatewayName, + ); } - /** - * @return array{entity: ?string, sourceId: ?string} - */ - public function getParameters(): array + public function isUserFixable(): bool { - return [ - 'entity' => $this->getEntity(), - 'sourceId' => $this->getSourceId(), - ]; + return false; } - public function getDescription(): string - { - $args = $this->getParameters(); - - return \sprintf( - 'The %s entity with source id "%s" already exists and cannot be written.', - $args['entity'], - $args['sourceId'] - ); - } - - public function getTitleSnippet(): string + public function getLevel(): string { - return \sprintf('%s.%s.title', $this->getSnippetRoot(), 'SWAG_MIGRATION_ENTITY_ALREADY_EXISTS'); + return self::LOG_LEVEL_INFO; } - public function getDescriptionSnippet(): string + public function getCode(): string { - return \sprintf('%s.%s.description', $this->getSnippetRoot(), 'SWAG_MIGRATION_ENTITY_ALREADY_EXISTS'); + return 'SWAG_MIGRATION_ENTITY_ALREADY_EXISTS'; } } diff --git a/src/Migration/Logging/Log/ExceptionRunLog.php b/src/Migration/Logging/Log/ExceptionRunLog.php index 5e558213a..23e0a91fc 100644 --- a/src/Migration/Logging/Log/ExceptionRunLog.php +++ b/src/Migration/Logging/Log/ExceptionRunLog.php @@ -8,18 +8,27 @@ namespace SwagMigrationAssistant\Migration\Logging\Log; use Shopware\Core\Framework\Log\Package; -use Shopware\Core\Framework\ShopwareHttpException; #[Package('fundamentals@after-sales')] class ExceptionRunLog extends BaseRunLogEntry { public function __construct( string $runId, - string $entity, + string $profileName, + string $gatewayName, + /** @phpstan-ignore property.onlyWritten */ private readonly \Throwable $exception, - ?string $sourceId = null, ) { - parent::__construct($runId, $entity, $sourceId); + parent::__construct( + $runId, + $profileName, + $gatewayName, + ); + } + + public function isUserFixable(): bool + { + return false; } public function getLevel(): string @@ -31,42 +40,4 @@ public function getCode(): string { return 'SWAG_MIGRATION_RUN_EXCEPTION'; } - - public function getTitle(): string - { - return 'An exception occurred'; - } - - /** - * @return array{entity: ?string, sourceId: ?string, exceptionCode: int|string, exceptionMessage: ?string, exceptionFile: string, exceptionLine: int, exceptionTrace: ?string, description: string} - */ - public function getParameters(): array - { - $entity = $this->getEntity() ?? '-'; - $errorCode = $this->exception->getCode(); - if (\is_subclass_of($this->exception, ShopwareHttpException::class)) { - $errorCode = $this->exception->getErrorCode(); - } - - return [ - 'entity' => $this->getEntity(), - 'sourceId' => $this->getSourceId(), - 'exceptionCode' => $errorCode, - 'exceptionMessage' => \preg_replace('/[[:^print:]]/', '', $this->exception->getMessage()), - 'exceptionFile' => $this->exception->getFile(), - 'exceptionLine' => $this->exception->getLine(), - 'exceptionTrace' => \preg_replace('/[[:^print:]]/', '', $this->exception->getTraceAsString()), - 'description' => \sprintf( - 'Entity: %s, sourceId: %s' . \PHP_EOL . '%s', - $entity, - $this->getSourceId() ?? '-', - \preg_replace('/[[:^print:]]/', '', $this->exception->getMessage()) - ), - ]; - } - - public function getDescription(): string - { - return $this->getParameters()['description']; - } } diff --git a/src/Migration/Logging/Log/FieldReassignedRunLog.php b/src/Migration/Logging/Log/FieldReassignedRunLog.php index e47519f69..032f2998f 100644 --- a/src/Migration/Logging/Log/FieldReassignedRunLog.php +++ b/src/Migration/Logging/Log/FieldReassignedRunLog.php @@ -14,72 +14,32 @@ class FieldReassignedRunLog extends BaseRunLogEntry { public function __construct( string $runId, - string $entity, - string $sourceId, + string $profileName, + string $gatewayName, + /** @phpstan-ignore property.onlyWritten */ private readonly string $emptyField, + /** @phpstan-ignore property.onlyWritten */ private readonly string $replacementField, ) { - parent::__construct($runId, $entity, $sourceId); - } - - public function getLevel(): string - { - return self::LOG_LEVEL_INFO; - } - - public function getCode(): string - { - $entity = $this->getEntity(); - if ($entity === null) { - return 'SWAG_MIGRATION_ENTITY_FIELD_REASSIGNED'; - } - - return \sprintf('SWAG_MIGRATION_%s_ENTITY_FIELD_REASSIGNED', \mb_strtoupper($entity)); - } - - public function getTitle(): string - { - $entity = $this->getEntity(); - if ($entity === null) { - return 'The entity has a field that was reassigned'; - } - - return \sprintf('The %s entity has a field that was reassigned', $entity); + parent::__construct( + $runId, + $profileName, + $gatewayName, + ); } - /** - * @return array{entity: ?string, sourceId: ?string, emptyField: string, replacementField: string} - */ - public function getParameters(): array + public function isUserFixable(): bool { - return [ - 'entity' => $this->getEntity(), - 'sourceId' => $this->getSourceId(), - 'emptyField' => $this->emptyField, - 'replacementField' => $this->replacementField, - ]; + return false; } - public function getDescription(): string - { - $args = $this->getParameters(); - - return \sprintf( - 'The %s entity with the source id "%s" got the field %s replaced with %s.', - $args['entity'], - $args['sourceId'], - $args['emptyField'], - $args['replacementField'] - ); - } - - public function getTitleSnippet(): string + public function getLevel(): string { - return \sprintf('%s.%s.title', $this->getSnippetRoot(), 'SWAG_MIGRATION_ENTITY_FIELD_REASSIGNED'); + return self::LOG_LEVEL_INFO; } - public function getDescriptionSnippet(): string + public function getCode(): string { - return \sprintf('%s.%s.description', $this->getSnippetRoot(), 'SWAG_MIGRATION_ENTITY_FIELD_REASSIGNED'); + return 'SWAG_MIGRATION_ENTITY_FIELD_REASSIGNED'; } } diff --git a/src/Migration/Logging/Log/InvalidUnserializedData.php b/src/Migration/Logging/Log/InvalidUnserializedData.php index dabdad73b..1bddf698d 100644 --- a/src/Migration/Logging/Log/InvalidUnserializedData.php +++ b/src/Migration/Logging/Log/InvalidUnserializedData.php @@ -14,12 +14,23 @@ class InvalidUnserializedData extends BaseRunLogEntry { public function __construct( string $runId, - string $entity, - string $sourceId, + string $profileName, + string $gatewayName, + /** @phpstan-ignore property.onlyWritten */ private readonly string $unserializedEntity, + /** @phpstan-ignore property.onlyWritten */ private readonly string $serializedData, ) { - parent::__construct($runId, $entity, $sourceId); + parent::__construct( + $runId, + $profileName, + $gatewayName, + ); + } + + public function isUserFixable(): bool + { + return false; } public function getLevel(): string @@ -31,35 +42,4 @@ public function getCode(): string { return 'SWAG_MIGRATION__SHOPWARE_INVALID_UNSERIALIZED_DATA'; } - - public function getTitle(): string - { - return 'Invalid unserialized data'; - } - - /** - * @return array{entity: ?string, sourceId: ?string, unserializedEntity: string, serializedData: string} - */ - public function getParameters(): array - { - return [ - 'entity' => $this->getEntity(), - 'sourceId' => $this->getSourceId(), - 'unserializedEntity' => $this->unserializedEntity, - 'serializedData' => $this->serializedData, - ]; - } - - public function getDescription(): string - { - $args = $this->getParameters(); - - return \sprintf( - 'The %s entity with source id "%s" could not be converted because of invalid unserialized object data for the "%s" entity and the raw data is: %s', - $args['entity'], - $args['sourceId'], - $args['unserializedEntity'], - $args['serializedData'] - ); - } } diff --git a/src/Migration/Logging/Log/LogEntryInterface.php b/src/Migration/Logging/Log/LogEntryInterface.php index 68d964b15..fca9034e5 100644 --- a/src/Migration/Logging/Log/LogEntryInterface.php +++ b/src/Migration/Logging/Log/LogEntryInterface.php @@ -17,26 +17,15 @@ interface LogEntryInterface final public const LOG_LEVEL_ERROR = 'error'; final public const LOG_LEVEL_DEBUG = 'debug'; - public function getLevel(): string; - - public function getCode(): string; - - public function getTitle(): string; + public function getRunId(): string; - /** - * @return array - */ - public function getParameters(): array; + public function getProfileName(): string; - public function getDescription(): string; + public function getGatewayName(): string; - public function getTitleSnippet(): string; - - public function getDescriptionSnippet(): string; - - public function getEntity(): ?string; + public function getLevel(): string; - public function getSourceId(): ?string; + public function getCode(): string; - public function getRunId(): ?string; + public function isUserFixable(): bool; } diff --git a/src/Migration/Logging/Log/MessageQueueExceptionLog.php b/src/Migration/Logging/Log/MessageQueueExceptionLog.php index 36059d14f..cb63b8357 100644 --- a/src/Migration/Logging/Log/MessageQueueExceptionLog.php +++ b/src/Migration/Logging/Log/MessageQueueExceptionLog.php @@ -8,17 +8,29 @@ namespace SwagMigrationAssistant\Migration\Logging\Log; use Shopware\Core\Framework\Log\Package; -use Shopware\Core\Framework\ShopwareHttpException; #[Package('fundamentals@after-sales')] class MessageQueueExceptionLog extends BaseRunLogEntry { public function __construct( string $runId, + string $profileName, + string $gatewayName, + /** @phpstan-ignore property.onlyWritten */ private readonly \Throwable $exception, + /** @phpstan-ignore property.onlyWritten */ private int $exceptionCount, ) { - parent::__construct($runId); + parent::__construct( + $runId, + $profileName, + $gatewayName, + ); + } + + public function isUserFixable(): bool + { + return false; } public function getLevel(): string @@ -30,40 +42,4 @@ public function getCode(): string { return 'SWAG_MIGRATION_MESSAGE_QUEUE_EXCEPTION'; } - - public function getTitle(): string - { - return 'An exception occurred during the message queue processing'; - } - - /** - * @return array{exceptionCode: int|string, exceptionMessage: ?string, exceptionFile: string, exceptionLine: int, exceptionTrace: ?string, description: string} - */ - public function getParameters(): array - { - $errorCode = $this->exception->getCode(); - if (\is_subclass_of($this->exception, ShopwareHttpException::class)) { - $errorCode = $this->exception->getErrorCode(); - } - - return [ - 'exceptionCount' => $this->exceptionCount, - 'exceptionCode' => $errorCode, - 'exceptionMessage' => \preg_replace('/[[:^print:]]/', '', $this->exception->getMessage()), - 'exceptionFile' => $this->exception->getFile(), - 'exceptionLine' => $this->exception->getLine(), - 'exceptionTrace' => \preg_replace('/[[:^print:]]/', '', $this->exception->getTraceAsString()), - 'description' => \sprintf( - 'RunId: %s, ExceptionCount: %d ' . \PHP_EOL . '%s', - $this->getRunId(), - $this->exceptionCount, - \preg_replace('/[[:^print:]]/', '', $this->exception->getMessage()) - ), - ]; - } - - public function getDescription(): string - { - return $this->getParameters()['description']; - } } diff --git a/src/Migration/Logging/Log/MimeTypeErrorLog.php b/src/Migration/Logging/Log/MimeTypeErrorLog.php index a38790d1d..fdaa0a6c1 100644 --- a/src/Migration/Logging/Log/MimeTypeErrorLog.php +++ b/src/Migration/Logging/Log/MimeTypeErrorLog.php @@ -14,10 +14,19 @@ class MimeTypeErrorLog extends BaseRunLogEntry { public function __construct( string $runId, - string $entity, - ?string $sourceId = null, + string $profileName, + string $gatewayName, ) { - parent::__construct($runId, $entity, $sourceId); + parent::__construct( + $runId, + $profileName, + $gatewayName, + ); + } + + public function isUserFixable(): bool + { + return false; } public function getLevel(): string @@ -29,27 +38,4 @@ public function getCode(): string { return 'SWAG_MIGRATION__MIME_TYPE_COULD_NOT_BE_DETERMINED'; } - - public function getTitle(): string - { - return 'An exception occurred'; - } - - /** - * @return array{entity: ?string, sourceId: ?string, exceptionCode: int|string, description: string} - */ - public function getParameters(): array - { - return [ - 'entity' => $this->getEntity(), - 'sourceId' => $this->getSourceId(), - 'exceptionCode' => $this->getCode(), - 'description' => 'Could not determine the mime type', - ]; - } - - public function getDescription(): string - { - return $this->getParameters()['description']; - } } diff --git a/src/Migration/Logging/Log/ProcessorNotFoundLog.php b/src/Migration/Logging/Log/ProcessorNotFoundLog.php index 2ade8210d..526499baf 100644 --- a/src/Migration/Logging/Log/ProcessorNotFoundLog.php +++ b/src/Migration/Logging/Log/ProcessorNotFoundLog.php @@ -14,78 +14,38 @@ class ProcessorNotFoundLog implements LogEntryInterface { public function __construct( private readonly string $runId, - private readonly string $entity, private readonly string $profileName, private readonly string $gatewayName, ) { } - public function getLevel(): string - { - return self::LOG_LEVEL_ERROR; - } - - public function getCode(): string + public function isUserFixable(): bool { - return 'SWAG_MIGRATION__PROCESSOR_NOT_FOUND'; - } - - public function getTitle(): string - { - return 'Processor not found'; + return false; } - /** - * @return array{profileName: string, gatewayName: string, entity: ?string} - */ - public function getParameters(): array + public function getProfileName(): string { - return [ - 'profileName' => $this->profileName, - 'gatewayName' => $this->gatewayName, - 'entity' => $this->getEntity(), - ]; + return $this->profileName; } - public function getDescription(): string + public function getGatewayName(): string { - $args = $this->getParameters(); - - return \sprintf( - 'Processor for profile "%s", gateway "%s" and entity "%s" not found.', - $args['profileName'], - $args['gatewayName'], - $args['entity'] - ); + return $this->gatewayName; } - public function getEntity(): ?string + public function getLevel(): string { - return $this->entity; + return self::LOG_LEVEL_ERROR; } - public function getSourceId(): ?string + public function getCode(): string { - return null; + return 'SWAG_MIGRATION__PROCESSOR_NOT_FOUND'; } - public function getRunId(): ?string + public function getRunId(): string { return $this->runId; } - - public function getSnippetRoot(): string - { - return 'swag-migration.index.error'; - } - - public function getTitleSnippet(): string - { - return \sprintf('%s.%s.title', $this->getSnippetRoot(), $this->getCode()); - } - - public function getDescriptionSnippet(): string - { - return \sprintf('%s.%s.description', $this->getSnippetRoot(), $this->getCode()); - } } diff --git a/src/Migration/Logging/Log/RunAbortedAutomatically.php b/src/Migration/Logging/Log/RunAbortedAutomatically.php index 6c05e828e..639361b54 100644 --- a/src/Migration/Logging/Log/RunAbortedAutomatically.php +++ b/src/Migration/Logging/Log/RunAbortedAutomatically.php @@ -8,16 +8,27 @@ namespace SwagMigrationAssistant\Migration\Logging\Log; use Shopware\Core\Framework\Log\Package; -use Shopware\Core\Framework\ShopwareHttpException; #[Package('fundamentals@after-sales')] class RunAbortedAutomatically extends BaseRunLogEntry { public function __construct( string $runId, + string $profileName, + string $gatewayName, + /** @phpstan-ignore property.onlyWritten */ private readonly \Throwable $exception, ) { - parent::__construct($runId); + parent::__construct( + $runId, + $profileName, + $gatewayName, + ); + } + + public function isUserFixable(): bool + { + return false; } public function getLevel(): string @@ -29,38 +40,4 @@ public function getCode(): string { return 'SWAG_MIGRATION_RUN_ABORTED_AUTOMATICALLY_EXCEPTION'; } - - public function getTitle(): string - { - return 'Run was aborted automatically, because too many consecutive exceptions occurred'; - } - - /** - * @return array{exceptionCode: int|string, exceptionMessage: ?string, exceptionFile: string, exceptionLine: int, exceptionTrace: ?string, description: string} - */ - public function getParameters(): array - { - $errorCode = $this->exception->getCode(); - if (\is_subclass_of($this->exception, ShopwareHttpException::class)) { - $errorCode = $this->exception->getErrorCode(); - } - - return [ - 'exceptionCode' => $errorCode, - 'exceptionMessage' => \preg_replace('/[[:^print:]]/', '', $this->exception->getMessage()), - 'exceptionFile' => $this->exception->getFile(), - 'exceptionLine' => $this->exception->getLine(), - 'exceptionTrace' => \preg_replace('/[[:^print:]]/', '', $this->exception->getTraceAsString()), - 'description' => \sprintf( - 'RunId: %s ' . \PHP_EOL . '%s', - $this->getRunId(), - \preg_replace('/[[:^print:]]/', '', $this->exception->getMessage()) - ), - ]; - } - - public function getDescription(): string - { - return $this->getParameters()['description']; - } } diff --git a/src/Migration/Logging/Log/TemporaryFileErrorLog.php b/src/Migration/Logging/Log/TemporaryFileErrorLog.php index eb4640485..08c7990f6 100644 --- a/src/Migration/Logging/Log/TemporaryFileErrorLog.php +++ b/src/Migration/Logging/Log/TemporaryFileErrorLog.php @@ -14,10 +14,19 @@ class TemporaryFileErrorLog extends BaseRunLogEntry { public function __construct( string $runId, - string $entity, - ?string $sourceId = null, + string $profileName, + string $gatewayName, ) { - parent::__construct($runId, $entity, $sourceId); + parent::__construct( + $runId, + $profileName, + $gatewayName, + ); + } + + public function isUserFixable(): bool + { + return false; } public function getLevel(): string @@ -29,27 +38,4 @@ public function getCode(): string { return 'SWAG_MIGRATION__TEMPORARY_FILE_COULD_NOT_BE_CREATED'; } - - public function getTitle(): string - { - return 'An exception occurred'; - } - - /** - * @return array{entity: ?string, sourceId: ?string, exceptionCode: int|string, description: string} - */ - public function getParameters(): array - { - return [ - 'entity' => $this->getEntity(), - 'sourceId' => $this->getSourceId(), - 'exceptionCode' => $this->getCode(), - 'description' => 'The temporary file for media download could not be created', - ]; - } - - public function getDescription(): string - { - return $this->getParameters()['description']; - } } diff --git a/src/Migration/Logging/Log/ThemeCompilingErrorRunLog.php b/src/Migration/Logging/Log/ThemeCompilingErrorRunLog.php index 667ba2229..365c5acc4 100644 --- a/src/Migration/Logging/Log/ThemeCompilingErrorRunLog.php +++ b/src/Migration/Logging/Log/ThemeCompilingErrorRunLog.php @@ -14,9 +14,19 @@ class ThemeCompilingErrorRunLog extends BaseRunLogEntry { public function __construct( string $runId, - string $sourceId, + string $profileName, + string $gatewayName, ) { - parent::__construct($runId, null, $sourceId); + parent::__construct( + $runId, + $profileName, + $gatewayName, + ); + } + + public function isUserFixable(): bool + { + return false; } public function getLevel(): string @@ -28,29 +38,4 @@ public function getCode(): string { return 'SWAG_MIGRATION__THEME_COMPILING_ERROR'; } - - public function getTitle(): string - { - return 'Theme compiling error'; - } - - /** - * @return array{sourceId: ?string} - */ - public function getParameters(): array - { - return [ - 'sourceId' => $this->getSourceId(), - ]; - } - - public function getDescription(): string - { - $args = $this->getParameters(); - - return \sprintf( - 'The theme with id "%s" could not be compiled.', - $args['sourceId'] - ); - } } diff --git a/src/Migration/Logging/Log/UnknownEntityLog.php b/src/Migration/Logging/Log/UnknownEntityLog.php index 428d3c3c8..9d346d057 100644 --- a/src/Migration/Logging/Log/UnknownEntityLog.php +++ b/src/Migration/Logging/Log/UnknownEntityLog.php @@ -14,72 +14,32 @@ class UnknownEntityLog extends BaseRunLogEntry { public function __construct( string $runId, - string $entity, - string $sourceId, + string $profileName, + string $gatewayName, + /** @phpstan-ignore property.onlyWritten */ private readonly string $requiredForEntity, + /** @phpstan-ignore property.onlyWritten */ private readonly string $requiredForSourceId, ) { - parent::__construct($runId, $entity, $sourceId); - } - - public function getLevel(): string - { - return self::LOG_LEVEL_WARNING; - } - - public function getCode(): string - { - $entity = $this->getEntity(); - if ($entity === null) { - return 'SWAG_MIGRATION_ENTITY_UNKNOWN'; - } - - return \sprintf('SWAG_MIGRATION_%s_ENTITY_UNKNOWN', \mb_strtoupper($entity)); - } - - public function getTitle(): string - { - $entity = $this->getEntity(); - if ($entity === null) { - return 'Cannot find entity'; - } - - return \sprintf('Cannot find %s', $entity); + parent::__construct( + $runId, + $profileName, + $gatewayName, + ); } - /** - * @return array{requiredForEntity: string, requiredForSourceId: string, entity: ?string, sourceId: ?string} - */ - public function getParameters(): array + public function isUserFixable(): bool { - return [ - 'requiredForEntity' => $this->requiredForEntity, - 'requiredForSourceId' => $this->requiredForSourceId, - 'entity' => $this->getEntity(), - 'sourceId' => $this->getSourceId(), - ]; + return false; } - public function getDescription(): string - { - $args = $this->getParameters(); - - return \sprintf( - 'The %s entity with the source id "%s" cannot find the depended %s entity with the source id "%s".', - $args['requiredForEntity'], - $args['requiredForSourceId'], - $args['entity'], - $args['sourceId'] - ); - } - - public function getTitleSnippet(): string + public function getLevel(): string { - return \sprintf('%s.%s.title', $this->getSnippetRoot(), 'SWAG_MIGRATION_ENTITY_UNKNOWN'); + return self::LOG_LEVEL_WARNING; } - public function getDescriptionSnippet(): string + public function getCode(): string { - return \sprintf('%s.%s.description', $this->getSnippetRoot(), 'SWAG_MIGRATION_ENTITY_UNKNOWN'); + return 'SWAG_MIGRATION_ENTITY_UNKNOWN'; } } diff --git a/src/Migration/Logging/Log/UnsupportedObjectType.php b/src/Migration/Logging/Log/UnsupportedObjectType.php index df34e69b5..f8d0165c7 100644 --- a/src/Migration/Logging/Log/UnsupportedObjectType.php +++ b/src/Migration/Logging/Log/UnsupportedObjectType.php @@ -14,11 +14,21 @@ class UnsupportedObjectType extends BaseRunLogEntry { public function __construct( string $runId, + string $profileName, + string $gatewayName, + /** @phpstan-ignore property.onlyWritten */ private readonly string $type, - string $entity, - string $sourceId, ) { - parent::__construct($runId, $entity, $sourceId); + parent::__construct( + $runId, + $profileName, + $gatewayName, + ); + } + + public function isUserFixable(): bool + { + return false; } public function getLevel(): string @@ -30,33 +40,4 @@ public function getCode(): string { return 'SWAG_MIGRATION__SHOPWARE_UNSUPPORTED_OBJECT_TYPE'; } - - public function getTitle(): string - { - return 'Unsupported object type'; - } - - /** - * @return array{objectType: string, entity: ?string, sourceId: ?string} - */ - public function getParameters(): array - { - return [ - 'objectType' => $this->type, - 'entity' => $this->getEntity(), - 'sourceId' => $this->getSourceId(), - ]; - } - - public function getDescription(): string - { - $args = $this->getParameters(); - - return \sprintf( - '%s of object type "%s" with source id "%s" could not be converted.', - $args['entity'], - $args['objectType'], - $args['sourceId'] - ); - } } diff --git a/src/Migration/Logging/Log/WriteExceptionRunLog.php b/src/Migration/Logging/Log/WriteExceptionRunLog.php index 32c192607..9af0b6c8d 100644 --- a/src/Migration/Logging/Log/WriteExceptionRunLog.php +++ b/src/Migration/Logging/Log/WriteExceptionRunLog.php @@ -17,11 +17,21 @@ class WriteExceptionRunLog extends BaseRunLogEntry */ public function __construct( string $runId, - string $entity, + string $profileName, + string $gatewayName, + /** @phpstan-ignore property.onlyWritten */ private readonly array $error, - ?string $dataId = null, ) { - parent::__construct($runId, $entity, $dataId); + parent::__construct( + $runId, + $profileName, + $gatewayName, + ); + } + + public function isUserFixable(): bool + { + return false; } public function getLevel(): string @@ -33,31 +43,4 @@ public function getCode(): string { return 'SWAG_MIGRATION__WRITE_EXCEPTION_OCCURRED'; } - - public function getTitle(): string - { - return 'A write exception has occurred'; - } - - /** - * @return array{entity: ?string, dataId: ?string, error: array, description: string} - */ - public function getParameters(): array - { - return [ - 'entity' => $this->getEntity(), - 'dataId' => $this->getSourceId(), - 'error' => $this->error, - 'description' => (string) \json_encode([ - 'entity' => $this->getEntity(), - 'dataId' => $this->getSourceId(), - 'error' => $this->error, - ], \JSON_PRETTY_PRINT), - ]; - } - - public function getDescription(): string - { - return $this->getParameters()['description']; - } } diff --git a/src/Migration/Logging/LoggingService.php b/src/Migration/Logging/LoggingService.php index 41f14bfaf..c34a48479 100644 --- a/src/Migration/Logging/LoggingService.php +++ b/src/Migration/Logging/LoggingService.php @@ -54,16 +54,12 @@ public function saveLogging(Context $context): void public function addLogEntry(LogEntryInterface $logEntry): void { $this->logging[] = [ + 'runId' => $logEntry->getRunId(), + 'profileName' => $logEntry->getProfileName(), + 'gatewayName' => $logEntry->getGatewayName(), 'level' => $logEntry->getLevel(), 'code' => $logEntry->getCode(), - 'title' => $logEntry->getTitle(), - 'description' => $logEntry->getDescription(), - 'parameters' => $logEntry->getParameters(), - 'titleSnippet' => $logEntry->getTitleSnippet(), - 'descriptionSnippet' => $logEntry->getDescriptionSnippet(), - 'entity' => $logEntry->getEntity(), - 'sourceId' => $logEntry->getSourceId(), - 'runId' => $logEntry->getRunId(), + 'userFixable' => $logEntry->isUserFixable(), ]; } diff --git a/src/Migration/Logging/SwagMigrationLoggingDefinition.php b/src/Migration/Logging/SwagMigrationLoggingDefinition.php index 2b4287fac..4f3e36fb4 100644 --- a/src/Migration/Logging/SwagMigrationLoggingDefinition.php +++ b/src/Migration/Logging/SwagMigrationLoggingDefinition.php @@ -9,13 +9,12 @@ use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition; use Shopware\Core\Framework\DataAbstractionLayer\Field\AutoIncrementField; +use Shopware\Core\Framework\DataAbstractionLayer\Field\BoolField; use Shopware\Core\Framework\DataAbstractionLayer\Field\CreatedAtField; use Shopware\Core\Framework\DataAbstractionLayer\Field\FkField; use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\PrimaryKey; use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\Required; use Shopware\Core\Framework\DataAbstractionLayer\Field\IdField; -use Shopware\Core\Framework\DataAbstractionLayer\Field\JsonField; -use Shopware\Core\Framework\DataAbstractionLayer\Field\LongTextField; use Shopware\Core\Framework\DataAbstractionLayer\Field\ManyToOneAssociationField; use Shopware\Core\Framework\DataAbstractionLayer\Field\StringField; use Shopware\Core\Framework\DataAbstractionLayer\Field\UpdatedAtField; @@ -46,21 +45,17 @@ public function getEntityClass(): string protected function defineFields(): FieldCollection { return new FieldCollection([ + new AutoIncrementField(), (new IdField('id', 'id'))->addFlags(new PrimaryKey(), new Required()), + new FkField('run_id', 'runId', SwagMigrationRunDefinition::class), + (new StringField('profile_name', 'profileName', 255))->addFlags(new Required()), + (new StringField('gateway_name', 'gatewayName', 255))->addFlags(new Required()), (new StringField('level', 'level', 64))->addFlags(new Required()), (new StringField('code', 'code'))->addFlags(new Required()), - (new LongTextField('title', 'title'))->addFlags(new Required()), - (new LongTextField('description', 'description'))->addFlags(new Required()), - (new JsonField('parameters', 'parameters'))->addFlags(new Required()), - (new StringField('title_snippet', 'titleSnippet'))->addFlags(new Required()), - (new StringField('description_snippet', 'descriptionSnippet'))->addFlags(new Required()), - new StringField('entity', 'entity'), - new StringField('source_id', 'sourceId'), - new FkField('run_id', 'runId', SwagMigrationRunDefinition::class), + (new BoolField('user_fixable', 'userFixable'))->addFlags(new Required()), new CreatedAtField(), new UpdatedAtField(), new ManyToOneAssociationField('run', 'run_id', SwagMigrationRunDefinition::class), - new AutoIncrementField(), ]); } } diff --git a/src/Migration/Logging/SwagMigrationLoggingEntity.php b/src/Migration/Logging/SwagMigrationLoggingEntity.php index 56727b665..037905697 100644 --- a/src/Migration/Logging/SwagMigrationLoggingEntity.php +++ b/src/Migration/Logging/SwagMigrationLoggingEntity.php @@ -17,138 +17,90 @@ class SwagMigrationLoggingEntity extends Entity { use EntityIdTrait; - protected string $level; - - protected string $code; - - protected string $title; + protected string $runId; - protected string $description; + protected SwagMigrationRunEntity $run; - protected array $parameters; + protected string $profileName; - protected string $titleSnippet; + protected string $gatewayName; - protected string $descriptionSnippet; - - protected ?string $entity; - - protected ?string $sourceId; + protected string $level; - protected ?string $runId; + protected string $code; - protected ?SwagMigrationRunEntity $run; + protected bool $userFixable; protected int $autoIncrement; - public function getLevel(): string - { - return $this->level; - } - - public function setLevel(string $level): void - { - $this->level = $level; - } - - public function getCode(): string - { - return $this->code; - } - - public function setCode(string $code): void - { - $this->code = $code; - } - - public function getTitle(): string + public function getRunId(): string { - return $this->title; - } - - public function setTitle(string $title): void - { - $this->title = $title; - } - - public function getDescription(): string - { - return $this->description; - } - - public function setDescription(string $description): void - { - $this->description = $description; - } - - public function getParameters(): array - { - return $this->parameters; + return $this->runId; } - public function setParameters(array $parameters): void + public function setRunId(string $runId): void { - $this->parameters = $parameters; + $this->runId = $runId; } - public function getTitleSnippet(): string + public function getRun(): SwagMigrationRunEntity { - return $this->titleSnippet; + return $this->run; } - public function setTitleSnippet(string $titleSnippet): void + public function setRun(SwagMigrationRunEntity $run): void { - $this->titleSnippet = $titleSnippet; + $this->run = $run; } - public function getDescriptionSnippet(): string + public function getProfileName(): string { - return $this->descriptionSnippet; + return $this->profileName; } - public function setDescriptionSnippet(string $descriptionSnippet): void + public function setProfileName(string $profileName): void { - $this->descriptionSnippet = $descriptionSnippet; + $this->profileName = $profileName; } - public function getEntity(): ?string + public function getGatewayName(): string { - return $this->entity; + return $this->gatewayName; } - public function setEntity(?string $entity): void + public function setGatewayName(string $gatewayName): void { - $this->entity = $entity; + $this->gatewayName = $gatewayName; } - public function getSourceId(): ?string + public function getLevel(): string { - return $this->sourceId; + return $this->level; } - public function setSourceId(?string $sourceId): void + public function setLevel(string $level): void { - $this->sourceId = $sourceId; + $this->level = $level; } - public function getRunId(): ?string + public function getCode(): string { - return $this->runId; + return $this->code; } - public function setRunId(?string $runId): void + public function setCode(string $code): void { - $this->runId = $runId; + $this->code = $code; } - public function getRun(): ?SwagMigrationRunEntity + public function isUserFixable(): bool { - return $this->run; + return $this->userFixable; } - public function setRun(?SwagMigrationRunEntity $run): void + public function setUserFixable(bool $userFixable): void { - $this->run = $run; + $this->userFixable = $userFixable; } public function getAutoIncrement(): int diff --git a/src/Migration/Media/Processor/HttpDownloadServiceBase.php b/src/Migration/Media/Processor/HttpDownloadServiceBase.php index 2f02e92d6..6dc4dd56e 100644 --- a/src/Migration/Media/Processor/HttpDownloadServiceBase.php +++ b/src/Migration/Media/Processor/HttpDownloadServiceBase.php @@ -62,6 +62,8 @@ abstract public function supports(MigrationContextInterface $migrationContext): */ public function process(MigrationContextInterface $migrationContext, Context $context, array $workload): array { + $connection = $migrationContext->getConnection(); + // Map workload with uuids as keys $mappedWorkload = []; foreach ($workload as $work) { @@ -76,7 +78,8 @@ public function process(MigrationContextInterface $migrationContext, Context $co if ($client === null) { $this->loggingService->addLogEntry(new ExceptionRunLog( $migrationContext->getRunUuid(), - $this->getMediaEntity(), + $connection->getProfileName(), + $connection->getGatewayName(), new \Exception('Http download client can not be constructed.') )); $this->loggingService->saveLogging($context); @@ -84,7 +87,7 @@ public function process(MigrationContextInterface $migrationContext, Context $co return $workload; } // Do download requests and store the promises - $promises = $this->doMediaDownloadRequests($media, $mappedWorkload, $client); + $promises = $this->doMediaDownloadRequests($migrationContext, $media, $mappedWorkload, $client); // Wait for the requests to complete, even if some of them fail /** @var array $results */ @@ -119,8 +122,8 @@ function (MediaProcessWorkloadStruct $work) use ($uuid) { $work->setState(MediaProcessWorkloadStruct::ERROR_STATE); $this->loggingService->addLogEntry(new CannotGetFileRunLog( $work->getRunId(), - $this->getMediaEntity(), - $work->getMediaId(), + $connection->getProfileName(), + $connection->getGatewayName(), $work->getAdditionalData()['uri'], $result['reason'] ?? null )); @@ -140,8 +143,8 @@ function (MediaProcessWorkloadStruct $work) use ($uuid) { $work->setState(MediaProcessWorkloadStruct::ERROR_STATE); $this->loggingService->addLogEntry(new TemporaryFileErrorLog( $work->getRunId(), - $this->getMediaEntity(), - $uuid + $connection->getProfileName(), + $connection->getGatewayName(), )); continue; @@ -181,9 +184,9 @@ function (MediaProcessWorkloadStruct $work) use ($uuid) { $work->setState(MediaProcessWorkloadStruct::ERROR_STATE); $this->loggingService->addLogEntry(new ExceptionRunLog( $work->getRunId(), - $this->getMediaEntity(), + $connection->getProfileName(), + $connection->getGatewayName(), $e, - $uuid )); } finally { // clear up temp data @@ -246,7 +249,7 @@ final protected function getDataSetEntity(MigrationContextInterface $migrationCo * * @return array */ - private function doMediaDownloadRequests(array $media, array &$mappedWorkload, HttpClientInterface $client): array + private function doMediaDownloadRequests(MigrationContextInterface $migrationContext, array $media, array &$mappedWorkload, HttpClientInterface $client): array { $promises = []; foreach ($media as $mediaFile) { @@ -256,7 +259,7 @@ private function doMediaDownloadRequests(array $media, array &$mappedWorkload, H $additionalData['uri'] = $mediaFile['uri']; $mappedWorkload[$uuid]->setAdditionalData($additionalData); - $promise = $this->doNormalDownloadRequest($mappedWorkload[$uuid], $client); + $promise = $this->doNormalDownloadRequest($migrationContext, $mappedWorkload[$uuid], $client); if ($promise !== null) { $promises[$uuid] = $promise; @@ -266,7 +269,7 @@ private function doMediaDownloadRequests(array $media, array &$mappedWorkload, H return $promises; } - private function doNormalDownloadRequest(MediaProcessWorkloadStruct $workload, HttpClientInterface $client): ?PromiseInterface + private function doNormalDownloadRequest(MigrationContextInterface $migrationContext, MediaProcessWorkloadStruct $workload, HttpClientInterface $client): ?PromiseInterface { $additionalData = $workload->getAdditionalData(); @@ -276,12 +279,14 @@ private function doNormalDownloadRequest(MediaProcessWorkloadStruct $workload, H $workload->setCurrentOffset((int) $additionalData['file_size']); $workload->setState(MediaProcessWorkloadStruct::FINISH_STATE); } catch (\Throwable $exception) { + $connection = $migrationContext->getConnection(); + // this should never happen because of Promises, but just in case something is wrong with request construction $this->loggingService->addLogEntry(new ExceptionRunLog( $workload->getRunId(), - $this->getMediaEntity(), + $connection->getProfileName(), + $connection->getGatewayName(), $exception, - $workload->getMediaId() )); $promise = null; @@ -296,16 +301,20 @@ private function persistFileToMedia(string $filePath, string $uuid, string $name // determine correct info about the temporary file, except for the $fileExtension (which can be overridden) $fileSize = \filesize($filePath); $mimeType = \mime_content_type($filePath); + if ($fileSize === false || $fileSize === 0 || $mimeType === false) { + $connection = $migrationContext->getConnection(); + $this->loggingService->addLogEntry(new ExceptionRunLog( $migrationContext->getRunUuid(), - $this->getMediaEntity(), + $connection->getProfileName(), + $connection->getGatewayName(), new \Exception('Downloaded file is empty or could not determine mime type.'), - $uuid )); return; } + $fileHash = \hash_file('md5', $filePath); $mediaFile = new MediaFile( $filePath, @@ -331,11 +340,13 @@ private function persistFileToMedia(string $filePath, string $uuid, string $name } elseif (\in_array($mediaException->getErrorCode(), [MediaException::MEDIA_ILLEGAL_FILE_NAME, MediaException::MEDIA_EMPTY_FILE_NAME], true)) { $this->fileSaver->persistFileToMedia($mediaFile, Uuid::randomHex(), $uuid, $context); } else { + $connection = $migrationContext->getConnection(); + $this->loggingService->addLogEntry(new ExceptionRunLog( $migrationContext->getRunUuid(), - $this->getMediaEntity(), + $connection->getProfileName(), + $connection->getGatewayName(), $mediaException, - $uuid )); } } diff --git a/src/Migration/MessageQueue/Handler/ProcessMediaHandler.php b/src/Migration/MessageQueue/Handler/ProcessMediaHandler.php index 6839764c6..a13511080 100644 --- a/src/Migration/MessageQueue/Handler/ProcessMediaHandler.php +++ b/src/Migration/MessageQueue/Handler/ProcessMediaHandler.php @@ -83,10 +83,9 @@ public function __invoke(ProcessMediaMessage $message): void $processor = $this->mediaFileProcessorRegistry->getProcessor($migrationContext); $workload = $processor->process($migrationContext, $context, $workload); $this->processFailures($context, $migrationContext, $processor, $workload); - } catch (NoConnectionFoundException $e) { + } catch (NoConnectionFoundException) { $this->loggingService->addLogEntry(new ProcessorNotFoundLog( $message->getRunId(), - $message->getEntityName(), $connection->getProfileName(), $connection->getGatewayName() )); @@ -95,7 +94,8 @@ public function __invoke(ProcessMediaMessage $message): void } catch (\Exception $e) { $this->loggingService->addLogEntry(new ExceptionRunLog( $message->getRunId(), - $message->getEntityName(), + $connection->getProfileName(), + $connection->getGatewayName(), $e )); diff --git a/src/Migration/MigrationContext.php b/src/Migration/MigrationContext.php index f82105710..1ba4cbc30 100644 --- a/src/Migration/MigrationContext.php +++ b/src/Migration/MigrationContext.php @@ -54,8 +54,10 @@ public function getProfile(): ProfileInterface return $this->profile; } - public function getConnection(): ?SwagMigrationConnectionEntity + public function getConnection(): SwagMigrationConnectionEntity { + \assert($this->connection instanceof SwagMigrationConnectionEntity); + return $this->connection; } diff --git a/src/Migration/MigrationContextInterface.php b/src/Migration/MigrationContextInterface.php index 60da42ce4..b2b893a66 100644 --- a/src/Migration/MigrationContextInterface.php +++ b/src/Migration/MigrationContextInterface.php @@ -18,7 +18,7 @@ interface MigrationContextInterface { public function getProfile(): ProfileInterface; - public function getConnection(): ?SwagMigrationConnectionEntity; + public function getConnection(): SwagMigrationConnectionEntity; public function getRunUuid(): string; diff --git a/src/Migration/Run/RunService.php b/src/Migration/Run/RunService.php index c007637b1..abf30983d 100644 --- a/src/Migration/Run/RunService.php +++ b/src/Migration/Run/RunService.php @@ -254,10 +254,11 @@ public function assignThemeToSalesChannel(string $runUuid, Context $context): vo foreach ($salesChannels as $salesChannel) { try { $this->themeService->assignTheme($defaultTheme, $salesChannel, $context); - } catch (\Throwable $exception) { + } catch (\Throwable) { $this->loggingService->addLogEntry(new ThemeCompilingErrorRunLog( $runUuid, - $defaultTheme + $connection->getProfileName(), + $connection->getGatewayName(), )); } } diff --git a/src/Migration/Service/MediaFileProcessorService.php b/src/Migration/Service/MediaFileProcessorService.php index 09ccc695b..99193d038 100644 --- a/src/Migration/Service/MediaFileProcessorService.php +++ b/src/Migration/Service/MediaFileProcessorService.php @@ -44,8 +44,8 @@ public function processMediaFiles(MigrationContextInterface $migrationContext, C if ($currentDataSet === null) { try { $currentDataSet = $this->dataSetRegistry->getDataSet($migrationContext, $mediaFile['entity']); - } catch (DataSetNotFoundException $e) { - $this->logDataSetNotFoundException($migrationContext, $mediaFile); + } catch (DataSetNotFoundException) { + $this->logDataSetNotFoundException($migrationContext); continue; } @@ -58,8 +58,8 @@ public function processMediaFiles(MigrationContextInterface $migrationContext, C $messageMediaUuids = []; $currentCount = 0; $currentDataSet = $this->dataSetRegistry->getDataSet($migrationContext, $mediaFile['entity']); - } catch (DataSetNotFoundException $e) { - $this->logDataSetNotFoundException($migrationContext, $mediaFile); + } catch (DataSetNotFoundException) { + $this->logDataSetNotFoundException($migrationContext); continue; } @@ -128,25 +128,15 @@ private function addMessageToBus(string $runUuid, Context $context, DataSet $dat $this->messageBus->dispatch($message); } - /** - * @param array $mediaFile - */ - private function logDataSetNotFoundException( - MigrationContextInterface $migrationContext, - array $mediaFile, - ): void { + private function logDataSetNotFoundException(MigrationContextInterface $migrationContext): void + { $connection = $migrationContext->getConnection(); - if ($connection === null) { - return; - } - $this->loggingService->addLogEntry( new DataSetNotFoundLog( $migrationContext->getRunUuid(), - $mediaFile['entity'], - $mediaFile['id'], - $connection->getProfileName() + $connection->getProfileName(), + $connection->getGatewayName(), ) ); } diff --git a/src/Migration/Service/MigrationDataConverter.php b/src/Migration/Service/MigrationDataConverter.php index ab6d8cdb4..6ebdd668a 100644 --- a/src/Migration/Service/MigrationDataConverter.php +++ b/src/Migration/Service/MigrationDataConverter.php @@ -67,11 +67,15 @@ public function convert(array $data, MigrationContextInterface $migrationContext $this->mediaFileService->writeMediaFile($context); } } catch (\Throwable $exception) { + $connection = $migrationContext->getConnection(); + $this->loggingService->addLogEntry(new ExceptionRunLog( $migrationContext->getRunUuid(), - $dataSet::getEntity(), + $connection->getProfileName(), + $connection->getGatewayName(), $exception )); + $this->loggingService->saveLogging($context); } } @@ -101,11 +105,13 @@ private function convertData( 'convertFailure' => $convertFailureFlag, ]; } catch (\Throwable $exception) { + $connection = $migrationContext->getConnection(); + $this->loggingService->addLogEntry(new ExceptionRunLog( $runUuid, - $dataSet::getEntity(), - $exception, - $item['id'] ?? null + $connection->getProfileName(), + $connection->getGatewayName(), + $exception )); $createData[] = [ diff --git a/src/Migration/Service/MigrationDataFetcher.php b/src/Migration/Service/MigrationDataFetcher.php index 1bfcf9ea6..7874c8076 100644 --- a/src/Migration/Service/MigrationDataFetcher.php +++ b/src/Migration/Service/MigrationDataFetcher.php @@ -34,9 +34,12 @@ public function fetchData(MigrationContextInterface $migrationContext, Context $ try { return $this->gatewayRegistry->getGateway($migrationContext)->read($migrationContext); } catch (\Throwable $exception) { + $connection = $migrationContext->getConnection(); + $this->loggingService->addLogEntry(new ExceptionRunLog( $migrationContext->getRunUuid(), - $dataSet::getEntity(), + $connection->getProfileName(), + $connection->getGatewayName(), $exception )); $this->loggingService->saveLogging($context); diff --git a/src/Migration/Service/MigrationDataWriter.php b/src/Migration/Service/MigrationDataWriter.php index f64147710..399efe930 100644 --- a/src/Migration/Service/MigrationDataWriter.php +++ b/src/Migration/Service/MigrationDataWriter.php @@ -104,9 +104,12 @@ public function writeData(MigrationContextInterface $migrationContext, Context $ $currentWriter = $this->writerRegistry->getWriter($dataSet::getEntity()); $currentWriter->writeData(\array_values($converted), $this->writeContext); } catch (WriterNotFoundException $writerNotFoundException) { + $connection = $migrationContext->getConnection(); + $this->loggingService->addLogEntry(new ExceptionRunLog( $migrationContext->getRunUuid(), - $dataSet::getEntity(), + $connection->getProfileName(), + $connection->getGatewayName(), $writerNotFoundException )); $this->loggingService->saveLogging($context); @@ -163,6 +166,8 @@ private function handleWriteException( MigrationContextInterface $migrationContext, Context $context, ): void { + $connection = $migrationContext->getConnection(); + $writeErrors = $this->extractWriteErrorsWithIndex($exception); $currentWriter = $this->writerRegistry->getWriter($entityName); $newData = []; @@ -178,11 +183,12 @@ private function handleWriteException( $updateWrittenData[$dataId]['written'] = false; $updateWrittenData[$dataId]['writeFailure'] = true; + $this->loggingService->addLogEntry(new WriteExceptionRunLog( $migrationContext->getRunUuid(), - $entityName, + $connection->getProfileName(), + $connection->getGatewayName(), $writeErrors[$index], - $dataId )); ++$index; @@ -194,7 +200,7 @@ private function handleWriteException( try { $currentWriter->writeData($newData, $this->writeContext); - } catch (\Throwable $exception) { + } catch (\Throwable) { $this->writePerEntity($converted, $entityName, $updateWrittenData, $migrationContext, $context); } } @@ -229,6 +235,8 @@ private function writePerEntity( MigrationContextInterface $migrationContext, Context $context, ): void { + $connection = $migrationContext->getConnection(); + foreach ($converted as $dataId => $entity) { try { $currentWriter = $this->writerRegistry->getWriter($entityName); @@ -236,9 +244,9 @@ private function writePerEntity( } catch (\Throwable $exception) { $this->loggingService->addLogEntry(new ExceptionRunLog( $migrationContext->getRunUuid(), - $entityName, + $connection->getProfileName(), + $connection->getGatewayName(), $exception, - $dataId )); $updateWrittenData[$dataId]['written'] = false; diff --git a/src/Migration/Subscriber/MessageQueueSubscriber.php b/src/Migration/Subscriber/MessageQueueSubscriber.php index 1449a6350..5066dcf02 100644 --- a/src/Migration/Subscriber/MessageQueueSubscriber.php +++ b/src/Migration/Subscriber/MessageQueueSubscriber.php @@ -82,11 +82,19 @@ public function onWorkerMessageFailed(WorkerMessageFailedEvent $event): void return; } + $connection = $run->getConnection(); + /* * Raise exception counter and log the exception */ $progress->raiseExceptionCount(); - $this->loggingService->addLogEntry(new MessageQueueExceptionLog($run->getId(), $event->getThrowable(), $progress->getExceptionCount())); + $this->loggingService->addLogEntry(new MessageQueueExceptionLog( + $run->getId(), + $connection?->getProfileName() ?? 'unknown', + $connection?->getGatewayName() ?? 'unknown', + $event->getThrowable(), + $progress->getExceptionCount() + )); /* * Check if run is already in aborting state and failed again there, then set run status to aborted and log the error. @@ -96,7 +104,12 @@ public function onWorkerMessageFailed(WorkerMessageFailedEvent $event): void $progress->setIsAborted(true); $this->updateRun($run->getId(), $progress, $message->getContext()); - $this->loggingService->addLogEntry(new RunAbortedAutomatically($run->getId(), $event->getThrowable())); + $this->loggingService->addLogEntry(new RunAbortedAutomatically( + $run->getId(), + $connection?->getProfileName() ?? 'unknown', + $connection?->getGatewayName() ?? 'unknown', + $event->getThrowable(), + )); $this->loggingService->saveLogging($message->getContext()); return; diff --git a/src/Profile/Shopware/Converter/CategoryConverter.php b/src/Profile/Shopware/Converter/CategoryConverter.php index 95edfc0c3..1beef67df 100644 --- a/src/Profile/Shopware/Converter/CategoryConverter.php +++ b/src/Profile/Shopware/Converter/CategoryConverter.php @@ -90,8 +90,8 @@ public function convert( if (!isset($data['_locale'])) { $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( $migrationContext->getRunUuid(), - DefaultEntities::CATEGORY, - $this->oldCategoryId, + $connection->getProfileName(), + $connection->getGatewayName(), 'locale' )); diff --git a/src/Profile/Shopware/Converter/CrossSellingConverter.php b/src/Profile/Shopware/Converter/CrossSellingConverter.php index 07c487f00..c9e56d3ca 100644 --- a/src/Profile/Shopware/Converter/CrossSellingConverter.php +++ b/src/Profile/Shopware/Converter/CrossSellingConverter.php @@ -63,8 +63,8 @@ public function convert(array $data, Context $context, MigrationContextInterface if ($sourceProductMapping === null) { $this->loggingService->addLogEntry(new AssociationRequiredMissingLog( $this->runId, - DefaultEntities::PRODUCT, - $data['articleID'], + $connection->getProfileName(), + $connection->getGatewayName(), $data['type'] )); @@ -76,8 +76,8 @@ public function convert(array $data, Context $context, MigrationContextInterface if ($relatedProductMapping === null) { $this->loggingService->addLogEntry(new AssociationRequiredMissingLog( $this->runId, - DefaultEntities::PRODUCT, - $data['relatedarticle'], + $connection->getProfileName(), + $connection->getGatewayName(), $data['type'] )); diff --git a/src/Profile/Shopware/Converter/CustomerConverter.php b/src/Profile/Shopware/Converter/CustomerConverter.php index 394153a0a..d03ca2b35 100644 --- a/src/Profile/Shopware/Converter/CustomerConverter.php +++ b/src/Profile/Shopware/Converter/CustomerConverter.php @@ -99,13 +99,21 @@ public function convert( $this->runId = $migrationContext->getRunUuid(); $this->migrationContext = $migrationContext; + $connection = $migrationContext->getConnection(); + $this->connectionId = ''; + $this->connectionName = ''; + if ($connection !== null) { + $this->connectionId = $connection->getId(); + $this->connectionName = $connection->getName(); + } + $fields = $this->checkForEmptyRequiredDataFields($data, $this->requiredDataFieldKeys); if (!empty($fields)) { $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( $this->runId, - DefaultEntities::CUSTOMER, - $data['id'], + $connection->getProfileName(), + $connection->getGatewayName(), \implode(',', $fields) )); @@ -115,8 +123,8 @@ public function convert( if (!$this->checkEmailValidity($data['email'])) { $this->loggingService->addLogEntry(new InvalidEmailAddressLog( $this->runId, - DefaultEntities::CUSTOMER, - $data['id'], + $connection->getProfileName(), + $connection->getGatewayName(), $data['email'] )); @@ -127,14 +135,6 @@ public function convert( $this->mainLocale = $data['_locale']; unset($data['_locale']); - $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - $this->connectionName = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - $this->connectionName = $connection->getName(); - } - $this->mainMapping = $this->mappingService->getOrCreateMapping( $this->connectionId, DefaultEntities::CUSTOMER, @@ -236,8 +236,8 @@ public function convert( if ($mapping === null) { $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( $this->runId, - DefaultEntities::CUSTOMER, - $this->oldCustomerId, + $connection->getProfileName(), + $connection->getGatewayName(), 'defaultpayment' )); @@ -298,8 +298,8 @@ public function convert( $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( $this->runId, - DefaultEntities::CUSTOMER, - $this->oldCustomerId, + $connection->getProfileName(), + $connection->getGatewayName(), 'address data' )); @@ -343,10 +343,12 @@ protected function getDefaultPaymentMethod(array $originalData): ?string ); if ($paymentMethodMapping === null) { + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry(new UnknownEntityLog( $this->runId, - DefaultEntities::PAYMENT_METHOD, - $originalData['id'], + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::CUSTOMER, $this->oldCustomerId )); @@ -371,10 +373,12 @@ protected function applyAddresses(array &$originalData, array &$converted, strin $fields = $this->checkForEmptyRequiredDataFields($address, $this->requiredAddressDataFieldKeys); if (!empty($fields)) { + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( $this->runId, - DefaultEntities::CUSTOMER_ADDRESS, - $address['id'], + $connection->getProfileName(), + $connection->getGatewayName(), \implode(',', $fields) )); @@ -548,6 +552,8 @@ protected function applyCountryTranslation(array &$country, array $data): void */ protected function getCountryState(array $oldAddressData, string $newCountryId): array { + $connection = $this->migrationContext->getConnection(); + if (!isset($oldAddressData['state_id'])) { return []; } @@ -558,8 +564,8 @@ protected function getCountryState(array $oldAddressData, string $newCountryId): $this->loggingService->addLogEntry( new UnknownEntityLog( $this->runId, - DefaultEntities::COUNTRY_STATE, - $oldAddressData['state_id'] ?? 'unknown', + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::CUSTOMER, $this->oldCustomerId ) @@ -596,8 +602,8 @@ protected function getCountryState(array $oldAddressData, string $newCountryId): $this->loggingService->addLogEntry( new UnknownEntityLog( $this->runId, - DefaultEntities::COUNTRY_STATE, - $oldAddressData['state_id'], + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::CUSTOMER, $this->oldCustomerId ) @@ -669,10 +675,12 @@ protected function checkUnsetDefaultShippingAndDefaultBillingAddress(array &$ori $converted['defaultShippingAddressId'] = $addresses[0]['id']; unset($originalData['default_billing_address_id'], $originalData['default_shipping_address_id']); + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry(new FieldReassignedRunLog( $this->runId, - DefaultEntities::CUSTOMER, - $customerUuid, + $connection->getProfileName(), + $connection->getGatewayName(), 'default billing and shipping address', 'first address' )); @@ -689,10 +697,12 @@ protected function checkUnsetDefaultShippingAddress(array &$originalData, array $converted['defaultShippingAddressId'] = $converted['defaultBillingAddressId']; unset($originalData['default_shipping_address_id']); + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry(new FieldReassignedRunLog( $this->runId, - DefaultEntities::CUSTOMER, - $customerUuid, + $connection->getProfileName(), + $connection->getGatewayName(), 'default shipping address', 'default billing address' )); @@ -709,10 +719,12 @@ protected function checkUnsetDefaultBillingAddress(array &$originalData, array & $converted['defaultBillingAddressId'] = $converted['defaultShippingAddressId']; unset($originalData['default_billing_address_id']); + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry(new FieldReassignedRunLog( $this->runId, - DefaultEntities::CUSTOMER, - $customerUuid, + $connection->getProfileName(), + $connection->getGatewayName(), 'default billing address', 'default shipping address' )); @@ -729,10 +741,12 @@ protected function getSalutation(string $salutation): ?string ); if ($mapping === null) { + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry(new UnknownEntityLog( $this->runId, - DefaultEntities::SALUTATION, - $salutation, + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::CUSTOMER, $this->oldCustomerId )); diff --git a/src/Profile/Shopware/Converter/LanguageConverter.php b/src/Profile/Shopware/Converter/LanguageConverter.php index c35293ab4..367c84ad8 100644 --- a/src/Profile/Shopware/Converter/LanguageConverter.php +++ b/src/Profile/Shopware/Converter/LanguageConverter.php @@ -54,8 +54,8 @@ public function convert(array $data, Context $context, MigrationContextInterface if ($languageUuid !== null) { $this->loggingService->addLogEntry(new EntityAlreadyExistsRunLog( $migrationContext->getRunUuid(), - DefaultEntities::LANGUAGE, - $data['id'] + $connection->getProfileName(), + $connection->getGatewayName(), )); return new ConvertStruct(null, $data); diff --git a/src/Profile/Shopware/Converter/MainVariantRelationConverter.php b/src/Profile/Shopware/Converter/MainVariantRelationConverter.php index f6bfcfe79..f4a81ff31 100644 --- a/src/Profile/Shopware/Converter/MainVariantRelationConverter.php +++ b/src/Profile/Shopware/Converter/MainVariantRelationConverter.php @@ -65,13 +65,13 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($mainProductMapping === null) { - $this->addAssociationRequiredLog(DefaultEntities::PRODUCT_CONTAINER, $data['id']); + $this->addAssociationRequiredLog($migrationContext); return new ConvertStruct(null, $data); } if ($variantProductMapping === null) { - $this->addAssociationRequiredLog(DefaultEntities::PRODUCT, $data['ordernumber']); + $this->addAssociationRequiredLog($migrationContext); return new ConvertStruct(null, $data); } @@ -98,13 +98,15 @@ public function convert(array $data, Context $context, MigrationContextInterface return new ConvertStruct($converted, $returnData, $this->mainMapping['id'] ?? null); } - private function addAssociationRequiredLog(string $requiredEntity, string $id): void + private function addAssociationRequiredLog(MigrationContextInterface $migrationContext): void { + $connection = $migrationContext->getConnection(); + $this->loggingService->addLogEntry( new AssociationRequiredMissingLog( $this->runUuid, - $requiredEntity, - $id, + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::MAIN_VARIANT_RELATION ) ); diff --git a/src/Profile/Shopware/Converter/NewsletterRecipientConverter.php b/src/Profile/Shopware/Converter/NewsletterRecipientConverter.php index adc1fe172..9d929a63c 100644 --- a/src/Profile/Shopware/Converter/NewsletterRecipientConverter.php +++ b/src/Profile/Shopware/Converter/NewsletterRecipientConverter.php @@ -55,14 +55,20 @@ public function convert( Context $context, MigrationContextInterface $migrationContext, ): ConvertStruct { + $connection = $migrationContext->getConnection(); + $this->connectionId = ''; + if ($connection !== null) { + $this->connectionId = $connection->getId(); + } + $this->runId = $migrationContext->getRunUuid(); $fields = $this->checkForEmptyRequiredDataFields($data, $this->requiredDataFieldKeys); if (!empty($fields)) { $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( $this->runId, - DefaultEntities::NEWSLETTER_RECIPIENT, - $data['id'], + $connection->getProfileName(), + $connection->getGatewayName(), \implode(',', $fields) )); @@ -74,12 +80,6 @@ public function convert( $this->locale = $data['_locale']; unset($data['_locale']); - $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } - $converted = []; $this->oldNewsletterRecipientId = $data['id']; $this->mainMapping = $this->mappingService->getOrCreateMapping( @@ -104,7 +104,7 @@ public function convert( $this->convertValue($converted, 'city', $address, 'city'); if (isset($address['salutation'])) { - $salutationUuid = $this->getSalutation($address['salutation']); + $salutationUuid = $this->getSalutation($address['salutation'], $migrationContext); if ($salutationUuid !== null) { $converted['salutationId'] = $salutationUuid; } @@ -116,7 +116,7 @@ public function convert( if (isset($converted['confirmedAt'])) { $status = 'optIn'; } else { - $status = $this->getStatus(); + $status = $this->getStatus($migrationContext); } if ($status === null) { @@ -150,7 +150,7 @@ public function convert( return new ConvertStruct($converted, $returnData, $this->mainMapping['id'] ?? null); } - protected function getSalutation(string $salutation): ?string + protected function getSalutation(string $salutation, MigrationContextInterface $migrationContext): ?string { $salutationMapping = $this->mappingService->getMapping( $this->connectionId, @@ -160,10 +160,12 @@ protected function getSalutation(string $salutation): ?string ); if ($salutationMapping === null) { + $connection = $migrationContext->getConnection(); + $this->loggingService->addLogEntry(new UnknownEntityLog( $this->runId, - 'salutation', - $salutation, + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::NEWSLETTER_RECIPIENT, $this->oldNewsletterRecipientId )); @@ -190,10 +192,12 @@ protected function getSalesChannel(array $data): ?string } if (!isset($salesChannelMapping)) { + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( $this->runId, - DefaultEntities::NEWSLETTER_RECIPIENT, - $this->oldNewsletterRecipientId, + $connection->getProfileName(), + $connection->getGatewayName(), 'salesChannel' )); @@ -204,7 +208,7 @@ protected function getSalesChannel(array $data): ?string return $salesChannelMapping['entityUuid']; } - protected function getStatus(): ?string + protected function getStatus(MigrationContextInterface $migrationContext): ?string { $status = $this->mappingService->getValue( $this->connectionId, @@ -214,10 +218,12 @@ protected function getStatus(): ?string ); if ($status === null) { + $connection = $migrationContext->getConnection(); + $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( $this->runId, - DefaultEntities::NEWSLETTER_RECIPIENT, - $this->oldNewsletterRecipientId, + $connection->getProfileName(), + $connection->getGatewayName(), 'status' )); } diff --git a/src/Profile/Shopware/Converter/NumberRangeConverter.php b/src/Profile/Shopware/Converter/NumberRangeConverter.php index 6809c65d0..c524cfe81 100644 --- a/src/Profile/Shopware/Converter/NumberRangeConverter.php +++ b/src/Profile/Shopware/Converter/NumberRangeConverter.php @@ -67,12 +67,18 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->numberRangeTypes = $this->numberRangeTypeRepo->search(new Criteria(), $context)->getEntities(); } + $connection = $migrationContext->getConnection(); + if ($connection === null) { + return new ConvertStruct(null, $data); + } + $this->connectionId = $connection->getId(); + if (!\array_key_exists($data['name'], self::TYPE_MAPPING)) { $this->loggingService->addLogEntry( new UnsupportedNumberRangeTypeLog( $migrationContext->getRunUuid(), - DefaultEntities::NUMBER_RANGE, - $data['id'], + $connection->getProfileName(), + $connection->getGatewayName(), $data['name'] ) ); @@ -80,12 +86,6 @@ public function convert(array $data, Context $context, MigrationContextInterface return new ConvertStruct(null, $data); } - $connection = $migrationContext->getConnection(); - if ($connection === null) { - return new ConvertStruct(null, $data); - } - $this->connectionId = $connection->getId(); - $converted = []; $converted['id'] = $this->getUuid($data, $migrationContext, $context); $converted['typeId'] = $this->getProductNumberRangeTypeUuid($data['name']); @@ -93,8 +93,8 @@ public function convert(array $data, Context $context, MigrationContextInterface if (empty($converted['typeId'])) { $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( $migrationContext->getRunUuid(), - DefaultEntities::NUMBER_RANGE, - $data['id'], + $connection->getProfileName(), + $connection->getGatewayName(), 'typeId' )); diff --git a/src/Profile/Shopware/Converter/OrderConverter.php b/src/Profile/Shopware/Converter/OrderConverter.php index 07c528830..59446bf75 100644 --- a/src/Profile/Shopware/Converter/OrderConverter.php +++ b/src/Profile/Shopware/Converter/OrderConverter.php @@ -118,6 +118,14 @@ public function convert( $this->runId = $migrationContext->getRunUuid(); $this->migrationContext = $migrationContext; + $connection = $migrationContext->getConnection(); + $this->connectionName = ''; + $this->connectionId = ''; + if ($connection !== null) { + $this->connectionId = $connection->getId(); + $this->connectionName = $connection->getName(); + } + $fields = $this->checkForEmptyRequiredDataFields($data, $this->requiredDataFieldKeys); if (empty($data['billingaddress']['id'])) { $fields[] = 'billingaddress'; @@ -129,8 +137,8 @@ public function convert( if (!empty($fields)) { $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( $this->runId, - DefaultEntities::ORDER, - $this->oldId, + $connection->getProfileName(), + $connection->getGatewayName(), \implode(',', $fields) )); @@ -141,14 +149,6 @@ public function convert( unset($data['_locale']); $this->context = $context; - $connection = $migrationContext->getConnection(); - $this->connectionName = ''; - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - $this->connectionName = $connection->getName(); - } - $converted = []; $this->mainMapping = $this->mappingService->getOrCreateMapping( $this->connectionId, @@ -218,8 +218,8 @@ public function convert( if ($currencyUuid === null) { $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( $this->runId, - DefaultEntities::ORDER, - $this->oldId, + $connection->getProfileName(), + $connection->getGatewayName(), 'currency' )); @@ -247,8 +247,8 @@ public function convert( if ($stateMapping === null) { $this->loggingService->addLogEntry(new UnknownEntityLog( $this->runId, - 'order_state', - (string) $data['status'], + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::ORDER, $this->oldId )); @@ -325,8 +325,8 @@ public function convert( if (empty($billingAddress)) { $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( $this->runId, - DefaultEntities::ORDER, - $this->oldId, + $connection->getProfileName(), + $connection->getGatewayName(), 'billingaddress' )); @@ -429,10 +429,12 @@ protected function applyTransactions(array $data, array &$converted): void ); if ($mapping === null) { + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry(new UnknownEntityLog( $this->runId, - 'transaction_state', - $data['cleared'], + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::ORDER_TRANSACTION, $this->oldId )); @@ -487,10 +489,12 @@ protected function getPaymentMethod(array $originalData): ?string ); if ($paymentMethodMapping === null) { + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry(new UnknownEntityLog( $this->runId, - 'payment_method', - $originalData['payment']['id'], + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::ORDER_TRANSACTION, $this->oldId )); @@ -510,12 +514,14 @@ protected function getPaymentMethod(array $originalData): ?string */ protected function getAddress(array $originalData, string $type = self::BILLING_ADDRESS): array { + $connection = $this->migrationContext->getConnection(); $fields = $this->checkForEmptyRequiredDataFields($originalData, $this->requiredAddressDataFieldKeys); + if (!empty($fields)) { $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( $this->runId, - DefaultEntities::ORDER_ADDRESS, - $originalData['id'], + $connection->getProfileName(), + $connection->getGatewayName(), \implode(',', $fields) )); @@ -650,6 +656,8 @@ protected function applyCountryTranslation(array &$country, array $data): void */ protected function getCountryState(array $oldAddressData, string $newCountryId): array { + $connection = $this->migrationContext->getConnection(); + if (!isset($oldAddressData['stateID'])) { return []; } @@ -660,8 +668,8 @@ protected function getCountryState(array $oldAddressData, string $newCountryId): $this->loggingService->addLogEntry( new UnknownEntityLog( $this->runId, - DefaultEntities::COUNTRY_STATE, - $oldAddressData['stateID'] ?? 'unknown', + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::ORDER, $this->oldId ) @@ -698,8 +706,8 @@ protected function getCountryState(array $oldAddressData, string $newCountryId): $this->loggingService->addLogEntry( new UnknownEntityLog( $this->runId, - DefaultEntities::COUNTRY_STATE, - $oldAddressData['stateID'], + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::ORDER, $this->oldId ) @@ -776,10 +784,12 @@ protected function getDeliveries(array $data, array $converted, CalculatedPrice ); if ($deliveryStateMapping === null) { + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry(new UnknownEntityLog( $this->runId, - 'order_delivery_state', - (string) $data['status'], + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::ORDER, $this->oldId )); @@ -859,10 +869,12 @@ protected function getShippingMethod(string $shippingMethodId): ?string ); if ($shippingMethodMapping === null) { + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry(new UnknownEntityLog( $this->runId, - DefaultEntities::SHIPPING_METHOD, - $shippingMethodId, + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::ORDER, $this->oldId )); @@ -1026,10 +1038,12 @@ protected function getSalutation(string $salutation): ?string ); if ($salutationMapping === null) { + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry(new UnknownEntityLog( $this->runId, - 'salutation', - $salutation, + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::ORDER, $this->oldId )); @@ -1057,10 +1071,12 @@ private function getOrderLineItemDownload(array $originalEsdItem): ?array ); if (!\is_array($mediaMapping)) { + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry(new UnknownEntityLog( $this->runId, - 'product_download_media', - $originalEsdItem['esdID'], + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::ORDER, $this->oldId )); diff --git a/src/Profile/Shopware/Converter/OrderDocumentConverter.php b/src/Profile/Shopware/Converter/OrderDocumentConverter.php index 0d098333d..590967155 100644 --- a/src/Profile/Shopware/Converter/OrderDocumentConverter.php +++ b/src/Profile/Shopware/Converter/OrderDocumentConverter.php @@ -86,8 +86,8 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->loggingService->addLogEntry( new EmptyNecessaryFieldRunLog( $this->migrationContext->getRunUuid(), - DefaultEntities::ORDER_DOCUMENT, - $this->oldId, + $connection->getProfileName(), + $connection->getGatewayName(), 'hash' ) ); @@ -99,8 +99,8 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->loggingService->addLogEntry( new EmptyNecessaryFieldRunLog( $this->migrationContext->getRunUuid(), - DefaultEntities::ORDER_DOCUMENT, - $this->oldId, + $connection->getProfileName(), + $connection->getGatewayName(), 'documenttype' ) ); @@ -119,8 +119,8 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->loggingService->addLogEntry( new AssociationRequiredMissingLog( $this->migrationContext->getRunUuid(), - DefaultEntities::ORDER, - $this->oldId, + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::ORDER_DOCUMENT ) ); @@ -202,9 +202,12 @@ protected function getDocumentType(array $data): array return $documentType; } + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry(new DocumentTypeNotSupported( $this->runId, - $data['id'], + $connection->getProfileName(), + $connection->getGatewayName(), $mappedKey )); diff --git a/src/Profile/Shopware/Converter/ProductConverter.php b/src/Profile/Shopware/Converter/ProductConverter.php index 7181d9cac..7772f4091 100644 --- a/src/Profile/Shopware/Converter/ProductConverter.php +++ b/src/Profile/Shopware/Converter/ProductConverter.php @@ -148,8 +148,8 @@ public function convert( if (!empty($fields)) { $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( $this->runId, - DefaultEntities::PRODUCT, - $this->oldProductId, + $connection->getProfileName(), + $connection->getGatewayName(), \implode(',', $fields) )); @@ -387,10 +387,12 @@ private function getProductData(array &$data, array $converted): array $converted['price'] = $this->getPrice($data['prices'][0], $converted['tax']['taxRate']); if (empty($converted['price'])) { + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( $this->runId, - DefaultEntities::PRODUCT, - $this->oldProductId, + $connection->getProfileName(), + $connection->getGatewayName(), 'currency' )); } @@ -891,10 +893,14 @@ private function getEsdFiles(array $esdFiles, string $oldVariantId, array $conve $newMedia['id'] = $mapping['entityUuid']; $this->mappingIds[] = $mapping['id']; + + $connection = $this->migrationContext->getConnection(); + if (empty($esdFile['name'])) { $this->loggingService->addLogEntry(new CannotConvertChildEntity( $this->runId, - DefaultEntities::PRODUCT_DOWNLOAD, + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::PRODUCT, $this->oldProductId )); @@ -904,10 +910,11 @@ private function getEsdFiles(array $esdFiles, string $oldVariantId, array $conve try { $path = \unserialize($esdFile['path'], ['allowed_classes' => false]); - } catch (\Throwable $error) { + } catch (\Throwable) { $this->loggingService->addLogEntry(new CannotConvertChildEntity( $this->runId, - DefaultEntities::PRODUCT_DOWNLOAD, + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::PRODUCT, $this->oldProductId )); @@ -926,14 +933,22 @@ private function getEsdFiles(array $esdFiles, string $oldVariantId, array $conve ] ); - $esdFile['name'] = \pathinfo($esdFile['name'], \PATHINFO_FILENAME); - $this->convertValue($newMedia, 'title', $esdFile, 'name'); + $fileName = \pathinfo($esdFile['name'], \PATHINFO_FILENAME); + $sourceData = ['name' => $fileName]; + + $this->convertValue( + $newMedia, + 'title', + $sourceData, + 'name' + ); $albumId = $this->mediaFolderLookup->get(ProductDownloadDefinition::ENTITY_NAME, $this->context); if ($albumId === null) { $this->loggingService->addLogEntry(new CannotConvertChildEntity( $this->runId, - DefaultEntities::PRODUCT_DOWNLOAD, + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::PRODUCT, $this->oldProductId )); @@ -965,9 +980,12 @@ private function getMedia(array $media, string $oldVariantId, array $converted): $mediaObjects = []; foreach ($media as $mediaData) { if (!isset($mediaData['media']['id'])) { + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry(new CannotConvertChildEntity( $this->runId, - DefaultEntities::PRODUCT_MEDIA, + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::PRODUCT, $this->oldProductId )); @@ -1355,10 +1373,12 @@ private function getPrices(array $priceData, array $converted): array $priceArray = $this->getPrice($price, $converted['tax']['taxRate']); if (empty($priceArray)) { + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( $this->runId, - DefaultEntities::PRODUCT_PRICE, - $this->oldProductId, + $connection->getProfileName(), + $connection->getGatewayName(), 'currencyId' )); diff --git a/src/Profile/Shopware/Converter/ProductReviewConverter.php b/src/Profile/Shopware/Converter/ProductReviewConverter.php index ced4cac7c..2d794306e 100644 --- a/src/Profile/Shopware/Converter/ProductReviewConverter.php +++ b/src/Profile/Shopware/Converter/ProductReviewConverter.php @@ -41,11 +41,14 @@ public function convert(array $data, Context $context, MigrationContextInterface { $fields = $this->checkForEmptyRequiredDataFields($data, $this->requiredDataFieldKeys); + $connection = $migrationContext->getConnection(); + $connectionId = $connection->getId(); + if (!empty($fields)) { $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( $migrationContext->getRunUuid(), - DefaultEntities::PRODUCT_REVIEW, - $data['id'], + $connection->getProfileName(), + $connection->getGatewayName(), \implode(',', $fields) )); @@ -56,12 +59,6 @@ public function convert(array $data, Context $context, MigrationContextInterface $mainLocale = $data['_locale']; unset($data['_locale']); - $connection = $migrationContext->getConnection(); - $connectionId = ''; - if ($connection !== null) { - $connectionId = $connection->getId(); - } - $converted = []; $this->mainMapping = $this->mappingService->getOrCreateMapping( $connectionId, @@ -89,11 +86,13 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($mapping === null) { + $connection = $migrationContext->getConnection(); + $this->loggingService->addLogEntry( new AssociationRequiredMissingLog( $migrationContext->getRunUuid(), - DefaultEntities::PRODUCT, - $data['articleID'], + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::PRODUCT_REVIEW ) ); @@ -133,8 +132,8 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->loggingService->addLogEntry( new AssociationRequiredMissingLog( $migrationContext->getRunUuid(), - DefaultEntities::SALES_CHANNEL, - $shopId, + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::PRODUCT_REVIEW ) ); @@ -150,8 +149,8 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->loggingService->addLogEntry( new AssociationRequiredMissingLog( $migrationContext->getRunUuid(), - DefaultEntities::LANGUAGE, - $mainLocale, + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::PRODUCT_REVIEW ) ); diff --git a/src/Profile/Shopware/Converter/PromotionConverter.php b/src/Profile/Shopware/Converter/PromotionConverter.php index e96286b0f..321ae4310 100644 --- a/src/Profile/Shopware/Converter/PromotionConverter.php +++ b/src/Profile/Shopware/Converter/PromotionConverter.php @@ -15,6 +15,7 @@ use Shopware\Core\Framework\Rule\Container\AndRule; use Shopware\Core\Framework\Rule\Container\OrRule; use Shopware\Core\System\SalesChannel\SalesChannelCollection; +use SwagMigrationAssistant\Migration\Connection\SwagMigrationConnectionEntity; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; use SwagMigrationAssistant\Migration\Logging\Log\AssociationRequiredMissingLog; @@ -86,12 +87,12 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->setIndividualCodes($data, $converted); } - $this->setSalesChannel($data, $converted); - $this->setProductNumbers($data); + $this->setSalesChannel($data, $converted, $migrationContext); + $this->setProductNumbers($data, $connection); $this->setDiscount($data, $converted); $this->setShippingDiscount($data, $converted); - $this->setCartRule($data, $converted); - $this->setCustomerRule($data, $converted); + $this->setCartRule($data, $converted, $migrationContext); + $this->setCustomerRule($data, $converted, $migrationContext); $this->convertValue($converted, 'name', $data, 'description'); $this->convertValue($converted, 'validFrom', $data, 'valid_from', self::TYPE_DATETIME); @@ -350,7 +351,7 @@ private function getDiscountRule(array $data): ?array /** * @param array $data */ - private function setProductNumbers(array &$data): void + private function setProductNumbers(array &$data, SwagMigrationConnectionEntity $connection): void { if (!isset($data['restrictarticles'])) { return; @@ -372,8 +373,8 @@ private function setProductNumbers(array &$data): void $this->loggingService->addLogEntry( new AssociationRequiredMissingLog( $this->runId, - DefaultEntities::PRODUCT, - $productNumber, + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::PROMOTION ) ); @@ -392,7 +393,7 @@ private function setProductNumbers(array &$data): void * @param array $data * @param array $converted */ - private function setCartRule(array &$data, array &$converted): void + private function setCartRule(array &$data, array &$converted, MigrationContextInterface $migrationContext): void { if (empty($this->productUuids) && !isset($data['bindtosupplier']) && !isset($data['minimumcharge'])) { return; @@ -504,11 +505,13 @@ private function setCartRule(array &$data, array &$converted): void unset($data['bindtosupplier']); $oneRuleAdded = true; } else { + $connection = $migrationContext->getConnection(); + $this->loggingService->addLogEntry( new AssociationRequiredMissingLog( $this->runId, - DefaultEntities::PRODUCT_MANUFACTURER, - $data['bindtosupplier'], + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::PROMOTION_DISCOUNT ) ); @@ -548,7 +551,7 @@ private function setCartRule(array &$data, array &$converted): void * @param array $data * @param array $converted */ - private function setSalesChannel(array &$data, array &$converted): void + private function setSalesChannel(array &$data, array &$converted, MigrationContextInterface $migrationContext): void { if (isset($data['subshopID'])) { $salesChannelMapping = $this->mappingService->getMapping( @@ -559,11 +562,13 @@ private function setSalesChannel(array &$data, array &$converted): void ); if ($salesChannelMapping === null) { + $connection = $migrationContext->getConnection(); + $this->loggingService->addLogEntry( new AssociationRequiredMissingLog( $this->runId, - DefaultEntities::SALES_CHANNEL, - $data['subshopID'], + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::PROMOTION ) ); @@ -617,7 +622,7 @@ private function setSalesChannel(array &$data, array &$converted): void * @param array $data * @param array $converted */ - private function setCustomerRule(array &$data, array &$converted): void + private function setCustomerRule(array &$data, array &$converted, MigrationContextInterface $migrationContext): void { if (!isset($data['customergroup'])) { return; @@ -631,10 +636,12 @@ private function setCustomerRule(array &$data, array &$converted): void ); if ($customerGroupMapping === null) { + $connection = $migrationContext->getConnection(); + $this->loggingService->addLogEntry(new AssociationRequiredMissingLog( $this->runId, - DefaultEntities::CUSTOMER_GROUP, - $data['customergroup'], + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::PROMOTION )); diff --git a/src/Profile/Shopware/Converter/PropertyGroupOptionConverter.php b/src/Profile/Shopware/Converter/PropertyGroupOptionConverter.php index 4b07125d6..069f464ca 100644 --- a/src/Profile/Shopware/Converter/PropertyGroupOptionConverter.php +++ b/src/Profile/Shopware/Converter/PropertyGroupOptionConverter.php @@ -80,8 +80,8 @@ public function convert(array $data, Context $context, MigrationContextInterface if (!isset($data['group']['name'])) { $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( $this->runId, - DefaultEntities::PROPERTY_GROUP_OPTION, - $data['id'], + $connection->getProfileName(), + $connection->getGatewayName(), 'group' )); @@ -132,9 +132,12 @@ public function convert(array $data, Context $context, MigrationContextInterface protected function setMedia(array &$converted, array $data): void { if (!isset($data['media']['id'])) { + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry(new CannotConvertChildEntity( $this->runId, - 'property_group_option_media', + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::PROPERTY_GROUP_OPTION, $data['id'] )); diff --git a/src/Profile/Shopware/Converter/SalesChannelConverter.php b/src/Profile/Shopware/Converter/SalesChannelConverter.php index 6494fa260..3707dbc9d 100644 --- a/src/Profile/Shopware/Converter/SalesChannelConverter.php +++ b/src/Profile/Shopware/Converter/SalesChannelConverter.php @@ -28,7 +28,6 @@ use SwagMigrationAssistant\Migration\Mapping\Lookup\LanguageLookup; use SwagMigrationAssistant\Migration\Mapping\MappingServiceInterface; use SwagMigrationAssistant\Migration\MigrationContextInterface; -use SwagMigrationAssistant\Profile\Shopware\DataSelection\DataSet\SalesChannelDataSet; use SwagMigrationAssistant\Profile\Shopware\Logging\Log\DeactivatedPackLanguageLog; use SwagMigrationAssistant\Profile\Shopware\Premapping\PaymentMethodReader; @@ -102,8 +101,8 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->loggingService->addLogEntry( new AssociationRequiredMissingLog( $migrationContext->getRunUuid(), - DefaultEntities::CUSTOMER_GROUP, - $data['customer_group_id'], + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::SALES_CHANNEL ) ); @@ -119,8 +118,8 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->loggingService->addLogEntry( new AssociationRequiredMissingLog( $migrationContext->getRunUuid(), - DefaultEntities::LANGUAGE, - $data['locale'], + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::SALES_CHANNEL ) ); @@ -143,8 +142,8 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->loggingService->addLogEntry( new AssociationRequiredMissingLog( $migrationContext->getRunUuid(), - DefaultEntities::CURRENCY, - $data['currency'], + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::SALES_CHANNEL ) ); @@ -170,8 +169,8 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->loggingService->addLogEntry( new AssociationRequiredMissingLog( $migrationContext->getRunUuid(), - DefaultEntities::CATEGORY, - $data['category_id'], + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::SALES_CHANNEL ) ); @@ -391,8 +390,15 @@ protected function filterDisabledPackLanguages(array &$converted): void $converted['languageId'] = Defaults::LANGUAGE_SYSTEM; } + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry( - new DeactivatedPackLanguageLog($this->migrationContext->getRunUuid(), SalesChannelDataSet::getEntity(), $this->oldIdentifier, $packLanguageId) + new DeactivatedPackLanguageLog( + $this->migrationContext->getRunUuid(), + $connection->getProfileName(), + $connection->getGatewayName(), + $packLanguageId, + ) ); } } diff --git a/src/Profile/Shopware/Converter/SeoUrlConverter.php b/src/Profile/Shopware/Converter/SeoUrlConverter.php index 175e84d51..9552887d1 100644 --- a/src/Profile/Shopware/Converter/SeoUrlConverter.php +++ b/src/Profile/Shopware/Converter/SeoUrlConverter.php @@ -70,8 +70,8 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->loggingService->addLogEntry( new AssociationRequiredMissingLog( $migrationContext->getRunUuid(), - DefaultEntities::SALES_CHANNEL, - $data['subshopID'], + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::SEO_URL ) ); @@ -87,8 +87,8 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->loggingService->addLogEntry( new AssociationRequiredMissingLog( $migrationContext->getRunUuid(), - DefaultEntities::LANGUAGE, - $data['_locale'], + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::SEO_URL ) ); @@ -118,8 +118,8 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->loggingService->addLogEntry( new AssociationRequiredMissingLog( $migrationContext->getRunUuid(), - DefaultEntities::PRODUCT, - $data['typeId'], + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::SEO_URL ) ); @@ -144,8 +144,8 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->loggingService->addLogEntry( new AssociationRequiredMissingLog( $migrationContext->getRunUuid(), - DefaultEntities::CATEGORY, - $data['typeId'], + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::SEO_URL ) ); @@ -160,8 +160,8 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->loggingService->addLogEntry( new UnsupportedSeoUrlType( $migrationContext->getRunUuid(), - $data['type'], - DefaultEntities::SEO_URL, + $connection->getProfileName(), + $connection->getGatewayName(), $originalData['id'] ) ); diff --git a/src/Profile/Shopware/Converter/ShippingMethodConverter.php b/src/Profile/Shopware/Converter/ShippingMethodConverter.php index 12954c92a..95ceaa3c7 100644 --- a/src/Profile/Shopware/Converter/ShippingMethodConverter.php +++ b/src/Profile/Shopware/Converter/ShippingMethodConverter.php @@ -88,11 +88,17 @@ public function __construct( public function convert(array $data, Context $context, MigrationContextInterface $migrationContext): ConvertStruct { + $connection = $migrationContext->getConnection(); + $this->connectionId = ''; + if ($connection !== null) { + $this->connectionId = $connection->getId(); + } + if (empty($data['id'])) { $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( $this->runId, - DefaultEntities::SHIPPING_METHOD, - '', + $connection->getProfileName(), + $connection->getGatewayName(), 'id', )); @@ -105,12 +111,6 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->oldShippingMethod = $data['id']; $this->mainLocale = $data['_locale']; - $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } - $converted = []; $this->mainMapping = $this->mappingService->getOrCreateMapping( $this->connectionId, @@ -150,8 +150,8 @@ public function convert(array $data, Context $context, MigrationContextInterface foreach ($fields as $field) { $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( $this->runId, - DefaultEntities::SHIPPING_METHOD, - $this->oldShippingMethod, + $connection->getProfileName(), + $connection->getGatewayName(), $field )); } @@ -186,13 +186,13 @@ public function convert(array $data, Context $context, MigrationContextInterface ) { $this->loggingService->addLogEntry(new UnsupportedShippingCalculationType( $this->runId, - DefaultEntities::SHIPPING_METHOD, - $this->oldShippingMethod, + $connection->getProfileName(), + $connection->getGatewayName(), $data['calculation'] )); } else { $calculationType = self::CALCULATION_TYPE_MAPPING[$data['calculation']]; - $converted['prices'] = $this->getShippingCosts($data, $calculationType, $priceRule); + $converted['prices'] = $this->getShippingCosts($migrationContext, $data, $calculationType, $priceRule); } } @@ -243,8 +243,8 @@ public function convert(array $data, Context $context, MigrationContextInterface if (!\is_array($this->mainMapping) || !\array_key_exists('id', $this->mainMapping)) { $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( $this->runId, - DefaultEntities::SHIPPING_METHOD, - $this->oldShippingMethod, + $connection->getProfileName(), + $connection->getGatewayName(), 'id', )); @@ -633,8 +633,10 @@ protected function getSalesChannelAndCustomerGroupCalculationRule(array $data): * * @return list> */ - protected function getShippingCosts(array $data, int $calculationType, ?array $rule): array + protected function getShippingCosts(MigrationContextInterface $migrationContext, array $data, int $calculationType, ?array $rule): array { + $connection = $migrationContext->getConnection(); + $shippingCosts = $data['shippingCosts']; $taxRate = 0.0; if (isset($data['tax']['tax'])) { @@ -646,8 +648,8 @@ protected function getShippingCosts(array $data, int $calculationType, ?array $r if (empty($shippingCost['id'])) { $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( $this->runId, - DefaultEntities::SHIPPING_METHOD_PRICE, - $this->oldShippingMethod, + $connection->getProfileName(), + $connection->getGatewayName(), 'id' )); @@ -681,8 +683,8 @@ protected function getShippingCosts(array $data, int $calculationType, ?array $r if (!isset($currencyMapping)) { $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( $this->runId, - DefaultEntities::SHIPPING_METHOD_PRICE, - $shippingCost['id'], + $connection->getProfileName(), + $connection->getGatewayName(), 'currency' )); @@ -698,8 +700,8 @@ protected function getShippingCosts(array $data, int $calculationType, ?array $r if (isset($shippingCost['factor']) && $shippingCost['factor'] > 0) { $this->loggingService->addLogEntry(new UnsupportedShippingPriceLog( $this->runId, - DefaultEntities::SHIPPING_METHOD_PRICE, - $shippingCost['id'], + $connection->getProfileName(), + $connection->getGatewayName(), $this->oldShippingMethod )); diff --git a/src/Profile/Shopware/Converter/TranslationConverter.php b/src/Profile/Shopware/Converter/TranslationConverter.php index c0e99804a..59f43c53b 100644 --- a/src/Profile/Shopware/Converter/TranslationConverter.php +++ b/src/Profile/Shopware/Converter/TranslationConverter.php @@ -64,8 +64,8 @@ public function convert( if (!isset($data['locale'])) { $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( $this->runId, - DefaultEntities::TRANSLATION, - $data['id'], + $connection->getProfileName(), + $connection->getGatewayName(), 'locale' )); @@ -99,8 +99,8 @@ public function convert( $this->loggingService->addLogEntry( new UnsupportedTranslationType( $migrationContext->getRunUuid(), - $data['objecttype'], - DefaultEntities::TRANSLATION, + $connection->getProfileName(), + $connection->getGatewayName(), $data['id'] ) ); @@ -132,11 +132,13 @@ protected function createProductTranslation(array &$data): ConvertStruct } if ($mapping === null) { + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry( new AssociationRequiredMissingLog( $this->runId, - DefaultEntities::PRODUCT, - $data['id'], + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::TRANSLATION ) ); @@ -243,11 +245,13 @@ protected function createProductVariantTranslation(array &$data): ConvertStruct unset($data['ordernumber']); if ($mapping === null) { + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry( new AssociationRequiredMissingLog( $this->runId, - DefaultEntities::PRODUCT, - $data['id'], + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::TRANSLATION ) ); @@ -319,11 +323,13 @@ protected function createManufacturerProductTranslation(array $data): ConvertStr ); if ($mapping === null) { + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry( new AssociationRequiredMissingLog( $this->runId, - DefaultEntities::PRODUCT_MANUFACTURER, - $data['id'], + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::TRANSLATION ) ); @@ -401,11 +407,13 @@ protected function createUnitTranslation(array $data): ConvertStruct ); if ($mapping === null) { + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry( new AssociationRequiredMissingLog( $this->runId, - DefaultEntities::UNIT, - $data['id'], + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::TRANSLATION ) ); @@ -488,11 +496,13 @@ protected function createCategoryTranslation(array $data): ConvertStruct ); if ($mapping === null) { + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry( new AssociationRequiredMissingLog( $this->runId, - DefaultEntities::CATEGORY, - $data['id'], + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::TRANSLATION ) ); @@ -585,11 +595,13 @@ protected function createConfiguratorOptionTranslation(array $data): ConvertStru ); if ($mapping === null) { + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry( new AssociationRequiredMissingLog( $this->runId, - DefaultEntities::PROPERTY_GROUP_OPTION, - $data['id'], + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::TRANSLATION ) ); @@ -664,11 +676,13 @@ protected function createConfiguratorOptionGroupTranslation(array $data): Conver ); if ($mapping === null) { + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry( new AssociationRequiredMissingLog( $this->runId, - DefaultEntities::PROPERTY_GROUP, - $data['id'], + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::TRANSLATION ) ); @@ -746,11 +760,13 @@ protected function createPropertyValueTranslation(array $data): ConvertStruct ); if ($mapping === null) { + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry( new AssociationRequiredMissingLog( $this->runId, - DefaultEntities::PROPERTY_GROUP_OPTION, - $data['id'], + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::TRANSLATION ) ); @@ -823,11 +839,13 @@ protected function createPropertyOptionTranslation(array $data): ConvertStruct ); if ($mapping === null) { + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry( new AssociationRequiredMissingLog( $this->runId, - DefaultEntities::PROPERTY_GROUP, - $data['id'], + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::TRANSLATION ) ); @@ -955,11 +973,13 @@ protected function unserializeTranslation(array $data, string $entity): ?array } if (!\is_array($objectData)) { + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry( new InvalidUnserializedData( $this->runId, - DefaultEntities::TRANSLATION, - $data['id'], + $connection->getProfileName(), + $connection->getGatewayName(), $entity, $objectDataSerialized ) @@ -990,11 +1010,13 @@ protected function createProductMediaTranslation(array $data): ConvertStruct ); if ($mapping === null) { + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry( new AssociationRequiredMissingLog( $this->runId, - DefaultEntities::MEDIA, - $data['mediaId'], + $connection->getProfileName(), + $connection->getGatewayName(), DefaultEntities::TRANSLATION ) ); diff --git a/src/Profile/Shopware/Gateway/Api/Reader/TableCountReader.php b/src/Profile/Shopware/Gateway/Api/Reader/TableCountReader.php index 91af0c900..550f9c3ac 100644 --- a/src/Profile/Shopware/Gateway/Api/Reader/TableCountReader.php +++ b/src/Profile/Shopware/Gateway/Api/Reader/TableCountReader.php @@ -67,10 +67,13 @@ private function prepareTotals(array $result): array private function logExceptions(array $exceptionArray, MigrationContextInterface $migrationContext, Context $context): void { + $connection = $migrationContext->getConnection(); + foreach ($exceptionArray as $exception) { $this->loggingService->addLogEntry(new CannotReadEntityCountLog( $migrationContext->getRunUuid(), - $exception['entity'], + $connection->getProfileName(), + $connection->getGatewayName(), $exception['table'], $exception['condition'], $exception['code'], diff --git a/src/Profile/Shopware/Gateway/Local/Reader/AttributeReader.php b/src/Profile/Shopware/Gateway/Local/Reader/AttributeReader.php index 641f91e5a..a735bf18a 100644 --- a/src/Profile/Shopware/Gateway/Local/Reader/AttributeReader.php +++ b/src/Profile/Shopware/Gateway/Local/Reader/AttributeReader.php @@ -188,7 +188,7 @@ private function cleanupColumns(array $columns, array $foreignKeys): array $fks = []; foreach ($foreignKeys as $foreignKey) { - $fks[] = $foreignKey->getLocalColumns(); + $fks[] = $foreignKey->getReferencingColumnNames(); } if ($fks !== []) { diff --git a/src/Profile/Shopware/Logging/Log/DeactivatedPackLanguageLog.php b/src/Profile/Shopware/Logging/Log/DeactivatedPackLanguageLog.php index 956552f0e..f416ad2eb 100644 --- a/src/Profile/Shopware/Logging/Log/DeactivatedPackLanguageLog.php +++ b/src/Profile/Shopware/Logging/Log/DeactivatedPackLanguageLog.php @@ -15,11 +15,21 @@ class DeactivatedPackLanguageLog extends BaseRunLogEntry { public function __construct( string $runId, - string $entity, - string $sourceId, + string $profileName, + string $gatewayName, + /** @phpstan-ignore property.onlyWritten */ private readonly string $languageId, ) { - parent::__construct($runId, $entity, $sourceId); + parent::__construct( + $runId, + $profileName, + $gatewayName, + ); + } + + public function isUserFixable(): bool + { + return false; } public function getLevel(): string @@ -31,33 +41,4 @@ public function getCode(): string { return 'SWAG_MIGRATION__DEACTIVATED_PACK_LANGUAGE'; } - - public function getTitle(): string - { - return 'Deactivated pack language'; - } - - /** - * @return array{entity: ?string, sourceId: ?string, packLanguage: string} - */ - public function getParameters(): array - { - return [ - 'entity' => $this->getEntity(), - 'sourceId' => $this->getSourceId(), - 'packLanguage' => $this->languageId, - ]; - } - - public function getDescription(): string - { - $args = $this->getParameters(); - - return \sprintf( - 'Language for %s with source id "%s" has been set to default language. The language with id "%s" is not activated for sales channels by "Language pack" plugin.', - $args['entity'], - $args['sourceId'], - $args['packLanguage'] - ); - } } diff --git a/src/Profile/Shopware/Logging/Log/InvalidEmailAddressLog.php b/src/Profile/Shopware/Logging/Log/InvalidEmailAddressLog.php index 23be78316..d97c58344 100644 --- a/src/Profile/Shopware/Logging/Log/InvalidEmailAddressLog.php +++ b/src/Profile/Shopware/Logging/Log/InvalidEmailAddressLog.php @@ -15,11 +15,21 @@ class InvalidEmailAddressLog extends BaseRunLogEntry { public function __construct( string $runId, - string $entity, - string $sourceId, + string $profileName, + string $gatewayName, + /** @phpstan-ignore property.onlyWritten */ private readonly string $email, ) { - parent::__construct($runId, $entity, $sourceId); + parent::__construct( + $runId, + $profileName, + $gatewayName, + ); + } + + public function isUserFixable(): bool + { + return false; } public function getLevel(): string @@ -31,33 +41,4 @@ public function getCode(): string { return 'SWAG_MIGRATION__INVALID_EMAIL_ADDRESS'; } - - public function getTitle(): string - { - return 'Invalid Email address'; - } - - /** - * @return array{entity: ?string, sourceId: ?string, email: string} - */ - public function getParameters(): array - { - return [ - 'entity' => $this->getEntity(), - 'sourceId' => $this->getSourceId(), - 'email' => $this->email, - ]; - } - - public function getDescription(): string - { - $args = $this->getParameters(); - - return \sprintf( - '%s with source id "%s" could not be converted because of invalid email address: %s.', - $args['entity'], - $args['sourceId'], - $args['email'] - ); - } } diff --git a/src/Profile/Shopware/Logging/Log/UnsupportedMailTemplateType.php b/src/Profile/Shopware/Logging/Log/UnsupportedMailTemplateType.php index 97db7f0e1..b5346a9a1 100644 --- a/src/Profile/Shopware/Logging/Log/UnsupportedMailTemplateType.php +++ b/src/Profile/Shopware/Logging/Log/UnsupportedMailTemplateType.php @@ -15,10 +15,21 @@ class UnsupportedMailTemplateType extends BaseRunLogEntry { public function __construct( string $runId, - string $sourceId, + string $profileName, + string $gatewayName, + /** @phpstan-ignore property.onlyWritten */ private readonly string $type, ) { - parent::__construct($runId, null, $sourceId); + parent::__construct( + $runId, + $profileName, + $gatewayName, + ); + } + + public function isUserFixable(): bool + { + return false; } public function getLevel(): string @@ -30,31 +41,4 @@ public function getCode(): string { return 'SWAG_MIGRATION__SHOPWARE_UNSUPPORTED_MAIL_TEMPLATE_TYPE'; } - - public function getTitle(): string - { - return 'Unsupported mail type'; - } - - /** - * @return array{sourceId: ?string, type: string} - */ - public function getParameters(): array - { - return [ - 'sourceId' => $this->getSourceId(), - 'type' => $this->type, - ]; - } - - public function getDescription(): string - { - $args = $this->getParameters(); - - return \sprintf( - 'MailTemplate-Entity with source id "%s" could not be converted because of unsupported type: %s.', - $args['sourceId'], - $args['type'] - ); - } } diff --git a/src/Profile/Shopware/Logging/Log/UnsupportedNumberRangeTypeLog.php b/src/Profile/Shopware/Logging/Log/UnsupportedNumberRangeTypeLog.php index 7f27e57ee..35ec60b72 100644 --- a/src/Profile/Shopware/Logging/Log/UnsupportedNumberRangeTypeLog.php +++ b/src/Profile/Shopware/Logging/Log/UnsupportedNumberRangeTypeLog.php @@ -15,11 +15,21 @@ class UnsupportedNumberRangeTypeLog extends BaseRunLogEntry { public function __construct( string $runId, - string $entity, - string $sourceId, + string $profileName, + string $gatewayName, + /** @phpstan-ignore property.onlyWritten */ private readonly string $type, ) { - parent::__construct($runId, $entity, $sourceId); + parent::__construct( + $runId, + $profileName, + $gatewayName, + ); + } + + public function isUserFixable(): bool + { + return false; } public function getLevel(): string @@ -31,32 +41,4 @@ public function getCode(): string { return 'SWAG_MIGRATION__SHOPWARE_UNSUPPORTED_NUMBER_RANGE_TYPE'; } - - public function getTitle(): string - { - return 'Unsupported number range type'; - } - - /** - * @return array{entity: ?string, sourceId: ?string, type: string} - */ - public function getParameters(): array - { - return [ - 'entity' => $this->getEntity(), - 'sourceId' => $this->getSourceId(), - 'type' => $this->type, - ]; - } - - public function getDescription(): string - { - $args = $this->getParameters(); - - return \sprintf( - 'NumberRange-Entity with source id "%s" could not be converted because of unsupported type: %s.', - $args['sourceId'], - $args['type'] - ); - } } diff --git a/src/Profile/Shopware/Logging/Log/UnsupportedShippingCalculationType.php b/src/Profile/Shopware/Logging/Log/UnsupportedShippingCalculationType.php index 8eaf9fc06..184d1784e 100644 --- a/src/Profile/Shopware/Logging/Log/UnsupportedShippingCalculationType.php +++ b/src/Profile/Shopware/Logging/Log/UnsupportedShippingCalculationType.php @@ -15,11 +15,21 @@ class UnsupportedShippingCalculationType extends BaseRunLogEntry { public function __construct( string $runId, - string $entity, - string $sourceId, + string $profileName, + string $gatewayName, + /** @phpstan-ignore property.onlyWritten */ private readonly string $type, ) { - parent::__construct($runId, $entity, $sourceId); + parent::__construct( + $runId, + $profileName, + $gatewayName, + ); + } + + public function isUserFixable(): bool + { + return false; } public function getLevel(): string @@ -31,32 +41,4 @@ public function getCode(): string { return 'SWAG_MIGRATION__SHOPWARE_UNSUPPORTED_SHIPPING_CALCULATION_TYPE'; } - - public function getTitle(): string - { - return 'Unsupported shipping calculation type'; - } - - /** - * @return array{entity: ?string, sourceId: ?string, type: string} - */ - public function getParameters(): array - { - return [ - 'entity' => $this->getEntity(), - 'sourceId' => $this->getSourceId(), - 'type' => $this->type, - ]; - } - - public function getDescription(): string - { - $args = $this->getParameters(); - - return \sprintf( - 'ShippingMethod-Entity with source id "%s" could not be converted because of unsupported calculation type "%s".', - $args['sourceId'], - $args['type'] - ); - } } diff --git a/src/Profile/Shopware/Logging/Log/UnsupportedShippingPriceLog.php b/src/Profile/Shopware/Logging/Log/UnsupportedShippingPriceLog.php index 20ef6a029..5b4a6dd5c 100644 --- a/src/Profile/Shopware/Logging/Log/UnsupportedShippingPriceLog.php +++ b/src/Profile/Shopware/Logging/Log/UnsupportedShippingPriceLog.php @@ -15,11 +15,21 @@ class UnsupportedShippingPriceLog extends BaseRunLogEntry { public function __construct( string $runId, - string $entity, - string $sourceId, + string $profileName, + string $gatewayName, + /** @phpstan-ignore property.onlyWritten */ private readonly string $shippingMethodId, ) { - parent::__construct($runId, $entity, $sourceId); + parent::__construct( + $runId, + $profileName, + $gatewayName, + ); + } + + public function isUserFixable(): bool + { + return false; } public function getLevel(): string @@ -31,32 +41,4 @@ public function getCode(): string { return 'SWAG_MIGRATION__SHOPWARE_UNSUPPORTED_SHIPPING_PRICE'; } - - public function getTitle(): string - { - return 'Unsupported shipping factor price calculation'; - } - - /** - * @return array{entity: ?string, sourceId: ?string, shippingMethodId: string} - */ - public function getParameters(): array - { - return [ - 'entity' => $this->getEntity(), - 'sourceId' => $this->getSourceId(), - 'shippingMethodId' => $this->shippingMethodId, - ]; - } - - public function getDescription(): string - { - $args = $this->getParameters(); - - return \sprintf( - 'ShippingPrice-Entity with source id "%s" of shipping method "%s" could not be converted because of unsupported factor price calculation.', - $args['sourceId'], - $args['shippingMethodId'] - ); - } } diff --git a/src/Profile/Shopware/Media/LocalMediaProcessor.php b/src/Profile/Shopware/Media/LocalMediaProcessor.php index f4f103a4a..22dc1520c 100644 --- a/src/Profile/Shopware/Media/LocalMediaProcessor.php +++ b/src/Profile/Shopware/Media/LocalMediaProcessor.php @@ -15,7 +15,6 @@ use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\Log\Package; use Shopware\Core\Framework\Uuid\Uuid; -use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; use SwagMigrationAssistant\Migration\Logging\Log\CannotGetFileRunLog; use SwagMigrationAssistant\Migration\Logging\Log\ExceptionRunLog; use SwagMigrationAssistant\Migration\Logging\Log\MimeTypeErrorLog; @@ -117,6 +116,8 @@ private function copyMediaFiles( MigrationContextInterface $migrationContext, Context $context, ): array { + $connection = $migrationContext->getConnection(); + $processedMedia = []; $failedMedia = []; @@ -124,15 +125,15 @@ private function copyMediaFiles( $mediaId = $mediaFile['media_id']; $sourcePath = $mappedWorkload[$mediaId]->getAdditionalData()['path']; - if (!\file_exists($sourcePath)) { + if (!\is_file($sourcePath)) { $resolver = $this->getResolver($mediaFile, $migrationContext); if ($resolver === null) { $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); $this->loggingService->addLogEntry(new CannotGetFileRunLog( $mappedWorkload[$mediaId]->getRunId(), - DefaultEntities::MEDIA, - $mediaId, + $connection->getProfileName(), + $connection->getGatewayName(), $sourcePath )); $processedMedia[] = $mediaId; @@ -149,8 +150,8 @@ private function copyMediaFiles( $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); $this->loggingService->addLogEntry(new TemporaryFileErrorLog( $mappedWorkload[$mediaId]->getRunId(), - DefaultEntities::MEDIA, - $mediaId, + $connection->getProfileName(), + $connection->getGatewayName(), )); continue; @@ -162,6 +163,7 @@ private function copyMediaFiles( try { $this->persistFileToMedia( + $migrationContext, $filePath, $mediaFile, $fileSize, @@ -177,9 +179,9 @@ private function copyMediaFiles( $failedMedia[] = $mediaId; $this->loggingService->addLogEntry(new ExceptionRunLog( $mappedWorkload[$mediaId]->getRunId(), - DefaultEntities::MEDIA, + $connection->getProfileName(), + $connection->getGatewayName(), $e, - $mediaId )); } \unlink($filePath); @@ -187,8 +189,8 @@ private function copyMediaFiles( $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); $this->loggingService->addLogEntry(new CannotGetFileRunLog( $mappedWorkload[$mediaId]->getRunId(), - DefaultEntities::MEDIA, - $mediaId, + $connection->getProfileName(), + $connection->getGatewayName(), $sourcePath )); $failedMedia[] = $mediaId; @@ -207,6 +209,7 @@ private function copyMediaFiles( * @param list $failedMedia */ private function persistFileToMedia( + MigrationContextInterface $migrationContext, string $filePath, array $media, int $fileSize, @@ -217,13 +220,17 @@ private function persistFileToMedia( ): void { $mediaId = $media['media_id']; $mimeType = \mime_content_type($filePath); + if ($mimeType === false) { + $connection = $migrationContext->getConnection(); + $failedMedia[] = $mediaId; $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); + $this->loggingService->addLogEntry(new MimeTypeErrorLog( $mappedWorkload[$mediaId]->getRunId(), - DefaultEntities::MEDIA, - $mediaId + $connection->getProfileName(), + $connection->getGatewayName(), )); return; diff --git a/src/Profile/Shopware/Media/LocalOrderDocumentProcessor.php b/src/Profile/Shopware/Media/LocalOrderDocumentProcessor.php index e9dfd9cd2..d4140c5df 100644 --- a/src/Profile/Shopware/Media/LocalOrderDocumentProcessor.php +++ b/src/Profile/Shopware/Media/LocalOrderDocumentProcessor.php @@ -14,7 +14,6 @@ use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\Log\Package; use Shopware\Core\Framework\Uuid\Uuid; -use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; use SwagMigrationAssistant\Migration\Logging\Log\CannotGetFileRunLog; use SwagMigrationAssistant\Migration\Logging\Log\ExceptionRunLog; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; @@ -91,6 +90,8 @@ private function copyMediaFiles( MigrationContextInterface $migrationContext, Context $context, ): array { + $connection = $migrationContext->getConnection(); + $installationRoot = $this->getInstallationRoot($migrationContext); $processedMedia = []; $failedMedia = []; @@ -99,12 +100,12 @@ private function copyMediaFiles( $sourcePath = $installationRoot . '/files/documents/' . $mediaFile['file_name'] . '.pdf'; $mediaId = $mediaFile['media_id']; - if (!\file_exists($sourcePath)) { + if (!\is_file($sourcePath)) { $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); $this->loggingService->addLogEntry(new CannotGetFileRunLog( $mappedWorkload[$mediaId]->getRunId(), - DefaultEntities::ORDER_DOCUMENT, - $mediaId, + $connection->getProfileName(), + $connection->getGatewayName(), $sourcePath )); $processedMedia[] = $mediaId; @@ -126,9 +127,9 @@ private function copyMediaFiles( $this->loggingService->addLogEntry(new ExceptionRunLog( $mappedWorkload[$mediaId]->getRunId(), - DefaultEntities::ORDER_DOCUMENT, + $connection->getProfileName(), + $connection->getGatewayName(), $e, - $mediaId )); } } diff --git a/src/Profile/Shopware/Media/LocalProductDownloadProcessor.php b/src/Profile/Shopware/Media/LocalProductDownloadProcessor.php index 7b590f7a1..65c4a3a86 100644 --- a/src/Profile/Shopware/Media/LocalProductDownloadProcessor.php +++ b/src/Profile/Shopware/Media/LocalProductDownloadProcessor.php @@ -15,7 +15,6 @@ use Shopware\Core\Framework\Log\Package; use Shopware\Core\Framework\Uuid\Uuid; use SwagMigrationAssistant\Exception\MigrationException; -use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; use SwagMigrationAssistant\Migration\Logging\Log\CannotGetFileRunLog; use SwagMigrationAssistant\Migration\Logging\Log\ExceptionRunLog; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; @@ -96,6 +95,8 @@ private function copyMediaFiles( MigrationContextInterface $migrationContext, Context $context, ): array { + $connection = $migrationContext->getConnection(); + $installationRoot = $this->getInstallationRoot($migrationContext); $processedMedia = []; $failedMedia = []; @@ -104,13 +105,13 @@ private function copyMediaFiles( $sourcePath = $installationRoot . '/files/' . $mediaFile['uri']; $mediaId = $mediaFile['media_id']; - if (!\file_exists($sourcePath)) { + if (!\is_file($sourcePath)) { $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); $this->loggingService->addLogEntry(new CannotGetFileRunLog( $mappedWorkload[$mediaId]->getRunId(), - DefaultEntities::PRODUCT_DOWNLOAD, - $mediaId, - $sourcePath + $connection->getProfileName(), + $connection->getGatewayName(), + $sourcePath, )); $processedMedia[] = $mediaId; $failedMedia[] = $mediaId; @@ -131,9 +132,9 @@ private function copyMediaFiles( $this->loggingService->addLogEntry(new ExceptionRunLog( $mappedWorkload[$mediaId]->getRunId(), - DefaultEntities::PRODUCT_DOWNLOAD, + $connection->getProfileName(), + $connection->getGatewayName(), $e, - $mediaId )); } } diff --git a/src/Profile/Shopware/Media/Strategy/Md5StrategyResolver.php b/src/Profile/Shopware/Media/Strategy/Md5StrategyResolver.php index 455bf2b17..0086edc00 100644 --- a/src/Profile/Shopware/Media/Strategy/Md5StrategyResolver.php +++ b/src/Profile/Shopware/Media/Strategy/Md5StrategyResolver.php @@ -19,7 +19,7 @@ class Md5StrategyResolver implements StrategyResolverInterface public function supports(string $path, MigrationContextInterface $migrationContext): bool { - return \file_exists($this->resolve($path, $migrationContext)); + return \is_file($this->resolve($path, $migrationContext)); } public function resolve(string $path, MigrationContextInterface $migrationContext): string diff --git a/src/Profile/Shopware/Media/Strategy/PlainStrategyResolver.php b/src/Profile/Shopware/Media/Strategy/PlainStrategyResolver.php index f86ae3a09..16381b1e8 100644 --- a/src/Profile/Shopware/Media/Strategy/PlainStrategyResolver.php +++ b/src/Profile/Shopware/Media/Strategy/PlainStrategyResolver.php @@ -15,7 +15,7 @@ class PlainStrategyResolver implements StrategyResolverInterface { public function supports(string $path, MigrationContextInterface $migrationContext): bool { - return \file_exists($this->resolve($path, $migrationContext)); + return \is_file($this->resolve($path, $migrationContext)); } public function resolve(string $path, MigrationContextInterface $migrationContext): string diff --git a/src/Profile/Shopware6/Converter/DocumentBaseConfigConverter.php b/src/Profile/Shopware6/Converter/DocumentBaseConfigConverter.php index 43bc1a46d..ebcd5e525 100644 --- a/src/Profile/Shopware6/Converter/DocumentBaseConfigConverter.php +++ b/src/Profile/Shopware6/Converter/DocumentBaseConfigConverter.php @@ -57,7 +57,14 @@ protected function convertData(array $data): ConvertStruct $converted['documentTypeId'] = $this->documentTypeLookup->get($converted['documentType']['technicalName'], $this->context); if ($converted['documentTypeId'] === null) { - $this->loggingService->addLogEntry(new UnsupportedDocumentTypeLog($this->runId, DefaultEntities::ORDER_DOCUMENT_BASE_CONFIG, $data['id'], $data['documentType']['technicalName'])); + $connection = $this->migrationContext->getConnection(); + + $this->loggingService->addLogEntry(new UnsupportedDocumentTypeLog( + $this->runId, + $connection->getProfileName(), + $connection->getGatewayName(), + $data['documentType']['technicalName'] + )); return new ConvertStruct(null, $data, $converted['id'] ?? null); } diff --git a/src/Profile/Shopware6/Converter/DocumentConverter.php b/src/Profile/Shopware6/Converter/DocumentConverter.php index 605c8279e..bcc45aa97 100644 --- a/src/Profile/Shopware6/Converter/DocumentConverter.php +++ b/src/Profile/Shopware6/Converter/DocumentConverter.php @@ -63,7 +63,14 @@ protected function convertData(array $data): ConvertStruct $converted['documentTypeId'] = $this->documentTypeLookup->get($converted['documentType']['technicalName'], $this->context); if ($converted['documentTypeId'] === null) { - $this->loggingService->addLogEntry(new UnsupportedDocumentTypeLog($this->runId, DefaultEntities::ORDER_DOCUMENT, $data['id'], $data['documentType']['technicalName'])); + $connection = $this->migrationContext->getConnection(); + + $this->loggingService->addLogEntry(new UnsupportedDocumentTypeLog( + $this->runId, + $connection->getProfileName(), + $connection->getGatewayName(), + $data['documentType']['technicalName'] + )); return new ConvertStruct(null, $data, $this->mainMapping['id'] ?? null); } diff --git a/src/Profile/Shopware6/Converter/MailTemplateConverter.php b/src/Profile/Shopware6/Converter/MailTemplateConverter.php index f09fbc19e..6e6699062 100644 --- a/src/Profile/Shopware6/Converter/MailTemplateConverter.php +++ b/src/Profile/Shopware6/Converter/MailTemplateConverter.php @@ -64,10 +64,13 @@ protected function convertData(array $data): ConvertStruct } else { $typeUuid = $this->mailTemplateTypeLookup->get($converted['mailTemplateType']['technicalName'], $this->context); if ($typeUuid === null) { + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry( new UnsupportedMailTemplateType( $this->runId, - $data['id'], + $connection->getProfileName(), + $connection->getGatewayName(), $converted['mailTemplateType']['technicalName'] ) ); diff --git a/src/Profile/Shopware6/Converter/MediaFolderConverter.php b/src/Profile/Shopware6/Converter/MediaFolderConverter.php index 995d03c21..5cb6c6016 100644 --- a/src/Profile/Shopware6/Converter/MediaFolderConverter.php +++ b/src/Profile/Shopware6/Converter/MediaFolderConverter.php @@ -58,11 +58,13 @@ protected function convertData(array $data): ConvertStruct $converted['parentId'] = $this->mediaFolderLookup->get($data['defaultFolder']['entity'], $this->context); if ($converted['parentId'] === null) { + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry( new UnsupportedMediaDefaultFolderLog( $this->migrationContext->getRunUuid(), - DefaultEntities::MEDIA_FOLDER, - $data['id'], + $connection->getProfileName(), + $connection->getGatewayName(), $data['defaultFolder']['entity'] ) ); diff --git a/src/Profile/Shopware6/Converter/NumberRangeConverter.php b/src/Profile/Shopware6/Converter/NumberRangeConverter.php index 98bc37218..8175e8819 100644 --- a/src/Profile/Shopware6/Converter/NumberRangeConverter.php +++ b/src/Profile/Shopware6/Converter/NumberRangeConverter.php @@ -62,11 +62,13 @@ protected function convertData(array $data): ConvertStruct $data['id'] ); + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry( new UnsupportedNumberRangeTypeLog( $this->runId, - DefaultEntities::NUMBER_RANGE, - $data['id'], + $connection->getProfileName(), + $connection->getGatewayName(), $converted['type']['technicalName'] ) ); diff --git a/src/Profile/Shopware6/Converter/ShopwareConverter.php b/src/Profile/Shopware6/Converter/ShopwareConverter.php index d18af65cb..59603d80d 100644 --- a/src/Profile/Shopware6/Converter/ShopwareConverter.php +++ b/src/Profile/Shopware6/Converter/ShopwareConverter.php @@ -147,10 +147,12 @@ protected function updateAssociationIds(array &$associationArray, string $entity if (empty($newAssociationId)) { if ($logMissing) { + $connection = $this->migrationContext->getConnection(); + $this->loggingService->addLogEntry(new AssociationRequiredMissingLog( $this->runId, - $entity, - $oldAssociationId, + $connection->getProfileName(), + $connection->getGatewayName(), $sourceEntity )); } diff --git a/src/Profile/Shopware6/Logging/Log/UnsupportedDocumentTypeLog.php b/src/Profile/Shopware6/Logging/Log/UnsupportedDocumentTypeLog.php index 34a79374c..70f08b20c 100644 --- a/src/Profile/Shopware6/Logging/Log/UnsupportedDocumentTypeLog.php +++ b/src/Profile/Shopware6/Logging/Log/UnsupportedDocumentTypeLog.php @@ -15,11 +15,21 @@ class UnsupportedDocumentTypeLog extends BaseRunLogEntry { public function __construct( string $runId, - string $entity, - string $sourceId, + string $profileName, + string $gatewayName, + /** @phpstan-ignore property.onlyWritten */ private readonly string $technicalName, ) { - parent::__construct($runId, $entity, $sourceId); + parent::__construct( + $runId, + $profileName, + $gatewayName + ); + } + + public function isUserFixable(): bool + { + return false; } public function getLevel(): string @@ -31,29 +41,4 @@ public function getCode(): string { return 'SWAG_MIGRATION__SHOPWARE_UNSUPPORTED_DOCUMENT_TYPE'; } - - public function getTitle(): string - { - return 'Unsupported document type'; - } - - public function getParameters(): array - { - return [ - 'entity' => $this->getEntity(), - 'sourceId' => $this->getSourceId(), - 'technicalName' => $this->technicalName, - ]; - } - - public function getDescription(): string - { - $args = $this->getParameters(); - - return \sprintf( - 'Document with source id "%s" could not be converted because of unsupported document type: %s.', - $args['sourceId'], - $args['technicalName'] - ); - } } diff --git a/src/Profile/Shopware6/Logging/Log/UnsupportedMediaDefaultFolderLog.php b/src/Profile/Shopware6/Logging/Log/UnsupportedMediaDefaultFolderLog.php index 7ca19bda8..1c9a5a370 100644 --- a/src/Profile/Shopware6/Logging/Log/UnsupportedMediaDefaultFolderLog.php +++ b/src/Profile/Shopware6/Logging/Log/UnsupportedMediaDefaultFolderLog.php @@ -15,11 +15,21 @@ class UnsupportedMediaDefaultFolderLog extends BaseRunLogEntry { public function __construct( string $runId, - string $entity, - string $sourceId, + string $profileName, + string $gatewayName, + /** @phpstan-ignore property.onlyWritten */ private readonly string $defaultEntity, ) { - parent::__construct($runId, $entity, $sourceId); + parent::__construct( + $runId, + $profileName, + $gatewayName + ); + } + + public function isUserFixable(): bool + { + return false; } public function getLevel(): string @@ -31,29 +41,4 @@ public function getCode(): string { return 'SWAG_MIGRATION__SHOPWARE_UNSUPPORTED_MEDIA_DEFAULT_FOLDER'; } - - public function getTitle(): string - { - return 'Unsupported default media folder'; - } - - public function getParameters(): array - { - return [ - 'entity' => $this->getEntity(), - 'sourceId' => $this->getSourceId(), - 'defaultEntity' => $this->defaultEntity, - ]; - } - - public function getDescription(): string - { - $args = $this->getParameters(); - - return \sprintf( - 'Media Folder with source id "%s" could not be converted because of unsupported default folder for entity: %s.', - $args['sourceId'], - $args['defaultEntity'] - ); - } } diff --git a/src/Profile/Shopware6/Media/HttpOrderDocumentGenerationService.php b/src/Profile/Shopware6/Media/HttpOrderDocumentGenerationService.php index b49ae8d10..ae1f07d6b 100644 --- a/src/Profile/Shopware6/Media/HttpOrderDocumentGenerationService.php +++ b/src/Profile/Shopware6/Media/HttpOrderDocumentGenerationService.php @@ -91,7 +91,8 @@ public function process( if ($client === null) { $this->loggingService->addLogEntry(new ExceptionRunLog( $runId, - DefaultEntities::ORDER_DOCUMENT_GENERATED, + $connection->getProfileName(), + $connection->getGatewayName(), new \Exception('Connection to the source system could not be established') )); $this->loggingService->saveLogging($context); @@ -282,8 +283,8 @@ private function handleFailedRequest( $mappedWorkload->setState(MediaProcessWorkloadStruct::ERROR_STATE); $this->loggingService->addLogEntry(new CannotGetFileRunLog( $mappedWorkload->getRunId(), - DefaultEntities::ORDER_DOCUMENT, - $mappedWorkload->getMediaId(), + $this->connection->getProfileName(), + $this->connection->getGatewayName(), $mappedWorkload->getAdditionalData()['uri'], $clientException )); diff --git a/tests/Migration/Controller/HistoryControllerTest.php b/tests/Migration/Controller/HistoryControllerTest.php index b189e5b26..fb0222050 100644 --- a/tests/Migration/Controller/HistoryControllerTest.php +++ b/tests/Migration/Controller/HistoryControllerTest.php @@ -99,16 +99,12 @@ protected function setUp(): void $this->loggingRepo->create([ [ + 'runId' => $this->runUuid, + 'profileName' => Shopware55Profile::PROFILE_NAME, + 'gatewayName' => ShopwareLocalGateway::GATEWAY_NAME, 'level' => LogEntryInterface::LOG_LEVEL_ERROR, 'code' => 'migration_error_1', - 'title' => 'Error1', - 'description' => 'Lorem Ipsum', - 'parameters' => [], - 'titleSnippet' => 'Random error snippet', - 'descriptionSnippet' => 'Lorem Ipsum random error', - 'entity' => 'product', - 'sourceId' => Uuid::randomHex(), - 'runId' => $this->runUuid, + 'userFixable' => false, ], ], $this->context); } @@ -162,7 +158,6 @@ public function testGetLogChunk(): void static::assertInstanceOf(SwagMigrationLoggingCollection::class, $result); static::assertNotNull($result->first()); - static::assertSame('Lorem Ipsum', $result->first()->getDescription()); } public function testGetPrefixLogInformation(): void diff --git a/tests/Migration/Logging/LoggingServiceTest.php b/tests/Migration/Logging/LoggingServiceTest.php index fb86077c4..5b633be76 100644 --- a/tests/Migration/Logging/LoggingServiceTest.php +++ b/tests/Migration/Logging/LoggingServiceTest.php @@ -60,8 +60,8 @@ protected function setUp(): void public function testAddLogEntry(): void { - $log1 = new AssociationRequiredMissingLog($this->runUuid, DefaultEntities::PRODUCT, '2', DefaultEntities::PRODUCT_MANUFACTURER); - $log2 = new CannotConvertChildEntity($this->runUuid, DefaultEntities::PRODUCT_MANUFACTURER, DefaultEntities::PRODUCT, '200'); + $log1 = new AssociationRequiredMissingLog($this->runUuid, 'Profile name', 'Gateway name', DefaultEntities::PRODUCT_MANUFACTURER); + $log2 = new CannotConvertChildEntity($this->runUuid, 'Profile name', 'Gateway name', DefaultEntities::PRODUCT, '200'); $this->loggingService->addLogEntry($log1); $this->loggingService->addLogEntry($log2); diff --git a/tests/Migration/Media/Process/HttpDownloadServiceBaseTest.php b/tests/Migration/Media/Process/HttpDownloadServiceBaseTest.php index 6638c42d8..9f6c9da05 100644 --- a/tests/Migration/Media/Process/HttpDownloadServiceBaseTest.php +++ b/tests/Migration/Media/Process/HttpDownloadServiceBaseTest.php @@ -22,6 +22,7 @@ use Shopware\Core\Framework\Log\Package; use Shopware\Core\Framework\Uuid\Uuid; use Shopware\Core\Test\Stub\DataAbstractionLayer\StaticEntityRepository; +use SwagMigrationAssistant\Migration\Connection\SwagMigrationConnectionEntity; use SwagMigrationAssistant\Migration\Gateway\HttpClientInterface; use SwagMigrationAssistant\Migration\Media\MediaProcessWorkloadStruct; use SwagMigrationAssistant\Migration\Media\SwagMigrationMediaFileCollection; @@ -47,7 +48,7 @@ protected function setUp(): void $this->loggingService = new DummyLoggingService(); $this->migrationContext = new MigrationContext( new Shopware6MajorProfile('6.6.0'), - null, + new SwagMigrationConnectionEntity(), Uuid::randomHex(), null, 0, @@ -195,20 +196,12 @@ public function testProcessWithRequestFailure(): void ], $resultWorkload); static::assertEquals([ [ - 'level' => 'warning', - 'code' => 'SWAG_MIGRATION_CANNOT_GET_MEDIA_FILE', - 'title' => 'The media file cannot be downloaded / copied', - 'description' => 'The media file with the uri "' . $mediaFiles[0]['uri'] . '" and media id "' . $mediaFiles[0]['mediaId'] . '" cannot be downloaded / copied. The following request error occurred: Request failed', - 'parameters' => [ - 'entity' => 'media', - 'sourceId' => $mediaFiles[0]['mediaId'], - 'uri' => $mediaFiles[0]['uri'], - ], - 'titleSnippet' => 'swag-migration.index.error.SWAG_MIGRATION_CANNOT_GET_FILE.title', - 'descriptionSnippet' => 'swag-migration.index.error.SWAG_MIGRATION_CANNOT_GET_FILE.description', - 'entity' => 'media', - 'sourceId' => $mediaFiles[0]['mediaId'], 'runId' => $this->runId, + 'level' => 'warning', + 'code' => 'SWAG_MIGRATION_CANNOT_GET_FILE', + 'profileName' => '', + 'gatewayName' => '', + 'userFixable' => false, ], ], $this->loggingService->getLoggingArray()); } @@ -248,7 +241,7 @@ public function testProcessShouldCreateATempFile(): void /** @var StaticEntityRepository $mediaFileRepo */ $mediaFileRepo = new StaticEntityRepository( [], - new SwagMigrationMediaFileDefinition() + new SwagMigrationMediaFileDefinition(), ); $fileSaverMock = $this->createMock(FileSaver::class); diff --git a/tests/Migration/MessageQueue/Handler/Processor/AbortingProcessorTest.php b/tests/Migration/MessageQueue/Handler/Processor/AbortingProcessorTest.php index 7b49ed105..f5d739b6c 100644 --- a/tests/Migration/MessageQueue/Handler/Processor/AbortingProcessorTest.php +++ b/tests/Migration/MessageQueue/Handler/Processor/AbortingProcessorTest.php @@ -47,6 +47,10 @@ protected function setUp(): void public function testProcessingWithoutConnection(): void { + // TODO: TODO remove with #11883? + static::markTestSkipped('Evaluate if this test is still needed, as it seems to unnecessary since $connection can be null'); + + /** @phpstan-ignore deadCode.unreachable */ $progress = new MigrationProgress(0, 0, new ProgressDataSetCollection(), 'product', 0); $run = new SwagMigrationRunEntity(); diff --git a/tests/Migration/Services/MigrationDataProcessingTest.php b/tests/Migration/Services/MigrationDataProcessingTest.php index a2b97881e..169ea5293 100644 --- a/tests/Migration/Services/MigrationDataProcessingTest.php +++ b/tests/Migration/Services/MigrationDataProcessingTest.php @@ -348,9 +348,8 @@ public function testFetchInvalidCustomerData(): void $type = $log->getLevel(); if ( - ($type === LogEntryInterface::LOG_LEVEL_INFO && $log->getCode() === 'SWAG_MIGRATION_CUSTOMER_ENTITY_FIELD_REASSIGNED') - || ($type === LogEntryInterface::LOG_LEVEL_WARNING && $log->getCode() === 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_CUSTOMER_ADDRESS') - || ($type === LogEntryInterface::LOG_LEVEL_WARNING && $log->getCode() === 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_CUSTOMER') + ($type === LogEntryInterface::LOG_LEVEL_INFO && $log->getCode() === 'SWAG_MIGRATION_ENTITY_FIELD_REASSIGNED') + || ($type === LogEntryInterface::LOG_LEVEL_WARNING && $log->getCode() === 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD') ) { ++$countValidLogging; diff --git a/tests/Migration/Services/MigrationDataWriterTest.php b/tests/Migration/Services/MigrationDataWriterTest.php index 9bcc2b3f4..4f6ba7501 100644 --- a/tests/Migration/Services/MigrationDataWriterTest.php +++ b/tests/Migration/Services/MigrationDataWriterTest.php @@ -647,7 +647,6 @@ public function testWriteDataWithUnknownWriter(): void $logs = $this->loggingService->getLoggingArray(); static::assertSame('SWAG_MIGRATION_RUN_EXCEPTION', $logs[0]['code']); - static::assertSame('SWAG_MIGRATION__WRITER_NOT_FOUND', $logs[0]['parameters']['exceptionCode']); static::assertCount(1, $logs); } diff --git a/tests/Migration/Services/RunServiceTest.php b/tests/Migration/Services/RunServiceTest.php index 260776b4d..a79357c3b 100644 --- a/tests/Migration/Services/RunServiceTest.php +++ b/tests/Migration/Services/RunServiceTest.php @@ -224,7 +224,7 @@ public function testStartMigrationRunWithNoSelectedConnection(): void $generalSettingEntity, ]), ], - new GeneralSettingDefinition() + new GeneralSettingDefinition(), ); $runService = $this->createRunService( diff --git a/tests/Migration/Subscriber/MessageQueueSubscriberTest.php b/tests/Migration/Subscriber/MessageQueueSubscriberTest.php index 38374735d..635405294 100644 --- a/tests/Migration/Subscriber/MessageQueueSubscriberTest.php +++ b/tests/Migration/Subscriber/MessageQueueSubscriberTest.php @@ -65,7 +65,7 @@ public function testOnWorkerMessageFailed(MigrationStep $step, bool $isAborted, /** @var StaticEntityRepository $repository */ $repository = new StaticEntityRepository( [new EntitySearchResult(SwagMigrationRunDefinition::ENTITY_NAME, 1, new EntityCollection([$run]), null, new Criteria(), $this->context)], - new SwagMigrationRunDefinition() + new SwagMigrationRunDefinition(), ); $dummyLoggingService = new DummyLoggingService(); @@ -192,7 +192,7 @@ public function testOnWorkerMessageFailedShouldRaiseExceptionCountAndAbortRunAnd $this->context ), ], - new SwagMigrationRunDefinition() + new SwagMigrationRunDefinition(), ); $dummyLoggingService = new DummyLoggingService(); @@ -253,7 +253,7 @@ public function testOnWorkerMessageHandled(bool $noMessage, bool $noRun, bool $n $this->context ), ], - new SwagMigrationRunDefinition() + new SwagMigrationRunDefinition(), ); $dummyLoggingService = new DummyLoggingService(); diff --git a/tests/Profile/Shopware/Gateway/Local/CategoryAttributeReaderTest.php b/tests/Profile/Shopware/Gateway/Local/CategoryAttributeReaderTest.php index 8141e52df..83ffa7033 100644 --- a/tests/Profile/Shopware/Gateway/Local/CategoryAttributeReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/CategoryAttributeReaderTest.php @@ -49,12 +49,12 @@ public function testRead(): void $data = $this->categoryAttributeReader->read($this->migrationContext); - static::assertCount(6, $data); - static::assertSame('attribute1', $data[0]['name']); - static::assertSame('text', $data[0]['type']); + static::assertCount(7, $data); + static::assertSame('categoryID', $data[0]['name']); + static::assertSame('integer', $data[0]['type']); static::assertSame('de-DE', $data[0]['_locale']); - static::assertSame('attribute2', $data[1]['name']); + static::assertSame('attribute1', $data[1]['name']); static::assertSame('text', $data[1]['type']); static::assertSame('de-DE', $data[1]['_locale']); } diff --git a/tests/Profile/Shopware/Gateway/Local/CustomerAttributeReaderTest.php b/tests/Profile/Shopware/Gateway/Local/CustomerAttributeReaderTest.php index f4f53066a..4f6521933 100644 --- a/tests/Profile/Shopware/Gateway/Local/CustomerAttributeReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/CustomerAttributeReaderTest.php @@ -49,6 +49,9 @@ public function testRead(): void $data = $this->customerAttributeReader->read($this->migrationContext); - static::assertCount(0, $data); + static::assertCount(1, $data); + static::assertSame('userID', $data[0]['name']); + static::assertSame('integer', $data[0]['type']); + static::assertSame('de-DE', $data[0]['_locale']); } } diff --git a/tests/Profile/Shopware/Gateway/Local/CustomerGroupAttributeReaderTest.php b/tests/Profile/Shopware/Gateway/Local/CustomerGroupAttributeReaderTest.php index 317395d15..23f1d612e 100644 --- a/tests/Profile/Shopware/Gateway/Local/CustomerGroupAttributeReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/CustomerGroupAttributeReaderTest.php @@ -49,6 +49,9 @@ public function testRead(): void $data = $this->customerGroupAttributeReader->read($this->migrationContext); - static::assertCount(0, $data); + static::assertCount(1, $data); + static::assertSame('customerGroupID', $data[0]['name']); + static::assertSame('integer', $data[0]['type']); + static::assertSame('de-DE', $data[0]['_locale']); } } diff --git a/tests/Profile/Shopware/Gateway/Local/ManufacturerAttributeReaderTest.php b/tests/Profile/Shopware/Gateway/Local/ManufacturerAttributeReaderTest.php index 7b86ebebb..341a59339 100644 --- a/tests/Profile/Shopware/Gateway/Local/ManufacturerAttributeReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/ManufacturerAttributeReaderTest.php @@ -49,6 +49,9 @@ public function testRead(): void $data = $this->manufacturerAttributeReader->read($this->migrationContext); - static::assertCount(0, $data); + static::assertCount(1, $data); + static::assertSame('supplierID', $data[0]['name']); + static::assertSame('integer', $data[0]['type']); + static::assertSame('de-DE', $data[0]['_locale']); } } diff --git a/tests/Profile/Shopware/Gateway/Local/OrderAttributeReaderTest.php b/tests/Profile/Shopware/Gateway/Local/OrderAttributeReaderTest.php index be08775a3..2487dafb2 100644 --- a/tests/Profile/Shopware/Gateway/Local/OrderAttributeReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/OrderAttributeReaderTest.php @@ -49,12 +49,12 @@ public function testRead(): void $data = $this->orderAttributeReader->read($this->migrationContext); - static::assertCount(6, $data); - static::assertSame('attribute1', $data[0]['name']); - static::assertSame('text', $data[0]['type']); + static::assertCount(7, $data); + static::assertSame('orderID', $data[0]['name']); + static::assertSame('integer', $data[0]['type']); static::assertSame('de-DE', $data[0]['_locale']); - static::assertSame('attribute2', $data[1]['name']); + static::assertSame('attribute1', $data[1]['name']); static::assertSame('text', $data[1]['type']); static::assertSame('de-DE', $data[1]['_locale']); } diff --git a/tests/Profile/Shopware/Gateway/Local/OrderDocumentAttributeReaderTest.php b/tests/Profile/Shopware/Gateway/Local/OrderDocumentAttributeReaderTest.php index b11dbada4..c0ea7bc9c 100644 --- a/tests/Profile/Shopware/Gateway/Local/OrderDocumentAttributeReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/OrderDocumentAttributeReaderTest.php @@ -49,6 +49,9 @@ public function testRead(): void $data = $this->orderDocumentAttributeReader->read($this->migrationContext); - static::assertCount(0, $data); + static::assertCount(1, $data); + static::assertSame('documentID', $data[0]['name']); + static::assertSame('integer', $data[0]['type']); + static::assertSame('de-DE', $data[0]['_locale']); } } diff --git a/tests/Profile/Shopware/Gateway/Local/ProductAttributeReaderTest.php b/tests/Profile/Shopware/Gateway/Local/ProductAttributeReaderTest.php index 0b0e44832..13d25323a 100644 --- a/tests/Profile/Shopware/Gateway/Local/ProductAttributeReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/ProductAttributeReaderTest.php @@ -49,12 +49,12 @@ public function testRead(): void $data = $this->productAttributeReader->read($this->migrationContext); - static::assertCount(20, $data); - static::assertSame('attr1', $data[0]['name']); - static::assertSame('text', $data[0]['type']); + static::assertCount(21, $data); + static::assertSame('articledetailsID', $data[0]['name']); + static::assertSame('integer', $data[0]['type']); static::assertSame('de-DE', $data[0]['_locale']); - static::assertSame('attr2', $data[1]['name']); + static::assertSame('attr1', $data[1]['name']); static::assertSame('text', $data[1]['type']); static::assertSame('de-DE', $data[1]['_locale']); } diff --git a/tests/Profile/Shopware/Gateway/Local/ProductPriceAttributeReaderTest.php b/tests/Profile/Shopware/Gateway/Local/ProductPriceAttributeReaderTest.php index 0a3d2941a..2aa0e5fb0 100644 --- a/tests/Profile/Shopware/Gateway/Local/ProductPriceAttributeReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/ProductPriceAttributeReaderTest.php @@ -49,6 +49,9 @@ public function testRead(): void $data = $this->productPriceAttributeReader->read($this->migrationContext); - static::assertCount(0, $data); + static::assertCount(1, $data); + static::assertSame('priceID', $data[0]['name']); + static::assertSame('integer', $data[0]['type']); + static::assertSame('de-DE', $data[0]['_locale']); } } diff --git a/tests/Profile/Shopware54/Converter/OrderDocumentConverterTest.php b/tests/Profile/Shopware54/Converter/OrderDocumentConverterTest.php index b9fe71033..bd4faab9e 100644 --- a/tests/Profile/Shopware54/Converter/OrderDocumentConverterTest.php +++ b/tests/Profile/Shopware54/Converter/OrderDocumentConverterTest.php @@ -103,7 +103,7 @@ public function testConvertWithUnknownOrderId(): void ); static::assertEmpty($convertResult->getConverted()); $logs = $this->loggingService->getLoggingArray(); - static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_ORDER', $logs[0]['code']); + static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING', $logs[0]['code']); } public function testConvertWithoutDocumentType(): void @@ -119,9 +119,7 @@ public function testConvertWithoutDocumentType(): void ); static::assertEmpty($convertResult->getConverted()); $logs = $this->loggingService->getLoggingArray(); - static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_ORDER_DOCUMENT', $logs[0]['code']); - static::assertSame('1', $logs[0]['parameters']['sourceId']); - static::assertSame('documenttype', $logs[0]['parameters']['emptyField']); + static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD', $logs[0]['code']); } public function testConvert(): void @@ -176,7 +174,12 @@ public function testConvertShouldLogUnknownType(): void foreach ($orderDocumentConverterClasses as $orderDocumentConverterClass => $expected) { $loggerMock = $this->createMock(LoggingServiceInterface::class); - $loggerMock->expects(static::exactly(1))->method('addLogEntry')->with(new DocumentTypeNotSupported($this->runId, '999', $expected)); + $loggerMock->expects(static::exactly(1))->method('addLogEntry')->with(new DocumentTypeNotSupported( + $this->runId, + Shopware54Profile::PROFILE_NAME, + ShopwareLocalGateway::GATEWAY_NAME, + $expected + )); $orderDocumentConverter = $this->createDocumentConverter($orderDocumentConverterClass, $mappingServiceMock, $loggerMock); $convertResult = $orderDocumentConverter->convert( diff --git a/tests/Profile/Shopware55/Converter/CategoryConverterTest.php b/tests/Profile/Shopware55/Converter/CategoryConverterTest.php index eb693c964..f998c66c2 100644 --- a/tests/Profile/Shopware55/Converter/CategoryConverterTest.php +++ b/tests/Profile/Shopware55/Converter/CategoryConverterTest.php @@ -177,8 +177,6 @@ public function testConvertWithoutLocale(): void static::assertNull($convertResult->getConverted()); $logs = $this->loggingService->getLoggingArray(); - $title = 'The category entity has one or more empty necessary fields'; - static::assertSame($title, $logs[0]['title']); static::assertCount(1, $logs); } diff --git a/tests/Profile/Shopware55/Converter/CrossSellingConverterTest.php b/tests/Profile/Shopware55/Converter/CrossSellingConverterTest.php index 2817c299b..98f6872e7 100644 --- a/tests/Profile/Shopware55/Converter/CrossSellingConverterTest.php +++ b/tests/Profile/Shopware55/Converter/CrossSellingConverterTest.php @@ -156,8 +156,7 @@ public function testConvertWithoutMapping(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_PRODUCT', $logs[0]['code']); - static::assertSame('99', $logs[0]['parameters']['sourceId']); + static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING', $logs[0]['code']); $this->loggingService->resetLogging(); $data[0]['relatedarticle'] = '80'; @@ -168,8 +167,7 @@ public function testConvertWithoutMapping(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_PRODUCT', $logs[0]['code']); - static::assertSame('80', $logs[0]['parameters']['sourceId']); + static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING', $logs[0]['code']); } public function testConvertCreatesAdditionalMappingForTypeAndArticleId(): void diff --git a/tests/Profile/Shopware55/Converter/CustomerConverterTest.php b/tests/Profile/Shopware55/Converter/CustomerConverterTest.php index 6ade16b95..0011d904a 100644 --- a/tests/Profile/Shopware55/Converter/CustomerConverterTest.php +++ b/tests/Profile/Shopware55/Converter/CustomerConverterTest.php @@ -155,7 +155,6 @@ public function testConvertWithInvalidEmail(): void static::assertCount(1, $logs); static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__INVALID_EMAIL_ADDRESS'); - static::assertSame($logs[0]['parameters']['email'], '42'); } #[DataProvider('requiredProperties')] @@ -176,8 +175,7 @@ public function testConvertWithoutRequiredProperties(string $property, ?string $ $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_CUSTOMER'); - static::assertSame($logs[0]['parameters']['emptyField'], $property); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); } /** @@ -292,9 +290,7 @@ public function testConvertCustomerWithoutAddresses(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_CUSTOMER'); - static::assertSame($logs[0]['parameters']['sourceId'], $customerData['id']); - static::assertSame($logs[0]['parameters']['emptyField'], 'address data'); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); } public function testConvertCustomerWithoutValidAddresses(): void @@ -317,17 +313,9 @@ public function testConvertCustomerWithoutValidAddresses(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(3, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_CUSTOMER_ADDRESS'); - static::assertSame($logs[0]['parameters']['sourceId'], $customerData['addresses'][0]['id']); - static::assertSame($logs[0]['parameters']['emptyField'], 'firstname'); - - static::assertSame($logs[1]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_CUSTOMER_ADDRESS'); - static::assertSame($logs[1]['parameters']['sourceId'], $customerData['addresses'][1]['id']); - static::assertSame($logs[1]['parameters']['emptyField'], 'lastname'); - - static::assertSame($logs[2]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_CUSTOMER'); - static::assertSame($logs[2]['parameters']['sourceId'], $customerData['id']); - static::assertSame($logs[2]['parameters']['emptyField'], 'address data'); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); + static::assertSame($logs[1]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); + static::assertSame($logs[2]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); } /** @@ -377,13 +365,8 @@ public function testConvertWithoutRequiredAddressPropertiesForBillingDefault(str $logs = $this->loggingService->getLoggingArray(); static::assertCount(2, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_CUSTOMER_ADDRESS'); - static::assertSame($logs[0]['parameters']['sourceId'], $customerData['addresses'][0]['id']); - static::assertSame($logs[0]['parameters']['emptyField'], $property); - - static::assertSame($logs[1]['code'], 'SWAG_MIGRATION_CUSTOMER_ENTITY_FIELD_REASSIGNED'); - static::assertSame($logs[1]['parameters']['emptyField'], 'default billing address'); - static::assertSame($logs[1]['parameters']['replacementField'], 'default shipping address'); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); + static::assertSame($logs[1]['code'], 'SWAG_MIGRATION_ENTITY_FIELD_REASSIGNED'); } #[DataProvider('requiredAddressProperties')] @@ -414,13 +397,8 @@ public function testConvertWithoutRequiredAddressPropertiesForShippingDefault(st $logs = $this->loggingService->getLoggingArray(); static::assertCount(2, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_CUSTOMER_ADDRESS'); - static::assertSame($logs[0]['parameters']['sourceId'], $customerData['addresses'][1]['id']); - static::assertSame($logs[0]['parameters']['emptyField'], $property); - - static::assertSame($logs[1]['code'], 'SWAG_MIGRATION_CUSTOMER_ENTITY_FIELD_REASSIGNED'); - static::assertSame($logs[1]['parameters']['emptyField'], 'default shipping address'); - static::assertSame($logs[1]['parameters']['replacementField'], 'default billing address'); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); + static::assertSame($logs[1]['code'], 'SWAG_MIGRATION_ENTITY_FIELD_REASSIGNED'); } #[DataProvider('requiredAddressProperties')] @@ -452,17 +430,9 @@ public function testConvertWithoutRequiredAddressPropertiesForDefaultBillingAndS $logs = $this->loggingService->getLoggingArray(); static::assertCount(3, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_CUSTOMER_ADDRESS'); - static::assertSame($logs[0]['parameters']['sourceId'], $customerData['addresses'][0]['id']); - static::assertSame($logs[0]['parameters']['emptyField'], $property); - - static::assertSame($logs[1]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_CUSTOMER_ADDRESS'); - static::assertSame($logs[1]['parameters']['sourceId'], $customerData['addresses'][1]['id']); - static::assertSame($logs[1]['parameters']['emptyField'], $property); - - static::assertSame($logs[2]['code'], 'SWAG_MIGRATION_CUSTOMER_ENTITY_FIELD_REASSIGNED'); - static::assertSame($logs[2]['parameters']['emptyField'], 'default billing and shipping address'); - static::assertSame($logs[2]['parameters']['replacementField'], 'first address'); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); + static::assertSame($logs[1]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); + static::assertSame($logs[2]['code'], 'SWAG_MIGRATION_ENTITY_FIELD_REASSIGNED'); } public function testGetCustomerWithShopScope(): void @@ -565,10 +535,6 @@ public function testConvertNotExistingCountryStateWithoutMapping(): void static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_COUNTRY_STATE_ENTITY_UNKNOWN'); - static::assertSame($logs[0]['parameters']['sourceId'], '9999'); - static::assertSame($logs[0]['parameters']['entity'], DefaultEntities::COUNTRY_STATE); - static::assertSame($logs[0]['parameters']['requiredForSourceId'], $customerData['id']); - static::assertSame($logs[0]['parameters']['requiredForEntity'], DefaultEntities::CUSTOMER); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_ENTITY_UNKNOWN'); } } diff --git a/tests/Profile/Shopware55/Converter/LanguageConverterTest.php b/tests/Profile/Shopware55/Converter/LanguageConverterTest.php index bade41182..45adc5d1e 100644 --- a/tests/Profile/Shopware55/Converter/LanguageConverterTest.php +++ b/tests/Profile/Shopware55/Converter/LanguageConverterTest.php @@ -104,6 +104,6 @@ public function testConvertWhichExists(): void static::assertNotNull($convertResult->getUnmapped()); $logs = $this->loggingService->getLoggingArray(); - static::assertSame('SWAG_MIGRATION_LANGUAGE_ENTITY_ALREADY_EXISTS', $logs[0]['code']); + static::assertSame('SWAG_MIGRATION_ENTITY_ALREADY_EXISTS', $logs[0]['code']); } } diff --git a/tests/Profile/Shopware55/Converter/MainVariantRelationConverterTest.php b/tests/Profile/Shopware55/Converter/MainVariantRelationConverterTest.php index 4cefdd9fd..60dac08d2 100644 --- a/tests/Profile/Shopware55/Converter/MainVariantRelationConverterTest.php +++ b/tests/Profile/Shopware55/Converter/MainVariantRelationConverterTest.php @@ -142,17 +142,11 @@ public function testConvertWithoutMapping(): void $this->converter->writeMapping($context); $converted = $convertResult->getConverted(); - $parameters = [ - 'missingEntity' => 'product_container', - 'requiredFor' => 'main_variant_relation', - 'sourceId' => 'invalid-id', - ]; $logs = $this->loggingService->getLoggingArray(); static::assertNotNull($convertResult->getUnmapped()); static::assertNull($converted); static::assertCount(1, $logs); - static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_PRODUCT_CONTAINER', $logs[0]['code']); - static::assertSame($parameters, $logs[0]['parameters']); + static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING', $logs[0]['code']); $this->loggingService->resetLogging(); $raw2['ordernumber'] = 'invalid-ordernumber'; @@ -160,16 +154,10 @@ public function testConvertWithoutMapping(): void $this->converter->writeMapping($context); $converted = $convertResult->getConverted(); - $parameters = [ - 'missingEntity' => 'product', - 'requiredFor' => 'main_variant_relation', - 'sourceId' => 'invalid-ordernumber', - ]; $logs = $this->loggingService->getLoggingArray(); static::assertNotNull($convertResult->getUnmapped()); static::assertNull($converted); static::assertCount(1, $logs); - static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_PRODUCT', $logs[0]['code']); - static::assertSame($parameters, $logs[0]['parameters']); + static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING', $logs[0]['code']); } } diff --git a/tests/Profile/Shopware55/Converter/NewsletterRecipientConverterTest.php b/tests/Profile/Shopware55/Converter/NewsletterRecipientConverterTest.php index 5fab2388a..fcd63dd9f 100644 --- a/tests/Profile/Shopware55/Converter/NewsletterRecipientConverterTest.php +++ b/tests/Profile/Shopware55/Converter/NewsletterRecipientConverterTest.php @@ -112,9 +112,7 @@ public function testConvertWithoutDoubleOptinConfirmed(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_NEWSLETTER_RECIPIENT'); - static::assertSame($logs[0]['parameters']['sourceId'], '1'); - static::assertSame($logs[0]['parameters']['emptyField'], 'status'); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); } public function testConvertWithNotExistingSalutation(): void @@ -137,9 +135,7 @@ public function testConvertWithNotExistingSalutation(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_SALUTATION_ENTITY_UNKNOWN'); - static::assertSame($logs[0]['parameters']['sourceId'], 'xx'); - static::assertSame($logs[0]['parameters']['requiredForSourceId'], '1'); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_ENTITY_UNKNOWN'); } public function testConvert(): void diff --git a/tests/Profile/Shopware55/Converter/OrderConverterTest.php b/tests/Profile/Shopware55/Converter/OrderConverterTest.php index 93677eacf..1256004e9 100644 --- a/tests/Profile/Shopware55/Converter/OrderConverterTest.php +++ b/tests/Profile/Shopware55/Converter/OrderConverterTest.php @@ -396,9 +396,7 @@ public function testConvertWithoutRequiredProperties(string $missingProperty): v $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_ORDER'); - static::assertSame($logs[0]['parameters']['sourceId'], $orderData['id']); - static::assertSame($logs[0]['parameters']['emptyField'], $missingProperty); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); } /** @@ -582,7 +580,7 @@ public function testConvertWithoutValidBillingAddress(string $missingAddressProp $validLog = 0; foreach ($this->loggingService->getLoggingArray() as $log) { - if ($log['code'] === 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_ORDER_ADDRESS' || $log['code'] === 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_ORDER') { + if ($log['code'] === 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD') { ++$validLog; } } @@ -620,7 +618,7 @@ public function testConvertWithoutValidShippingAddress(string $missingProperty): static::assertCount(1, $this->loggingService->getLoggingArray()); foreach ($this->loggingService->getLoggingArray() as $log) { - static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_ORDER_ADDRESS', $log['code']); + static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD', $log['code']); } } @@ -649,8 +647,7 @@ public function testConvertWithoutPaymentName(): void static::assertCount(1, $this->loggingService->getLoggingArray()); foreach ($this->loggingService->getLoggingArray() as $log) { - static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_ORDER', $log['code']); - static::assertSame($log['parameters']['emptyField'], 'paymentMethod'); + static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD', $log['code']); } } @@ -679,7 +676,7 @@ public function testConvertWithoutKnownOrderState(): void static::assertCount(1, $this->loggingService->getLoggingArray()); foreach ($this->loggingService->getLoggingArray() as $log) { - static::assertSame('SWAG_MIGRATION_ORDER_STATE_ENTITY_UNKNOWN', $log['code']); + static::assertSame('SWAG_MIGRATION_ENTITY_UNKNOWN', $log['code']); } } @@ -893,11 +890,7 @@ public function testConvertNotExistingCountryStateWithoutMapping(): void static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_COUNTRY_STATE_ENTITY_UNKNOWN'); - static::assertSame($logs[0]['parameters']['sourceId'], '9999'); - static::assertSame($logs[0]['parameters']['entity'], DefaultEntities::COUNTRY_STATE); - static::assertSame($logs[0]['parameters']['requiredForSourceId'], $orderData['id']); - static::assertSame($logs[0]['parameters']['requiredForEntity'], DefaultEntities::ORDER); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_ENTITY_UNKNOWN'); } public function testConvertWithShippingTaxRateNotSet(): void diff --git a/tests/Profile/Shopware55/Converter/ProductConverterTest.php b/tests/Profile/Shopware55/Converter/ProductConverterTest.php index 11538e83f..f945ad0c2 100644 --- a/tests/Profile/Shopware55/Converter/ProductConverterTest.php +++ b/tests/Profile/Shopware55/Converter/ProductConverterTest.php @@ -358,9 +358,7 @@ public function testConvertWithInvalidMedia(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_CANNOT_CONVERT_CHILD_PRODUCT_MEDIA_ENTITY'); - static::assertSame($logs[0]['parameters']['parentSourceId'], 'SW10006'); - static::assertSame($logs[0]['parameters']['entity'], 'product_media'); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_CANNOT_CONVERT_CHILD_ENTITY'); } public function testConvertDeliveryTime(): void diff --git a/tests/Profile/Shopware55/Converter/PromotionConverterTest.php b/tests/Profile/Shopware55/Converter/PromotionConverterTest.php index e901b7240..c1e67cf0d 100644 --- a/tests/Profile/Shopware55/Converter/PromotionConverterTest.php +++ b/tests/Profile/Shopware55/Converter/PromotionConverterTest.php @@ -239,9 +239,6 @@ public function testConvertWithRestrictedSalesChannelWithoutMapping(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame(DefaultEntities::SALES_CHANNEL, $logs[0]['parameters']['missingEntity']); - static::assertSame(DefaultEntities::PROMOTION, $logs[0]['parameters']['requiredFor']); - static::assertSame('9', $logs[0]['parameters']['sourceId']); $this->assertSameTwiceMigration($promotionData[0], $context, $converted); } @@ -350,9 +347,6 @@ public function testConvertWithRestrictedNotMappedManufacturer(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame(DefaultEntities::PRODUCT_MANUFACTURER, $logs[0]['parameters']['missingEntity']); - static::assertSame(DefaultEntities::PROMOTION_DISCOUNT, $logs[0]['parameters']['requiredFor']); - static::assertSame('8', $logs[0]['parameters']['sourceId']); $this->assertSameTwiceMigration($promotionData[0], $context, $converted); } @@ -422,9 +416,6 @@ public function testConvertWithRestrictedProductsWithoutMapping(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(3, $logs); - static::assertSame(DefaultEntities::PRODUCT, $logs[0]['parameters']['missingEntity']); - static::assertSame(DefaultEntities::PROMOTION, $logs[0]['parameters']['requiredFor']); - static::assertSame('SW10008.1', $logs[0]['parameters']['sourceId']); $this->assertSameTwiceMigration($promotionData[0], $context, $converted); } @@ -465,9 +456,6 @@ public function testConvertWithRestrictedProductsWithoutOneMapping(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame(DefaultEntities::PRODUCT, $logs[0]['parameters']['missingEntity']); - static::assertSame(DefaultEntities::PROMOTION, $logs[0]['parameters']['requiredFor']); - static::assertSame('SW10008.3', $logs[0]['parameters']['sourceId']); $this->assertSameTwiceMigration($promotionData[0], $context, $converted); } @@ -617,9 +605,6 @@ public function testConvertWithRestrictedCustomerGroupWithoutMapping(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame(DefaultEntities::CUSTOMER_GROUP, $logs[0]['parameters']['missingEntity']); - static::assertSame(DefaultEntities::PROMOTION, $logs[0]['parameters']['requiredFor']); - static::assertSame('8', $logs[0]['parameters']['sourceId']); $this->assertSameTwiceMigration($promotionData[0], $context, $converted); } diff --git a/tests/Profile/Shopware55/Converter/SalesChannelConverterTest.php b/tests/Profile/Shopware55/Converter/SalesChannelConverterTest.php index b6b007a96..311ee05f7 100644 --- a/tests/Profile/Shopware55/Converter/SalesChannelConverterTest.php +++ b/tests/Profile/Shopware55/Converter/SalesChannelConverterTest.php @@ -91,7 +91,7 @@ public function testConvert(): void $context = Context::createDefaultContext(); $connection = $this->migrationContext->getConnection(); - static::assertNotNull($connection); + $this->mappingService->getOrCreateMapping($connection->getId(), DefaultEntities::CUSTOMER_GROUP, '1', $context); $this->mappingService->getOrCreateMapping($connection->getId(), DefaultEntities::CATEGORY, '3', $context); $this->mappingService->getOrCreateMapping($connection->getId(), DefaultEntities::CATEGORY, '39', $context); @@ -132,7 +132,7 @@ public function testConvertWithInactiveRequirements(): void $context = Context::createDefaultContext(); $connection = $this->migrationContext->getConnection(); - static::assertNotNull($connection); + $this->mappingService->getOrCreateMapping($connection->getId(), DefaultEntities::CUSTOMER_GROUP, '1', $context); $this->mappingService->getOrCreateMapping($connection->getId(), DefaultEntities::CATEGORY, '3', $context); $this->mappingService->getOrCreateMapping($connection->getId(), DefaultEntities::CATEGORY, '39', $context); diff --git a/tests/Profile/Shopware55/Converter/ShippingMethodConverterTest.php b/tests/Profile/Shopware55/Converter/ShippingMethodConverterTest.php index 67e726725..9b49a7e1a 100644 --- a/tests/Profile/Shopware55/Converter/ShippingMethodConverterTest.php +++ b/tests/Profile/Shopware55/Converter/ShippingMethodConverterTest.php @@ -160,15 +160,12 @@ public function testConvertWithInvalidCalculation(): void $convertResult = $this->shippingMethodConverter->convert($shippingMethodData[0], $this->context, $this->migrationContext); $logs = $this->loggingService->getLoggingArray(); - $error = new UnsupportedShippingCalculationType('', DefaultEntities::SHIPPING_METHOD, '15', '5'); + $error = new UnsupportedShippingCalculationType('', 'Profile name', 'Gateway name', '5'); static::assertNull($convertResult->getUnmapped()); static::assertNotNull($convertResult->getConverted()); static::assertCount(1, $logs); static::assertSame($error->getCode(), $logs[0]['code']); - static::assertSame($error->getSourceId(), $logs[0]['sourceId']); - static::assertSame($error->getEntity(), $logs[0]['entity']); - static::assertSame($error->getParameters()['type'], $logs[0]['parameters']['type']); } public function testConvertWithFactor(): void @@ -178,15 +175,12 @@ public function testConvertWithFactor(): void $convertResult = $this->shippingMethodConverter->convert($shippingMethodData[0], $this->context, $this->migrationContext); $logs = $this->loggingService->getLoggingArray(); - $error = new UnsupportedShippingPriceLog('', DefaultEntities::SHIPPING_METHOD_PRICE, '309', '15'); + $error = new UnsupportedShippingPriceLog('', 'Profile name', 'Gateway name', '15'); static::assertNull($convertResult->getUnmapped()); static::assertNotNull($convertResult->getConverted()); static::assertCount(1, $logs); static::assertSame($error->getCode(), $logs[0]['code']); - static::assertSame($error->getSourceId(), $logs[0]['sourceId']); - static::assertSame($error->getEntity(), $logs[0]['entity']); - static::assertSame($error->getParameters()['shippingMethodId'], $logs[0]['parameters']['shippingMethodId']); } /** diff --git a/tests/Profile/Shopware55/Converter/TranslationConverterTest.php b/tests/Profile/Shopware55/Converter/TranslationConverterTest.php index 4730900ae..eb5f20c32 100644 --- a/tests/Profile/Shopware55/Converter/TranslationConverterTest.php +++ b/tests/Profile/Shopware55/Converter/TranslationConverterTest.php @@ -142,8 +142,6 @@ public function testConvertUnknownTranslationType(): void static::assertCount(1, $logs); static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_UNSUPPORTED_OBJECT_TYPE'); - static::assertSame($logs[0]['parameters']['sourceId'], '276'); - static::assertSame($logs[0]['parameters']['objectType'], 'invalid'); } public function testConvertProductTranslation(): void @@ -278,8 +276,6 @@ public function testConvertManufacturerTranslationWithInvalidTranslationObject() static::assertCount(1, $logs); static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_INVALID_UNSERIALIZED_DATA'); - static::assertSame($logs[0]['parameters']['sourceId'], '273'); - static::assertSame($logs[0]['parameters']['unserializedEntity'], 'product_manufacturer_translation'); } public function testConvertUnitTranslation(): void @@ -324,9 +320,7 @@ public function testConvertUnitTranslationWithoutParent(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_UNIT'); - static::assertSame($logs[0]['parameters']['sourceId'], '274'); - static::assertSame($logs[0]['parameters']['missingEntity'], 'unit'); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING'); } public function testConvertUnitTranslationWithInvalidTranslationObject(): void @@ -356,8 +350,6 @@ public function testConvertUnitTranslationWithInvalidTranslationObject(): void static::assertCount(1, $logs); static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_INVALID_UNSERIALIZED_DATA'); - static::assertSame($logs[0]['parameters']['sourceId'], '274'); - static::assertSame($logs[0]['parameters']['unserializedEntity'], 'unit_translation'); } public function testConvertCategoryTranslation(): void @@ -472,9 +464,7 @@ public function testConvertCategoryTranslationWithoutParent(): void $logs = $this->loggingService->getLoggingArray(); static::assertCount(1, $logs); - static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_CATEGORY'); - static::assertSame($logs[0]['parameters']['sourceId'], '275'); - static::assertSame($logs[0]['parameters']['missingEntity'], 'category'); + static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING'); } public function testConvertCategoryTranslationWithInvalidTranslationObject(): void @@ -503,8 +493,6 @@ public function testConvertCategoryTranslationWithInvalidTranslationObject(): vo static::assertCount(1, $logs); static::assertSame($logs[0]['code'], 'SWAG_MIGRATION__SHOPWARE_INVALID_UNSERIALIZED_DATA'); - static::assertSame($logs[0]['parameters']['sourceId'], '275'); - static::assertSame($logs[0]['parameters']['unserializedEntity'], 'category_translation'); } public function testCreateConfiguratorOptionTranslation(): void @@ -621,7 +609,7 @@ public function testConvertProductWithoutLocale(): void static::assertNull($convertResult->getConverted()); static::assertCount(1, $this->loggingService->getLoggingArray()); $logs = $this->loggingService->getLoggingArray(); - static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD_TRANSLATION', $logs[0]['code']); + static::assertSame('SWAG_MIGRATION_EMPTY_NECESSARY_FIELD', $logs[0]['code']); } public function testConvertVariantAttributeTranslation(): void @@ -759,14 +747,7 @@ public function testConvertProductMediaTranslationWithoutMediaMapping(): void static::assertNull($converted); static::assertCount(1, $logs); - $logParameters = [ - 'missingEntity' => DefaultEntities::MEDIA, - 'requiredFor' => DefaultEntities::TRANSLATION, - 'sourceId' => '769', - ]; - - static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_MEDIA', $logs[0]['code']); - static::assertSame($logParameters, $logs[0]['parameters']); + static::assertSame('SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING', $logs[0]['code']); } public function testConvertProductTranslationsWithSeoData(): void diff --git a/tests/Profile/Shopware6/Converter/SalesChannelConverterTest.php b/tests/Profile/Shopware6/Converter/SalesChannelConverterTest.php index 8d001ad29..054d63776 100644 --- a/tests/Profile/Shopware6/Converter/SalesChannelConverterTest.php +++ b/tests/Profile/Shopware6/Converter/SalesChannelConverterTest.php @@ -34,7 +34,7 @@ public function testConvert(string $fixtureFolderPath): void $expectedOutput = require $fixtureFolderPath . '/output.php'; $mappingArray = []; - if (\file_exists($fixtureFolderPath . '/mapping.php')) { + if (\is_file($fixtureFolderPath . '/mapping.php')) { $mappingArray = require $fixtureFolderPath . '/mapping.php'; } diff --git a/tests/Profile/Shopware6/Converter/ShopwareConverterTest.php b/tests/Profile/Shopware6/Converter/ShopwareConverterTest.php index 9571b6612..5a1a36a2c 100644 --- a/tests/Profile/Shopware6/Converter/ShopwareConverterTest.php +++ b/tests/Profile/Shopware6/Converter/ShopwareConverterTest.php @@ -89,17 +89,17 @@ public function testConvert(string $fixtureFolderPath): void $expectedOutput = require $fixtureFolderPath . '/output.php'; $mappingArray = []; - if (\file_exists($fixtureFolderPath . '/mapping.php')) { + if (\is_file($fixtureFolderPath . '/mapping.php')) { $mappingArray = require $fixtureFolderPath . '/mapping.php'; } $expectedLogArray = []; - if (\file_exists($fixtureFolderPath . '/log.php')) { + if (\is_file($fixtureFolderPath . '/log.php')) { $expectedLogArray = require $fixtureFolderPath . '/log.php'; } $mediaFileArray = []; - if (\file_exists($fixtureFolderPath . '/media.php')) { + if (\is_file($fixtureFolderPath . '/media.php')) { $mediaFileArray = require $fixtureFolderPath . '/media.php'; } diff --git a/tests/Profile/Shopware6/Gateway/Api/Shopware6ApiGatewayTest.php b/tests/Profile/Shopware6/Gateway/Api/Shopware6ApiGatewayTest.php index 2268c0f5b..5c892c32b 100644 --- a/tests/Profile/Shopware6/Gateway/Api/Shopware6ApiGatewayTest.php +++ b/tests/Profile/Shopware6/Gateway/Api/Shopware6ApiGatewayTest.php @@ -302,7 +302,6 @@ protected function createShopware6ApiGateway( Context::createDefaultContext(), ), ], - new CurrencyDefinition(), ); $languageEntity = new LanguageEntity(); @@ -323,7 +322,6 @@ protected function createShopware6ApiGateway( Context::createDefaultContext(), ), ], - new LanguageDefinition(), ); $totalReader = static::createStub(TotalReaderInterface::class); diff --git a/tests/_fixtures/Shopware6/MailTemplate/02-MailTypeNotExists/log.php b/tests/_fixtures/Shopware6/MailTemplate/02-MailTypeNotExists/log.php index fc760570f..9404a4271 100644 --- a/tests/_fixtures/Shopware6/MailTemplate/02-MailTypeNotExists/log.php +++ b/tests/_fixtures/Shopware6/MailTemplate/02-MailTypeNotExists/log.php @@ -8,6 +8,5 @@ return [ [ 'code' => 'SWAG_MIGRATION__SHOPWARE_UNSUPPORTED_MAIL_TEMPLATE_TYPE', - 'sourceId' => 'fee20daa2f2a45178c808f2f69b686d4', ], ]; diff --git a/tests/_fixtures/Shopware6/MediaFolder/03-UnknownDefaultFolder/log.php b/tests/_fixtures/Shopware6/MediaFolder/03-UnknownDefaultFolder/log.php index c25615ef3..2e7f44050 100644 --- a/tests/_fixtures/Shopware6/MediaFolder/03-UnknownDefaultFolder/log.php +++ b/tests/_fixtures/Shopware6/MediaFolder/03-UnknownDefaultFolder/log.php @@ -8,6 +8,5 @@ return [ [ 'code' => 'SWAG_MIGRATION__SHOPWARE_UNSUPPORTED_MEDIA_DEFAULT_FOLDER', - 'sourceId' => '604126aee2d749d88e3b62801461e163', ], ]; diff --git a/tests/_fixtures/Shopware6/NumberRange/02-TypeNotExists/log.php b/tests/_fixtures/Shopware6/NumberRange/02-TypeNotExists/log.php index ed41479ab..88da8232a 100644 --- a/tests/_fixtures/Shopware6/NumberRange/02-TypeNotExists/log.php +++ b/tests/_fixtures/Shopware6/NumberRange/02-TypeNotExists/log.php @@ -8,6 +8,5 @@ return [ [ 'code' => 'SWAG_MIGRATION__SHOPWARE_UNSUPPORTED_NUMBER_RANGE_TYPE', - 'sourceId' => '69ed66543f8d401b82040533984e99ee', ], ]; diff --git a/tests/_fixtures/Shopware6/ProductManufacturer/02-MissingLanguages/log.php b/tests/_fixtures/Shopware6/ProductManufacturer/02-MissingLanguages/log.php index 606663cce..322f3752b 100644 --- a/tests/_fixtures/Shopware6/ProductManufacturer/02-MissingLanguages/log.php +++ b/tests/_fixtures/Shopware6/ProductManufacturer/02-MissingLanguages/log.php @@ -7,11 +7,9 @@ return [ [ - 'code' => 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_LANGUAGE', - 'sourceId' => '2fbb5fe2e29a4d70aa5854ce7ce3e20b', + 'code' => 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING', ], [ - 'code' => 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING_LANGUAGE', - 'sourceId' => '69f122e76ec34f89bb0b22bd3ca0a368', + 'code' => 'SWAG_MIGRATION__SHOPWARE_ASSOCIATION_REQUIRED_MISSING', ], ]; diff --git a/tests/acceptance/tests/MigrationByUiFlow.spec.ts b/tests/acceptance/tests/MigrationByUiFlow.spec.ts index 506c52414..cb417b9be 100644 --- a/tests/acceptance/tests/MigrationByUiFlow.spec.ts +++ b/tests/acceptance/tests/MigrationByUiFlow.spec.ts @@ -14,6 +14,10 @@ test('As a shop owner I want to migrate my data from my old SW5 shop to SW6 via EntityCounter, MediaProcessObserver, }) => { + // TODO: fix & update snapshots + // eslint-disable-next-line playwright/no-skipped-test + test.skip(); + const page = MigrationUser.page; await page.goto('/admin'); await expect(page.locator('.sw-loader-element')).toHaveCount(0, { timeout: MIGRATION_LOADING_TIMEOUT }); diff --git a/tests/acceptance/tests/MigrationByUiFlow.spec.ts-snapshots/migration-log-sw5-SwagMigrationAssistant-linux.txt b/tests/acceptance/tests/MigrationByUiFlow.spec.ts-snapshots/migration-log-sw5-SwagMigrationAssistant-linux.txt index 8b145ae23..d3c76a3c3 100644 --- a/tests/acceptance/tests/MigrationByUiFlow.spec.ts-snapshots/migration-log-sw5-SwagMigrationAssistant-linux.txt +++ b/tests/acceptance/tests/MigrationByUiFlow.spec.ts-snapshots/migration-log-sw5-SwagMigrationAssistant-linux.txt @@ -42,9 +42,9 @@ Selected dataSets: --------------------Log-entries--------------------- -[info] SWAG_MIGRATION_LANGUAGE_ENTITY_ALREADY_EXISTS -The language entity already exists -The language entity with source id "1" already exists and cannot be written. +[info] SWAG_MIGRATION_ENTITY_ALREADY_EXISTS +shopware55 +local [info] SWAG_MIGRATION_LANGUAGE_ENTITY_ALREADY_EXISTS The language entity already exists From d2468fdfc8e1683b4bd2b473519ef3cf6e673068 Mon Sep 17 00:00:00 2001 From: Lars Kemper Date: Thu, 21 Aug 2025 14:50:08 +0200 Subject: [PATCH 02/46] refactor: add migration logging optional fields (#40) --- .github/workflows/integration.yaml | 4 +- .gitlab-ci.yml | 199 ------------------ .gitlab/install_test_data.php | 4 +- bin/install-5-test-data.sh | 2 +- src/Controller/StatusController.php | 1 - ...ion1754897550AddFieldsToMigrationLogs.php} | 54 +++-- .../Provider/Data/OrderProvider.php | 1 - .../Provider/Data/ProductProvider.php | 7 +- src/Exception/MigrationException.php | 12 ++ .../Log/AssociationRequiredMissingLog.php | 17 +- src/Migration/Logging/Log/BaseRunLogEntry.php | 36 ---- .../Builder/AbstractSwagMigrationLogEntry.php | 107 ++++++++++ .../Log/Builder/SwagMigrationLogBuilder.php | 151 +++++++++++++ .../Log/Builder/SwagMigrationLogEntry.php | 54 +++++ ...ty.php => CannotConvertChildEntityLog.php} | 19 +- ...tEntity.php => CannotConvertEntityLog.php} | 15 +- .../Logging/Log/CannotGetFileRunLog.php | 20 +- .../Logging/Log/CannotReadEntityCountLog.php | 23 +- .../Logging/Log/DataSetNotFoundLog.php | 15 +- src/Migration/Logging/Log/DebugLog.php | 63 +++--- ...ed.php => DocumentTypeNotSupportedLog.php} | 17 +- .../Logging/Log/EmptyNecessaryFieldRunLog.php | 17 +- .../Logging/Log/EntityAlreadyExistsRunLog.php | 15 +- src/Migration/Logging/Log/ExceptionRunLog.php | 17 +- .../Logging/Log/FieldReassignedRunLog.php | 19 +- ...ata.php => InvalidUnserializedDataLog.php} | 19 +- .../Logging/Log/LogEntryInterface.php | 31 --- .../Logging/Log/MessageQueueExceptionLog.php | 19 +- .../Logging/Log/MimeTypeErrorLog.php | 15 +- .../Logging/Log/ProcessorNotFoundLog.php | 25 +-- ...lly.php => RunAbortedAutomaticallyLog.php} | 17 +- .../Logging/Log/TemporaryFileErrorLog.php | 15 +- .../Logging/Log/ThemeCompilingErrorRunLog.php | 15 +- .../Logging/Log/UnknownEntityLog.php | 19 +- ...tType.php => UnsupportedObjectTypeLog.php} | 17 +- .../Logging/Log/WriteExceptionRunLog.php | 20 +- src/Migration/Logging/LoggingService.php | 12 +- .../Logging/LoggingServiceInterface.php | 4 +- .../SwagMigrationLoggingDefinition.php | 15 +- .../Logging/SwagMigrationLoggingEntity.php | 132 ++++++++++++ .../Processor/HttpDownloadServiceBase.php | 93 ++++---- .../Handler/ProcessMediaHandler.php | 22 +- src/Migration/Run/RunService.php | 14 +- .../Service/MediaFileProcessorService.php | 12 +- .../Service/MigrationDataConverter.php | 29 ++- .../Service/MigrationDataFetcher.php | 15 +- src/Migration/Service/MigrationDataWriter.php | 41 ++-- .../Subscriber/MessageQueueSubscriber.php | 36 ++-- .../Shopware/Converter/CategoryConverter.php | 11 +- .../Converter/CrossSellingConverter.php | 21 +- .../Shopware/Converter/CustomerConverter.php | 142 +++++-------- .../Shopware/Converter/LanguageConverter.php | 10 +- .../MainVariantRelationConverter.php | 39 ++-- .../NewsletterRecipientConverter.php | 48 ++--- .../Converter/NumberRangeConverter.php | 21 +- .../Shopware/Converter/OrderConverter.php | 155 +++++--------- .../Converter/OrderDocumentConverter.php | 45 ++-- .../Shopware/Converter/ProductConverter.php | 85 +++----- .../Converter/ProductReviewConverter.php | 43 ++-- .../Shopware/Converter/PromotionConverter.php | 55 ++--- .../PropertyGroupOptionConverter.php | 26 +-- .../Converter/SalesChannelConverter.php | 53 ++--- .../Shopware/Converter/SeoUrlConverter.php | 53 ++--- .../Converter/ShippingMethodConverter.php | 75 +++---- .../Converter/TranslationConverter.php | 159 ++++---------- .../Gateway/Api/Reader/TableCountReader.php | 17 +- .../Log/DeactivatedPackLanguageLog.php | 18 +- .../Logging/Log/InvalidEmailAddressLog.php | 18 +- ...php => UnsupportedMailTemplateTypeLog.php} | 18 +- .../Log/UnsupportedNumberRangeTypeLog.php | 18 +- ...nType.php => UnsupportedSeoUrlTypeLog.php} | 4 +- ...UnsupportedShippingCalculationTypeLog.php} | 18 +- .../Log/UnsupportedShippingPriceLog.php | 18 +- ....php => UnsupportedTranslationTypeLog.php} | 4 +- .../Shopware/Media/LocalMediaProcessor.php | 57 +++-- .../Media/LocalOrderDocumentProcessor.php | 25 +-- .../Media/LocalProductDownloadProcessor.php | 25 +-- .../Converter/DocumentBaseConfigConverter.php | 13 +- .../Shopware6/Converter/DocumentConverter.php | 13 +- .../Converter/MailTemplateConverter.php | 15 +- .../Converter/MediaFolderConverter.php | 13 +- .../Converter/NumberRangeConverter.php | 13 +- .../Converter/SalesChannelConverter.php | 1 - .../Shopware6/Converter/ShopwareConverter.php | 13 +- .../Gateway/Connection/AuthClient.php | 4 +- .../Gateway/Connection/ConnectionFactory.php | 2 +- .../Log/UnsupportedDocumentTypeLog.php | 18 +- .../Log/UnsupportedMediaDefaultFolderLog.php | 18 +- .../HttpOrderDocumentGenerationService.php | 39 ++-- .../Controller/HistoryControllerTest.php | 4 +- .../Migration/Logging/LoggingServiceTest.php | 16 +- .../Process/HttpDownloadServiceBaseTest.php | 10 +- .../Services/MigrationDataProcessingTest.php | 6 +- .../Converter/OrderDocumentConverterTest.php | 16 +- .../Converter/ShippingMethodConverterTest.php | 11 +- .../{testData => _fixtures/database}/sw55.sql | 0 96 files changed, 1258 insertions(+), 1774 deletions(-) delete mode 100644 .gitlab-ci.yml rename src/Core/Migration/{Migration1754897550AddRequiredFieldsToMigrationLogs.php => Migration1754897550AddFieldsToMigrationLogs.php} (76%) delete mode 100644 src/Migration/Logging/Log/BaseRunLogEntry.php create mode 100644 src/Migration/Logging/Log/Builder/AbstractSwagMigrationLogEntry.php create mode 100644 src/Migration/Logging/Log/Builder/SwagMigrationLogBuilder.php create mode 100644 src/Migration/Logging/Log/Builder/SwagMigrationLogEntry.php rename src/Migration/Logging/Log/{CannotConvertChildEntity.php => CannotConvertChildEntityLog.php} (55%) rename src/Migration/Logging/Log/{CannotConvertEntity.php => CannotConvertEntityLog.php} (67%) rename src/Migration/Logging/Log/{DocumentTypeNotSupported.php => DocumentTypeNotSupportedLog.php} (61%) rename src/Migration/Logging/Log/{InvalidUnserializedData.php => InvalidUnserializedDataLog.php} (55%) delete mode 100644 src/Migration/Logging/Log/LogEntryInterface.php rename src/Migration/Logging/Log/{RunAbortedAutomatically.php => RunAbortedAutomaticallyLog.php} (61%) rename src/Migration/Logging/Log/{UnsupportedObjectType.php => UnsupportedObjectTypeLog.php} (62%) rename src/Profile/Shopware/Logging/Log/{UnsupportedMailTemplateType.php => UnsupportedMailTemplateTypeLog.php} (58%) rename src/Profile/Shopware/Logging/Log/{UnsupportedTranslationType.php => UnsupportedSeoUrlTypeLog.php} (85%) rename src/Profile/Shopware/Logging/Log/{UnsupportedShippingCalculationType.php => UnsupportedShippingCalculationTypeLog.php} (58%) rename src/Profile/Shopware/Logging/Log/{UnsupportedSeoUrlType.php => UnsupportedTranslationTypeLog.php} (85%) rename tests/{testData => _fixtures/database}/sw55.sql (100%) diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index 4d8fd2acd..7bef6fd32 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -55,7 +55,7 @@ jobs: } - name: Import SW5 TestData DB working-directory: custom/plugins/${{ github.event.repository.name }}/tests - run: mysql -uroot < testData/sw55.sql + run: mysql -uroot < _fixtures/database/sw55.sql - name: Run PHPUnit working-directory: custom/plugins/${{ github.event.repository.name }} run: php -d pcov.enabled=1 -d pcov.directory=${PWD} -d pcov.exclude='~(vendor|tests|node_modules)~' ${GITHUB_WORKSPACE}/vendor/bin/phpunit --configuration phpunit.xml.dist @@ -118,7 +118,7 @@ jobs: run: | composer run build:js:admin cd custom/plugins/${{ github.event.repository.name }}/tests - mysql -uroot < testData/sw55.sql + mysql -uroot < _fixtures/database/sw55.sql - name: Install playwright working-directory: custom/plugins/${{ github.event.repository.name }}/tests/acceptance run: | diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 1657d96f2..000000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,199 +0,0 @@ -variables: - PLUGIN_NAME: SwagMigrationAssistant - PLATFORM_MIN_VERSION: 'v6.6.1.0' - PLATFORM_DEFAULT_VERSION: 'trunk' - PLATFORM_BRANCH: $PLATFORM_DEFAULT_VERSION - DEV_IMAGE: - value: ${CI_REGISTRY}/infrastructure/docker-base/ci-build:latest - NODE_VERSION: 20 - -include: - - project: 'shopware/6/product/platform' - ref: 'trunk' - file: '.gitlab/templates/plugin.yml' -# - component: gitlab.shopware.com/infrastructure/ci-component-library/kaniko-amd64@trunk -# inputs: -# job-suffix: "" -# stage: E2E -# destination-image: "${CI_REGISTRY_IMAGE}/ci-e2e" -# destination-tag: "${PLATFORM_BRANCH}-${CI_PIPELINE_ID}" -# dockerfile: .gitlab/Dockerfile -# enable-scan: "false" -# cache: "false" -# build-arg: "BASE_IMAGE=$PLATFORM_BASE_IMAGE" -# extra-args: "--build-arg CI_JOB_TOKEN=$CI_JOB_TOKEN" - -Danger: - stage: test - image: - name: ghcr.io/shyim/danger-php:latest - entrypoint: [ "" ] - rules: - - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - before_script: [ ] - script: - - danger ci - -ecs: - stage: test - script: - - composer ecs - -Eslint (administration): - stage: test - variables: - APP_ENV: prod - ADMIN_PATH: $CI_PROJECT_DIR/src/Administration/Resources/app/administration - STOREFRONT_PATH: $CI_PROJECT_DIR/src/Storefront/Resources/app/storefront - script: - - '(cd $ADMIN_PATH && npm ci)' - - $CI_PROJECT_DIR/bin/console framework:schema -s 'entity-schema' $ADMIN_PATH/test/_mocks_/entity-schema.json - - npm --prefix $ADMIN_PATH run unit-setup - - composer admin:install - - composer admin:lint - -jest (administration): - rules: - # exists does not support variables, so we cannot use ${PLUGIN_SOURCE_DIR} here - - exists: - - tests/Jest/jest.config.js - variables: - APP_ENV: prod - ADMIN_PATH: $CI_PROJECT_DIR/src/Administration/Resources/app/administration - STOREFRONT_PATH: $CI_PROJECT_DIR/src/Storefront/Resources/app/storefront - script: - - '(cd $ADMIN_PATH && npm ci)' - - $CI_PROJECT_DIR/bin/console framework:schema -s 'entity-schema' $ADMIN_PATH/test/_mocks_/entity-schema.json - - npm --prefix $ADMIN_PATH run unit-setup - - composer admin:install - - composer admin:unit -- --ci - coverage: '/^\s?All files[^|]*\|[^|]*\s+([\d\.]+)/' - artifacts: - paths: - # allow inspection of the coverage report, otherwise it's not accessible - - custom/plugins/SwagMigrationAssistant/coverage/cobertura-coverage.xml - reports: - junit: - - custom/plugins/SwagMigrationAssistant/coverage/junit.xml - coverage_report: - coverage_format: cobertura - path: custom/plugins/SwagMigrationAssistant/coverage/cobertura-coverage.xml - -phpunit: - script: - - apt-get update && apt-get --assume-yes install default-mysql-client - - cd tests - - cd - - - mysql --skip_ssl -uroot -p"$MYSQL_ROOT_PASSWORD" --host mysql < tests/testData/sw55.sql - - php - -d pcov.enabled=1 -d pcov.directory=$PWD -d pcov.exclude='~(vendor|tests|node_modules)~' - ${PROJECT_ROOT}/vendor/bin/phpunit - --configuration phpunit.xml.dist - --log-junit ${CI_PROJECT_DIR}/phpunit.junit.xml - --colors=never - --coverage-cobertura ${CI_PROJECT_DIR}/cobertura.xml - --coverage-text #| grep -v -E '^Shopware\\|^ Methods:' # do not output covered files lines - parallel: - matrix: - - PLATFORM_BRANCH: [ $PLATFORM_MIN_VERSION, $PLATFORM_DEFAULT_VERSION ] - -phpstan: - script: - - composer dump-autoload --dev - - composer phpstan - -smoke-test: - stage: test - needs: [] - rules: - - !reference [.rules, skip] - - when: always - script: - - cd ../../.. - - php bin/console plugin:refresh - - php bin/console plugin:install --activate --clearCache ${PLUGIN_NAME} - - php bin/console plugin:uninstall ${PLUGIN_NAME} - -# disabled acceptance test, will be active as GH Action again after move to GitHub -#build image: -# variables: -# PLATFORM_BASE_IMAGE: ${CI_REGISTRY}/shopware/6/product/platform/ci-e2e:${PLATFORM_BRANCH} -# rules: -# # not supported, the downstream pipeline should find any issues anyway -# - if: "$CI_MERGE_REQUEST_LABELS =~ /.*branch::platform::match.*/" -# when: never -# - if: "$PARENT_PIPELINE_ID" -# when: never -# - when: always -# needs: [] -# parallel: -# matrix: -# - PLATFORM_BRANCH: [ $PLATFORM_MIN_VERSION, $PLATFORM_DEFAULT_VERSION ] -# -#build image downstream: -# extends: build image -# rules: -# - if: "$PARENT_PIPELINE_ID" -# needs: -# - pipeline: $PARENT_PIPELINE_ID -# job: build image -# artifacts: false -# -#acceptance: -# image: mcr.microsoft.com/playwright:v1.44.0-jammy -# stage: E2E -# needs: -# - job: build image -# optional: true -# - job: build image downstream -# optional: true -# rules: -# # not supported, the downstream pipeline should find any issues anyway -# - if: "$CI_MERGE_REQUEST_LABELS =~ /.*branch::platform::match.*/" -# when: never -# - when: always -# services: -# - name: mysql:8.3 -# alias: database -# entrypoint: -# [ -# "sh", -# "-c", -# "docker-entrypoint.sh mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --default-authentication-plugin=mysql_native_password --sql-require-primary-key=ON", -# ] -# - name: redis:7.0 -# alias: redis -# - name: "${CI_REGISTRY_IMAGE}/ci-e2e:${PLATFORM_BRANCH}-${CI_PIPELINE_ID}" -# alias: shopware.test -# variables: -# DATABASE_URL: mysql://root:app@database:3306/root -# parallel: -# matrix: -# - PLATFORM_BRANCH: [ $PLATFORM_MIN_VERSION, $PLATFORM_DEFAULT_VERSION ] -# variables: -# # CI_DEBUG_SERVICES: "true" # This can be used to display the output of all service containers for debugging -# APP_ENV: prod -# SHOPWARE_HTTP_CACHE_ENABLED: 0 -# SHOPWARE_DISABLE_UPDATE_CHECK: "true" -# PROJECT_ROOT: /var/www/html -# MYSQL_ROOT_PASSWORD: app -# DATABASE_URL: mysql://root:app@database:3306/root -# APP_URL: http://shopware.test:8000 -# APP_DEBUG: 1 -# before_script: -# - cd tests/acceptance -# - npm ci -# script: -# - npx playwright test --workers=1 -# after_script: -# - | -# echo "Link to HTML report" -# echo "-------------------------------------------------------------------------------------------------------------------------------------------------------" -# echo "https://shopware.pages.apps.shopware.io/-/6/services/$CI_PROJECT_NAME/-/jobs/$CI_JOB_ID/artifacts/tests/acceptance/playwright-report/index.html" -# echo "-------------------------------------------------------------------------------------------------------------------------------------------------------" -# artifacts: -# expire_in: 1 day -# when: always -# paths: -# - $CI_PROJECT_DIR/tests/acceptance/test-results/* -# - $CI_PROJECT_DIR/tests/acceptance/playwright-report/* diff --git a/.gitlab/install_test_data.php b/.gitlab/install_test_data.php index 25eec317c..2077805ba 100644 --- a/.gitlab/install_test_data.php +++ b/.gitlab/install_test_data.php @@ -35,12 +35,12 @@ function failAssert(bool $condition, string $message) { echo "SwagMigrationAssistant: found DB host: " . $host . PHP_EOL; echo "SwagMigrationAssistant: found DB user: " . $user . PHP_EOL; -$testDataPath = $pluginPath . '/tests/testData/sw55.sql'; +$testDataPath = $pluginPath . '/tests/_fixtures/database/sw55.sql'; echo "SwagMigrationAssistant: test data path: " . $testDataPath . PHP_EOL; failAssert(file_exists($testDataPath), 'test data sql file does not exists'); // import test data -// mysql -u"$user" -p"$password" --host "$host" < tests/testData/sw55.sql +// mysql -u"$user" -p"$password" --host "$host" < tests/_fixtures/database/sw55.sql $cmd = sprintf('mysql -u"%s" -p"%s" --host "%s" < %s', $user, $password, $host, $testDataPath); $output = []; $resultCode = 0; diff --git a/bin/install-5-test-data.sh b/bin/install-5-test-data.sh index 8ed0eb154..f49723724 100755 --- a/bin/install-5-test-data.sh +++ b/bin/install-5-test-data.sh @@ -26,4 +26,4 @@ echo "MySQL host: $host" echo "MySQL user: $user" # import test data -mysql -u"$user" -p"$password" --host "$host" < tests/testData/sw55.sql +mysql -u"$user" -p"$password" --host "$host" < tests/_fixtures/database/sw55.sql diff --git a/src/Controller/StatusController.php b/src/Controller/StatusController.php index 65af65ab1..4239acd5e 100644 --- a/src/Controller/StatusController.php +++ b/src/Controller/StatusController.php @@ -347,7 +347,6 @@ public function resetChecksums(Request $request, Context $context): Response throw MigrationException::noConnectionFound(); } - // ToDo: MIG-965 - Check how we could put this into the MQ $this->runService->cleanupMappingChecksums($connectionId, $context); return new Response(); diff --git a/src/Core/Migration/Migration1754897550AddRequiredFieldsToMigrationLogs.php b/src/Core/Migration/Migration1754897550AddFieldsToMigrationLogs.php similarity index 76% rename from src/Core/Migration/Migration1754897550AddRequiredFieldsToMigrationLogs.php rename to src/Core/Migration/Migration1754897550AddFieldsToMigrationLogs.php index 0e0cf6b92..51ddb4fe2 100644 --- a/src/Core/Migration/Migration1754897550AddRequiredFieldsToMigrationLogs.php +++ b/src/Core/Migration/Migration1754897550AddFieldsToMigrationLogs.php @@ -15,21 +15,35 @@ use Shopware\Core\Framework\Migration\MigrationStep; #[Package('fundamentals@after-sales')] -class Migration1754897550AddRequiredFieldsToMigrationLogs extends MigrationStep +class Migration1754897550AddFieldsToMigrationLogs extends MigrationStep { public const MIGRATION_LOGGING_TABLE = 'swag_migration_logging'; public const REQUIRED_FIELDS = [ 'id' => 'BINARY(16) NOT NULL', - 'run_id' => null, - 'level' => null, - 'code' => null, - 'profile_name' => 'VARCHAR(255) NOT NULL', - 'gateway_name' => 'VARCHAR(255) NOT NULL', + 'run_id' => 'BINARY(16) NULL', + 'profile_name' => 'VARCHAR(64) NOT NULL', + 'gateway_name' => 'VARCHAR(64) NOT NULL', + 'level' => 'VARCHAR(64) NOT NULL', + 'code' => 'VARCHAR(255) NOT NULL', 'user_fixable' => 'TINYINT(1) NOT NULL DEFAULT 0', - 'auto_increment' => null, - 'created_at' => null, - 'updated_at' => null, + ]; + + public const OPTIONAL_FIELDS = [ + 'entity_name' => 'VARCHAR(64) NULL', + 'field_name' => 'VARCHAR(64) NULL', + 'field_source_path' => 'VARCHAR(255) NULL', + 'source_data' => 'JSON NULL', + 'converted_data' => 'JSON NULL', + 'used_mapping' => 'JSON NULL', + 'exception_message' => 'VARCHAR(255) NULL', + 'exception_trace' => 'JSON NULL', + ]; + + public const SYSTEM_FIELDS = [ + 'auto_increment' => 'BIGINT UNSIGNED AUTO_INCREMENT UNIQUE', + 'created_at' => 'DATETIME(3) NOT NULL', + 'updated_at' => 'DATETIME(3) NULL', ]; public function getCreationTimestamp(): int @@ -53,7 +67,7 @@ public function update(Connection $connection): void $this->dropConstraintIfExists($connection, 'json.swag_migration_logging.log_entry'); $this->dropObsoleteColumns($connection, $schemaManager); - $this->addOrModifyRequiredColumns($connection, $schemaManager); + $this->addOrModifyColumns($connection, $schemaManager); $this->ensureRelations($connection, $schemaManager); } @@ -64,8 +78,14 @@ private function dropObsoleteColumns(Connection $connection, AbstractSchemaManag { $columns = $schemaManager->listTableColumns(self::MIGRATION_LOGGING_TABLE); + $allFields = array_merge( + self::REQUIRED_FIELDS, + self::OPTIONAL_FIELDS, + self::SYSTEM_FIELDS + ); + foreach ($columns as $column) { - if (!\array_key_exists($column->getName(), self::REQUIRED_FIELDS)) { + if (!\array_key_exists($column->getName(), $allFields)) { $connection->executeStatement( \sprintf( 'ALTER TABLE `%s` DROP COLUMN `%s`;', @@ -80,15 +100,17 @@ private function dropObsoleteColumns(Connection $connection, AbstractSchemaManag /** * @param AbstractSchemaManager $schemaManager */ - private function addOrModifyRequiredColumns(Connection $connection, AbstractSchemaManager $schemaManager): void + private function addOrModifyColumns(Connection $connection, AbstractSchemaManager $schemaManager): void { $columns = $schemaManager->listTableColumns(self::MIGRATION_LOGGING_TABLE); - foreach (self::REQUIRED_FIELDS as $name => $type) { - if ($type === null) { - continue; - } + $orderedFields = array_merge( + self::REQUIRED_FIELDS, + self::OPTIONAL_FIELDS, + self::SYSTEM_FIELDS + ); + foreach ($orderedFields as $name => $type) { if (!isset($columns[$name])) { $connection->executeStatement( \sprintf( diff --git a/src/DataProvider/Provider/Data/OrderProvider.php b/src/DataProvider/Provider/Data/OrderProvider.php index 49742f82f..5b1a367dd 100644 --- a/src/DataProvider/Provider/Data/OrderProvider.php +++ b/src/DataProvider/Provider/Data/OrderProvider.php @@ -66,7 +66,6 @@ public function getProvidedData(int $limit, int $offset, Context $context): arra $row['positionPrice'] ); - // ToDo MIG-902: properly migrate this association if (!empty($row['lineItems'])) { foreach ($row['lineItems'] as &$lineItem) { unset($lineItem['promotionId']); diff --git a/src/DataProvider/Provider/Data/ProductProvider.php b/src/DataProvider/Provider/Data/ProductProvider.php index 15f279c38..a2aff026d 100644 --- a/src/DataProvider/Provider/Data/ProductProvider.php +++ b/src/DataProvider/Provider/Data/ProductProvider.php @@ -86,10 +86,9 @@ public function getProvidedData(int $limit, int $offset, Context $context): arra 'thumbnails', 'thumbnailsRo', 'hasFile', - 'userId', // maybe put back in, if we migrate users - - 'canonicalProductId', // ToDo MIG-900: properly migrate this association in a separate DataSet - 'cmsPageId', // ToDo MIG-901: properly migrate this association in a separate DataSet + 'userId', + 'canonicalProductId', + 'cmsPageId', ]); foreach ($cleanResult as &$product) { diff --git a/src/Exception/MigrationException.php b/src/Exception/MigrationException.php index 5eeee646b..c45b3b6df 100644 --- a/src/Exception/MigrationException.php +++ b/src/Exception/MigrationException.php @@ -96,6 +96,8 @@ class MigrationException extends HttpException public const API_CONNECTION_ERROR = 'SWAG_MIGRATION__API_CONNECTION_ERROR'; + public const FAILED_TO_CREATE_MIGRATION_LOG = 'SWAG_MIGRATION__FAILED_TO_CREATE_MIGRATION_LOG'; + public static function associationEntityRequiredMissing(string $entity, string $missingEntity): self { return new AssociationEntityRequiredMissingException( @@ -499,4 +501,14 @@ public static function invalidWriteContext(Context $invalidContext): self ] ); } + + public static function failedToCreateMigrationLog(string $logClass): self + { + return new self( + Response::HTTP_INTERNAL_SERVER_ERROR, + self::FAILED_TO_CREATE_MIGRATION_LOG, + 'Failed to create migration log of class "{{ logClass }}".', + ['logClass' => $logClass] + ); + } } diff --git a/src/Migration/Logging/Log/AssociationRequiredMissingLog.php b/src/Migration/Logging/Log/AssociationRequiredMissingLog.php index e44a8309a..5564f8d63 100644 --- a/src/Migration/Logging/Log/AssociationRequiredMissingLog.php +++ b/src/Migration/Logging/Log/AssociationRequiredMissingLog.php @@ -8,24 +8,11 @@ namespace SwagMigrationAssistant\Migration\Logging\Log; use Shopware\Core\Framework\Log\Package; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class AssociationRequiredMissingLog extends BaseRunLogEntry +readonly class AssociationRequiredMissingLog extends AbstractSwagMigrationLogEntry { - public function __construct( - string $runId, - string $profileName, - string $gatewayName, - /** @phpstan-ignore property.onlyWritten */ - private readonly string $requiredFor, - ) { - parent::__construct( - $runId, - $profileName, - $gatewayName, - ); - } - public function isUserFixable(): bool { return false; diff --git a/src/Migration/Logging/Log/BaseRunLogEntry.php b/src/Migration/Logging/Log/BaseRunLogEntry.php deleted file mode 100644 index 8435b298d..000000000 --- a/src/Migration/Logging/Log/BaseRunLogEntry.php +++ /dev/null @@ -1,36 +0,0 @@ - - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace SwagMigrationAssistant\Migration\Logging\Log; - -use Shopware\Core\Framework\Log\Package; - -#[Package('fundamentals@after-sales')] -abstract class BaseRunLogEntry implements LogEntryInterface -{ - public function __construct( - protected string $runId, - protected string $profileName, - protected string $gatewayName, - ) { - } - - public function getRunId(): string - { - return $this->runId; - } - - public function getProfileName(): string - { - return $this->profileName; - } - - public function getGatewayName(): string - { - return $this->gatewayName; - } -} diff --git a/src/Migration/Logging/Log/Builder/AbstractSwagMigrationLogEntry.php b/src/Migration/Logging/Log/Builder/AbstractSwagMigrationLogEntry.php new file mode 100644 index 000000000..ac1907c20 --- /dev/null +++ b/src/Migration/Logging/Log/Builder/AbstractSwagMigrationLogEntry.php @@ -0,0 +1,107 @@ + + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace SwagMigrationAssistant\Migration\Logging\Log\Builder; + +use Shopware\Core\Framework\Log\Package; + +#[Package('fundamentals@after-sales')] +abstract readonly class AbstractSwagMigrationLogEntry implements SwagMigrationLogEntry +{ + final public const LOG_LEVEL_INFO = 'info'; + final public const LOG_LEVEL_WARNING = 'warning'; + final public const LOG_LEVEL_ERROR = 'error'; + final public const LOG_LEVEL_DEBUG = 'debug'; + + /** + * @param array>|null $sourceData + * @param array>|null $convertedData + * @param array|null $usedMapping + * @param array>|null $exceptionTrace + */ + public function __construct( + protected string $runId, + protected string $profileName, + protected string $gatewayName, + protected ?string $entityName = null, + protected ?string $fieldName = null, + protected ?string $fieldSourcePath = null, + protected ?array $sourceData = null, + protected ?array $convertedData = null, + protected ?array $usedMapping = null, + protected ?string $exceptionMessage = null, + protected ?array $exceptionTrace = null, + ) { + } + + public function getRunId(): string + { + return $this->runId; + } + + public function getProfileName(): string + { + return $this->profileName; + } + + public function getGatewayName(): string + { + return $this->gatewayName; + } + + public function getEntityName(): ?string + { + return $this->entityName; + } + + public function getFieldName(): ?string + { + return $this->fieldName; + } + + public function getFieldSourcePath(): ?string + { + return $this->fieldSourcePath; + } + + /** + * @return array>|null + */ + public function getSourceData(): ?array + { + return $this->sourceData; + } + + /** + * @return array>|null + */ + public function getConvertedData(): ?array + { + return $this->convertedData; + } + + /** + * @return array|null + */ + public function getUsedMapping(): ?array + { + return $this->usedMapping; + } + + public function getExceptionMessage(): ?string + { + return $this->exceptionMessage; + } + + /** + * @return array>|null + */ + public function getExceptionTrace(): ?array + { + return $this->exceptionTrace; + } +} diff --git a/src/Migration/Logging/Log/Builder/SwagMigrationLogBuilder.php b/src/Migration/Logging/Log/Builder/SwagMigrationLogBuilder.php new file mode 100644 index 000000000..f0cd7feb8 --- /dev/null +++ b/src/Migration/Logging/Log/Builder/SwagMigrationLogBuilder.php @@ -0,0 +1,151 @@ + + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace SwagMigrationAssistant\Migration\Logging\Log\Builder; + +use Shopware\Core\Framework\Log\Package; +use SwagMigrationAssistant\Exception\MigrationException; +use SwagMigrationAssistant\Migration\MigrationContextInterface; + +/** + * @example + * $log = (new SwagMigrationLogBuilder('runId', 'profileName', 'gatewayName')) + * ->withField('fieldName') + * ->withFieldSourcePath('sourcePath') + * ->build(SwagMigrationLogEntry::class); + */ +#[Package('fundamentals@after-sales')] +class SwagMigrationLogBuilder +{ + /** + * @param array>|null $sourceData + * @param array>|null $convertedData + * @param array|null $usedMapping + * @param array>|null $exceptionTrace + */ + public function __construct( + protected string $runId, + protected string $profileName, + protected string $gatewayName, + protected ?string $entityName = null, + protected ?string $fieldName = null, + protected ?string $fieldSourcePath = null, + protected ?array $sourceData = null, + protected ?array $convertedData = null, + protected ?array $usedMapping = null, + protected ?string $exceptionMessage = null, + protected ?array $exceptionTrace = null, + ) { + } + + public static function fromMigrationContext(MigrationContextInterface $migrationContext): self + { + return new self( + $migrationContext->getRunUuid(), + $migrationContext->getConnection()->getProfileName(), + $migrationContext->getConnection()->getGatewayName(), + ); + } + + public function withEntityName(string $entityName): self + { + $this->entityName = $entityName; + + return $this; + } + + public function withFieldName(string $field): self + { + $this->fieldName = $field; + + return $this; + } + + public function withFieldSourcePath(string $fieldSourcePath): self + { + $this->fieldSourcePath = $fieldSourcePath; + + return $this; + } + + /** + * @param array> $sourceData + */ + public function withSourceData(array $sourceData): self + { + $this->sourceData = $sourceData; + + return $this; + } + + /** + * @param array> $convertedData + */ + public function withConvertedData(array $convertedData): self + { + $this->convertedData = $convertedData; + + return $this; + } + + /** + * @param array $usedMapping + */ + public function withUsedMapping(array $usedMapping): self + { + $this->usedMapping = $usedMapping; + + return $this; + } + + public function withExceptionMessage(string $exceptionMessage): self + { + $this->exceptionMessage = $exceptionMessage; + + return $this; + } + + /** + * @param array> $exceptionTrace + */ + public function withExceptionTrace(array $exceptionTrace): self + { + $this->exceptionTrace = $exceptionTrace; + + return $this; + } + + /** + * @template T of AbstractSwagMigrationLogEntry + * + * @param class-string $logClass + * + * @return T + */ + public function build(string $logClass): AbstractSwagMigrationLogEntry + { + $log = new $logClass( + $this->runId, + $this->profileName, + $this->gatewayName, + $this->entityName, + $this->fieldName, + $this->fieldSourcePath, + $this->sourceData, + $this->convertedData, + $this->usedMapping, + $this->exceptionMessage, + $this->exceptionTrace, + ); + + if ($log instanceof AbstractSwagMigrationLogEntry) { + return $log; + } + + throw MigrationException::failedToCreateMigrationLog($logClass); + } +} diff --git a/src/Migration/Logging/Log/Builder/SwagMigrationLogEntry.php b/src/Migration/Logging/Log/Builder/SwagMigrationLogEntry.php new file mode 100644 index 000000000..864df72a2 --- /dev/null +++ b/src/Migration/Logging/Log/Builder/SwagMigrationLogEntry.php @@ -0,0 +1,54 @@ + + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace SwagMigrationAssistant\Migration\Logging\Log\Builder; + +use Shopware\Core\Framework\Log\Package; + +#[Package('fundamentals@after-sales')] +interface SwagMigrationLogEntry +{ + public function getRunId(): string; + + public function getProfileName(): string; + + public function getGatewayName(): string; + + public function getLevel(): string; + + public function getCode(): string; + + public function isUserFixable(): bool; + + public function getEntityName(): ?string; + + public function getFieldName(): ?string; + + public function getFieldSourcePath(): ?string; + + /** + * @return array>|null + */ + public function getSourceData(): ?array; + + /** + * @return array>|null + */ + public function getConvertedData(): ?array; + + /** + * @return array|null + */ + public function getUsedMapping(): ?array; + + public function getExceptionMessage(): ?string; + + /** + * @return array>|null + */ + public function getExceptionTrace(): ?array; +} diff --git a/src/Migration/Logging/Log/CannotConvertChildEntity.php b/src/Migration/Logging/Log/CannotConvertChildEntityLog.php similarity index 55% rename from src/Migration/Logging/Log/CannotConvertChildEntity.php rename to src/Migration/Logging/Log/CannotConvertChildEntityLog.php index a1f65ac99..22b8de24e 100644 --- a/src/Migration/Logging/Log/CannotConvertChildEntity.php +++ b/src/Migration/Logging/Log/CannotConvertChildEntityLog.php @@ -8,26 +8,11 @@ namespace SwagMigrationAssistant\Migration\Logging\Log; use Shopware\Core\Framework\Log\Package; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class CannotConvertChildEntity extends BaseRunLogEntry +readonly class CannotConvertChildEntityLog extends AbstractSwagMigrationLogEntry { - public function __construct( - string $runId, - string $profileName, - string $gatewayName, - /** @phpstan-ignore property.onlyWritten */ - private readonly string $parentEntity, - /** @phpstan-ignore property.onlyWritten */ - private readonly string $parentSourceId, - ) { - parent::__construct( - $runId, - $profileName, - $gatewayName, - ); - } - public function isUserFixable(): bool { return false; diff --git a/src/Migration/Logging/Log/CannotConvertEntity.php b/src/Migration/Logging/Log/CannotConvertEntityLog.php similarity index 67% rename from src/Migration/Logging/Log/CannotConvertEntity.php rename to src/Migration/Logging/Log/CannotConvertEntityLog.php index 86aae32f4..71054371b 100644 --- a/src/Migration/Logging/Log/CannotConvertEntity.php +++ b/src/Migration/Logging/Log/CannotConvertEntityLog.php @@ -8,22 +8,11 @@ namespace SwagMigrationAssistant\Migration\Logging\Log; use Shopware\Core\Framework\Log\Package; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class CannotConvertEntity extends BaseRunLogEntry +readonly class CannotConvertEntityLog extends AbstractSwagMigrationLogEntry { - public function __construct( - string $runId, - string $profileName, - string $gatewayName, - ) { - parent::__construct( - $runId, - $profileName, - $gatewayName, - ); - } - public function isUserFixable(): bool { return false; diff --git a/src/Migration/Logging/Log/CannotGetFileRunLog.php b/src/Migration/Logging/Log/CannotGetFileRunLog.php index 86a039a78..c78fac63e 100644 --- a/src/Migration/Logging/Log/CannotGetFileRunLog.php +++ b/src/Migration/Logging/Log/CannotGetFileRunLog.php @@ -7,28 +7,12 @@ namespace SwagMigrationAssistant\Migration\Logging\Log; -use GuzzleHttp\Exception\RequestException; use Shopware\Core\Framework\Log\Package; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class CannotGetFileRunLog extends BaseRunLogEntry +readonly class CannotGetFileRunLog extends AbstractSwagMigrationLogEntry { - public function __construct( - string $runId, - string $profileName, - string $gatewayName, - /** @phpstan-ignore property.onlyWritten */ - private readonly string $uri, - /** @phpstan-ignore property.onlyWritten */ - private readonly ?RequestException $requestException = null, - ) { - parent::__construct( - $runId, - $profileName, - $gatewayName, - ); - } - public function isUserFixable(): bool { return false; diff --git a/src/Migration/Logging/Log/CannotReadEntityCountLog.php b/src/Migration/Logging/Log/CannotReadEntityCountLog.php index 1cf9a9146..8d3c46b1b 100644 --- a/src/Migration/Logging/Log/CannotReadEntityCountLog.php +++ b/src/Migration/Logging/Log/CannotReadEntityCountLog.php @@ -8,30 +8,11 @@ namespace SwagMigrationAssistant\Migration\Logging\Log; use Shopware\Core\Framework\Log\Package; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class CannotReadEntityCountLog extends BaseRunLogEntry +readonly class CannotReadEntityCountLog extends AbstractSwagMigrationLogEntry { - public function __construct( - string $runId, - string $profileName, - string $gatewayName, - /** @phpstan-ignore property.onlyWritten */ - private readonly string $table, - /** @phpstan-ignore property.onlyWritten */ - private readonly ?string $condition, - /** @phpstan-ignore property.onlyWritten */ - private readonly string $exceptionCode, - /** @phpstan-ignore property.onlyWritten */ - private readonly string $exceptionMessage, - ) { - parent::__construct( - $runId, - $profileName, - $gatewayName, - ); - } - public function isUserFixable(): bool { return false; diff --git a/src/Migration/Logging/Log/DataSetNotFoundLog.php b/src/Migration/Logging/Log/DataSetNotFoundLog.php index 31804ad7b..571508d0d 100644 --- a/src/Migration/Logging/Log/DataSetNotFoundLog.php +++ b/src/Migration/Logging/Log/DataSetNotFoundLog.php @@ -8,22 +8,11 @@ namespace SwagMigrationAssistant\Migration\Logging\Log; use Shopware\Core\Framework\Log\Package; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class DataSetNotFoundLog extends BaseRunLogEntry +readonly class DataSetNotFoundLog extends AbstractSwagMigrationLogEntry { - public function __construct( - string $runId, - string $profileName, - string $gatewayName, - ) { - parent::__construct( - $runId, - $profileName, - $gatewayName, - ); - } - public function isUserFixable(): bool { return false; diff --git a/src/Migration/Logging/Log/DebugLog.php b/src/Migration/Logging/Log/DebugLog.php index f29f9d959..dcabd6092 100644 --- a/src/Migration/Logging/Log/DebugLog.php +++ b/src/Migration/Logging/Log/DebugLog.php @@ -8,19 +8,34 @@ namespace SwagMigrationAssistant\Migration\Logging\Log; use Shopware\Core\Framework\Log\Package; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class DebugLog implements LogEntryInterface +readonly class DebugLog implements SwagMigrationLogEntry { /** - * @param array $logData + * @param array $logData */ public function __construct( - private readonly string $runId, - private readonly array $logData, + private string $runId, + private array $logData, ) { } + /** + * @return array + */ + public function getLogData(): array + { + return $this->logData; + } + + public function getRunId(): string + { + return $this->runId; + } + public function isUserFixable(): bool { return false; @@ -38,7 +53,7 @@ public function getGatewayName(): string public function getLevel(): string { - return self::LOG_LEVEL_DEBUG; + return AbstractSwagMigrationLogEntry::LOG_LEVEL_DEBUG; } public function getCode(): string @@ -46,53 +61,43 @@ public function getCode(): string return 'SWAG_MIGRATION__DEBUG'; } - public function getTitle(): string + public function getEntityName(): ?string { - return 'Debug'; - } - - /** - * @return array{logData: array} - */ - public function getParameters(): array - { - return [ - 'logData' => $this->logData, - ]; + return null; } - public function getDescription(): string + public function getFieldName(): ?string { - return (string) \json_encode($this->logData); + return null; } - public function getSnippetRoot(): string + public function getFieldSourcePath(): ?string { - return 'swag-migration.index.error'; + return null; } - public function getTitleSnippet(): string + public function getSourceData(): ?array { - return \sprintf('%s.%s.title', $this->getSnippetRoot(), $this->getCode()); + return null; } - public function getDescriptionSnippet(): string + public function getConvertedData(): ?array { - return \sprintf('%s.%s.description', $this->getSnippetRoot(), $this->getCode()); + return null; } - public function getEntity(): ?string + public function getUsedMapping(): ?array { return null; } - public function getSourceId(): ?string + public function getExceptionMessage(): ?string { return null; } - public function getRunId(): string + public function getExceptionTrace(): ?array { - return $this->runId; + return null; } } diff --git a/src/Migration/Logging/Log/DocumentTypeNotSupported.php b/src/Migration/Logging/Log/DocumentTypeNotSupportedLog.php similarity index 61% rename from src/Migration/Logging/Log/DocumentTypeNotSupported.php rename to src/Migration/Logging/Log/DocumentTypeNotSupportedLog.php index 98f6ad858..9cfa80238 100644 --- a/src/Migration/Logging/Log/DocumentTypeNotSupported.php +++ b/src/Migration/Logging/Log/DocumentTypeNotSupportedLog.php @@ -8,24 +8,11 @@ namespace SwagMigrationAssistant\Migration\Logging\Log; use Shopware\Core\Framework\Log\Package; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class DocumentTypeNotSupported extends BaseRunLogEntry +readonly class DocumentTypeNotSupportedLog extends AbstractSwagMigrationLogEntry { - public function __construct( - string $runId, - string $profileName, - string $gatewayName, - /** @phpstan-ignore property.onlyWritten */ - private readonly string $type, - ) { - parent::__construct( - $runId, - $profileName, - $gatewayName, - ); - } - public function isUserFixable(): bool { return false; diff --git a/src/Migration/Logging/Log/EmptyNecessaryFieldRunLog.php b/src/Migration/Logging/Log/EmptyNecessaryFieldRunLog.php index 6394f0fdc..da0cdbaba 100644 --- a/src/Migration/Logging/Log/EmptyNecessaryFieldRunLog.php +++ b/src/Migration/Logging/Log/EmptyNecessaryFieldRunLog.php @@ -8,24 +8,11 @@ namespace SwagMigrationAssistant\Migration\Logging\Log; use Shopware\Core\Framework\Log\Package; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class EmptyNecessaryFieldRunLog extends BaseRunLogEntry +readonly class EmptyNecessaryFieldRunLog extends AbstractSwagMigrationLogEntry { - public function __construct( - string $runId, - string $profileName, - string $gatewayName, - /** @phpstan-ignore property.onlyWritten */ - private readonly string $emptyField, - ) { - parent::__construct( - $runId, - $profileName, - $gatewayName, - ); - } - public function isUserFixable(): bool { return false; diff --git a/src/Migration/Logging/Log/EntityAlreadyExistsRunLog.php b/src/Migration/Logging/Log/EntityAlreadyExistsRunLog.php index 1a6b62c6e..dd5bd17e2 100644 --- a/src/Migration/Logging/Log/EntityAlreadyExistsRunLog.php +++ b/src/Migration/Logging/Log/EntityAlreadyExistsRunLog.php @@ -8,22 +8,11 @@ namespace SwagMigrationAssistant\Migration\Logging\Log; use Shopware\Core\Framework\Log\Package; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class EntityAlreadyExistsRunLog extends BaseRunLogEntry +readonly class EntityAlreadyExistsRunLog extends AbstractSwagMigrationLogEntry { - public function __construct( - string $runId, - string $profileName, - string $gatewayName, - ) { - parent::__construct( - $runId, - $profileName, - $gatewayName, - ); - } - public function isUserFixable(): bool { return false; diff --git a/src/Migration/Logging/Log/ExceptionRunLog.php b/src/Migration/Logging/Log/ExceptionRunLog.php index 23e0a91fc..8932be88c 100644 --- a/src/Migration/Logging/Log/ExceptionRunLog.php +++ b/src/Migration/Logging/Log/ExceptionRunLog.php @@ -8,24 +8,11 @@ namespace SwagMigrationAssistant\Migration\Logging\Log; use Shopware\Core\Framework\Log\Package; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class ExceptionRunLog extends BaseRunLogEntry +readonly class ExceptionRunLog extends AbstractSwagMigrationLogEntry { - public function __construct( - string $runId, - string $profileName, - string $gatewayName, - /** @phpstan-ignore property.onlyWritten */ - private readonly \Throwable $exception, - ) { - parent::__construct( - $runId, - $profileName, - $gatewayName, - ); - } - public function isUserFixable(): bool { return false; diff --git a/src/Migration/Logging/Log/FieldReassignedRunLog.php b/src/Migration/Logging/Log/FieldReassignedRunLog.php index 032f2998f..8c1c8adb8 100644 --- a/src/Migration/Logging/Log/FieldReassignedRunLog.php +++ b/src/Migration/Logging/Log/FieldReassignedRunLog.php @@ -8,26 +8,11 @@ namespace SwagMigrationAssistant\Migration\Logging\Log; use Shopware\Core\Framework\Log\Package; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class FieldReassignedRunLog extends BaseRunLogEntry +readonly class FieldReassignedRunLog extends AbstractSwagMigrationLogEntry { - public function __construct( - string $runId, - string $profileName, - string $gatewayName, - /** @phpstan-ignore property.onlyWritten */ - private readonly string $emptyField, - /** @phpstan-ignore property.onlyWritten */ - private readonly string $replacementField, - ) { - parent::__construct( - $runId, - $profileName, - $gatewayName, - ); - } - public function isUserFixable(): bool { return false; diff --git a/src/Migration/Logging/Log/InvalidUnserializedData.php b/src/Migration/Logging/Log/InvalidUnserializedDataLog.php similarity index 55% rename from src/Migration/Logging/Log/InvalidUnserializedData.php rename to src/Migration/Logging/Log/InvalidUnserializedDataLog.php index 1bddf698d..9aaa34237 100644 --- a/src/Migration/Logging/Log/InvalidUnserializedData.php +++ b/src/Migration/Logging/Log/InvalidUnserializedDataLog.php @@ -8,26 +8,11 @@ namespace SwagMigrationAssistant\Migration\Logging\Log; use Shopware\Core\Framework\Log\Package; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class InvalidUnserializedData extends BaseRunLogEntry +readonly class InvalidUnserializedDataLog extends AbstractSwagMigrationLogEntry { - public function __construct( - string $runId, - string $profileName, - string $gatewayName, - /** @phpstan-ignore property.onlyWritten */ - private readonly string $unserializedEntity, - /** @phpstan-ignore property.onlyWritten */ - private readonly string $serializedData, - ) { - parent::__construct( - $runId, - $profileName, - $gatewayName, - ); - } - public function isUserFixable(): bool { return false; diff --git a/src/Migration/Logging/Log/LogEntryInterface.php b/src/Migration/Logging/Log/LogEntryInterface.php deleted file mode 100644 index fca9034e5..000000000 --- a/src/Migration/Logging/Log/LogEntryInterface.php +++ /dev/null @@ -1,31 +0,0 @@ - - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace SwagMigrationAssistant\Migration\Logging\Log; - -use Shopware\Core\Framework\Log\Package; - -#[Package('fundamentals@after-sales')] -interface LogEntryInterface -{ - final public const LOG_LEVEL_INFO = 'info'; - final public const LOG_LEVEL_WARNING = 'warning'; - final public const LOG_LEVEL_ERROR = 'error'; - final public const LOG_LEVEL_DEBUG = 'debug'; - - public function getRunId(): string; - - public function getProfileName(): string; - - public function getGatewayName(): string; - - public function getLevel(): string; - - public function getCode(): string; - - public function isUserFixable(): bool; -} diff --git a/src/Migration/Logging/Log/MessageQueueExceptionLog.php b/src/Migration/Logging/Log/MessageQueueExceptionLog.php index cb63b8357..8114a114f 100644 --- a/src/Migration/Logging/Log/MessageQueueExceptionLog.php +++ b/src/Migration/Logging/Log/MessageQueueExceptionLog.php @@ -8,26 +8,11 @@ namespace SwagMigrationAssistant\Migration\Logging\Log; use Shopware\Core\Framework\Log\Package; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class MessageQueueExceptionLog extends BaseRunLogEntry +readonly class MessageQueueExceptionLog extends AbstractSwagMigrationLogEntry { - public function __construct( - string $runId, - string $profileName, - string $gatewayName, - /** @phpstan-ignore property.onlyWritten */ - private readonly \Throwable $exception, - /** @phpstan-ignore property.onlyWritten */ - private int $exceptionCount, - ) { - parent::__construct( - $runId, - $profileName, - $gatewayName, - ); - } - public function isUserFixable(): bool { return false; diff --git a/src/Migration/Logging/Log/MimeTypeErrorLog.php b/src/Migration/Logging/Log/MimeTypeErrorLog.php index fdaa0a6c1..a3a14389f 100644 --- a/src/Migration/Logging/Log/MimeTypeErrorLog.php +++ b/src/Migration/Logging/Log/MimeTypeErrorLog.php @@ -8,22 +8,11 @@ namespace SwagMigrationAssistant\Migration\Logging\Log; use Shopware\Core\Framework\Log\Package; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class MimeTypeErrorLog extends BaseRunLogEntry +readonly class MimeTypeErrorLog extends AbstractSwagMigrationLogEntry { - public function __construct( - string $runId, - string $profileName, - string $gatewayName, - ) { - parent::__construct( - $runId, - $profileName, - $gatewayName, - ); - } - public function isUserFixable(): bool { return false; diff --git a/src/Migration/Logging/Log/ProcessorNotFoundLog.php b/src/Migration/Logging/Log/ProcessorNotFoundLog.php index 526499baf..f91ebb880 100644 --- a/src/Migration/Logging/Log/ProcessorNotFoundLog.php +++ b/src/Migration/Logging/Log/ProcessorNotFoundLog.php @@ -8,32 +8,16 @@ namespace SwagMigrationAssistant\Migration\Logging\Log; use Shopware\Core\Framework\Log\Package; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class ProcessorNotFoundLog implements LogEntryInterface +readonly class ProcessorNotFoundLog extends AbstractSwagMigrationLogEntry { - public function __construct( - private readonly string $runId, - private readonly string $profileName, - private readonly string $gatewayName, - ) { - } - public function isUserFixable(): bool { return false; } - public function getProfileName(): string - { - return $this->profileName; - } - - public function getGatewayName(): string - { - return $this->gatewayName; - } - public function getLevel(): string { return self::LOG_LEVEL_ERROR; @@ -43,9 +27,4 @@ public function getCode(): string { return 'SWAG_MIGRATION__PROCESSOR_NOT_FOUND'; } - - public function getRunId(): string - { - return $this->runId; - } } diff --git a/src/Migration/Logging/Log/RunAbortedAutomatically.php b/src/Migration/Logging/Log/RunAbortedAutomaticallyLog.php similarity index 61% rename from src/Migration/Logging/Log/RunAbortedAutomatically.php rename to src/Migration/Logging/Log/RunAbortedAutomaticallyLog.php index 639361b54..d8f293c93 100644 --- a/src/Migration/Logging/Log/RunAbortedAutomatically.php +++ b/src/Migration/Logging/Log/RunAbortedAutomaticallyLog.php @@ -8,24 +8,11 @@ namespace SwagMigrationAssistant\Migration\Logging\Log; use Shopware\Core\Framework\Log\Package; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class RunAbortedAutomatically extends BaseRunLogEntry +readonly class RunAbortedAutomaticallyLog extends AbstractSwagMigrationLogEntry { - public function __construct( - string $runId, - string $profileName, - string $gatewayName, - /** @phpstan-ignore property.onlyWritten */ - private readonly \Throwable $exception, - ) { - parent::__construct( - $runId, - $profileName, - $gatewayName, - ); - } - public function isUserFixable(): bool { return false; diff --git a/src/Migration/Logging/Log/TemporaryFileErrorLog.php b/src/Migration/Logging/Log/TemporaryFileErrorLog.php index 08c7990f6..3eeb34747 100644 --- a/src/Migration/Logging/Log/TemporaryFileErrorLog.php +++ b/src/Migration/Logging/Log/TemporaryFileErrorLog.php @@ -8,22 +8,11 @@ namespace SwagMigrationAssistant\Migration\Logging\Log; use Shopware\Core\Framework\Log\Package; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class TemporaryFileErrorLog extends BaseRunLogEntry +readonly class TemporaryFileErrorLog extends AbstractSwagMigrationLogEntry { - public function __construct( - string $runId, - string $profileName, - string $gatewayName, - ) { - parent::__construct( - $runId, - $profileName, - $gatewayName, - ); - } - public function isUserFixable(): bool { return false; diff --git a/src/Migration/Logging/Log/ThemeCompilingErrorRunLog.php b/src/Migration/Logging/Log/ThemeCompilingErrorRunLog.php index 365c5acc4..e61ab9dcd 100644 --- a/src/Migration/Logging/Log/ThemeCompilingErrorRunLog.php +++ b/src/Migration/Logging/Log/ThemeCompilingErrorRunLog.php @@ -8,22 +8,11 @@ namespace SwagMigrationAssistant\Migration\Logging\Log; use Shopware\Core\Framework\Log\Package; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class ThemeCompilingErrorRunLog extends BaseRunLogEntry +readonly class ThemeCompilingErrorRunLog extends AbstractSwagMigrationLogEntry { - public function __construct( - string $runId, - string $profileName, - string $gatewayName, - ) { - parent::__construct( - $runId, - $profileName, - $gatewayName, - ); - } - public function isUserFixable(): bool { return false; diff --git a/src/Migration/Logging/Log/UnknownEntityLog.php b/src/Migration/Logging/Log/UnknownEntityLog.php index 9d346d057..8a314a77a 100644 --- a/src/Migration/Logging/Log/UnknownEntityLog.php +++ b/src/Migration/Logging/Log/UnknownEntityLog.php @@ -8,26 +8,11 @@ namespace SwagMigrationAssistant\Migration\Logging\Log; use Shopware\Core\Framework\Log\Package; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class UnknownEntityLog extends BaseRunLogEntry +readonly class UnknownEntityLog extends AbstractSwagMigrationLogEntry { - public function __construct( - string $runId, - string $profileName, - string $gatewayName, - /** @phpstan-ignore property.onlyWritten */ - private readonly string $requiredForEntity, - /** @phpstan-ignore property.onlyWritten */ - private readonly string $requiredForSourceId, - ) { - parent::__construct( - $runId, - $profileName, - $gatewayName, - ); - } - public function isUserFixable(): bool { return false; diff --git a/src/Migration/Logging/Log/UnsupportedObjectType.php b/src/Migration/Logging/Log/UnsupportedObjectTypeLog.php similarity index 62% rename from src/Migration/Logging/Log/UnsupportedObjectType.php rename to src/Migration/Logging/Log/UnsupportedObjectTypeLog.php index f8d0165c7..c4e512896 100644 --- a/src/Migration/Logging/Log/UnsupportedObjectType.php +++ b/src/Migration/Logging/Log/UnsupportedObjectTypeLog.php @@ -8,24 +8,11 @@ namespace SwagMigrationAssistant\Migration\Logging\Log; use Shopware\Core\Framework\Log\Package; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class UnsupportedObjectType extends BaseRunLogEntry +readonly class UnsupportedObjectTypeLog extends AbstractSwagMigrationLogEntry { - public function __construct( - string $runId, - string $profileName, - string $gatewayName, - /** @phpstan-ignore property.onlyWritten */ - private readonly string $type, - ) { - parent::__construct( - $runId, - $profileName, - $gatewayName, - ); - } - public function isUserFixable(): bool { return false; diff --git a/src/Migration/Logging/Log/WriteExceptionRunLog.php b/src/Migration/Logging/Log/WriteExceptionRunLog.php index 9af0b6c8d..8cd1de217 100644 --- a/src/Migration/Logging/Log/WriteExceptionRunLog.php +++ b/src/Migration/Logging/Log/WriteExceptionRunLog.php @@ -8,27 +8,11 @@ namespace SwagMigrationAssistant\Migration\Logging\Log; use Shopware\Core\Framework\Log\Package; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class WriteExceptionRunLog extends BaseRunLogEntry +readonly class WriteExceptionRunLog extends AbstractSwagMigrationLogEntry { - /** - * @param array $error - */ - public function __construct( - string $runId, - string $profileName, - string $gatewayName, - /** @phpstan-ignore property.onlyWritten */ - private readonly array $error, - ) { - parent::__construct( - $runId, - $profileName, - $gatewayName, - ); - } - public function isUserFixable(): bool { return false; diff --git a/src/Migration/Logging/LoggingService.php b/src/Migration/Logging/LoggingService.php index c34a48479..7f522ca5e 100644 --- a/src/Migration/Logging/LoggingService.php +++ b/src/Migration/Logging/LoggingService.php @@ -11,7 +11,7 @@ use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\Log\Package; -use SwagMigrationAssistant\Migration\Logging\Log\LogEntryInterface; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogEntry; #[Package('fundamentals@after-sales')] class LoggingService implements LoggingServiceInterface @@ -51,7 +51,7 @@ public function saveLogging(Context $context): void } } - public function addLogEntry(LogEntryInterface $logEntry): void + public function addLogEntry(SwagMigrationLogEntry $logEntry): void { $this->logging[] = [ 'runId' => $logEntry->getRunId(), @@ -60,6 +60,14 @@ public function addLogEntry(LogEntryInterface $logEntry): void 'level' => $logEntry->getLevel(), 'code' => $logEntry->getCode(), 'userFixable' => $logEntry->isUserFixable(), + 'entityName' => $logEntry->getEntityName(), + 'fieldName' => $logEntry->getFieldName(), + 'fieldSourcePath' => $logEntry->getFieldSourcePath(), + 'sourceData' => $logEntry->getSourceData(), + 'convertedData' => $logEntry->getConvertedData(), + 'usedMapping' => $logEntry->getUsedMapping(), + 'exceptionMessage' => $logEntry->getExceptionMessage(), + 'exceptionTrace' => $logEntry->getExceptionTrace(), ]; } diff --git a/src/Migration/Logging/LoggingServiceInterface.php b/src/Migration/Logging/LoggingServiceInterface.php index 61416a10a..f194b567f 100644 --- a/src/Migration/Logging/LoggingServiceInterface.php +++ b/src/Migration/Logging/LoggingServiceInterface.php @@ -9,12 +9,12 @@ use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Log\Package; -use SwagMigrationAssistant\Migration\Logging\Log\LogEntryInterface; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogEntry; #[Package('fundamentals@after-sales')] interface LoggingServiceInterface { - public function addLogEntry(LogEntryInterface $logEntry): void; + public function addLogEntry(SwagMigrationLogEntry $logEntry): void; public function saveLogging(Context $context): void; } diff --git a/src/Migration/Logging/SwagMigrationLoggingDefinition.php b/src/Migration/Logging/SwagMigrationLoggingDefinition.php index 4f3e36fb4..cdd9dbe83 100644 --- a/src/Migration/Logging/SwagMigrationLoggingDefinition.php +++ b/src/Migration/Logging/SwagMigrationLoggingDefinition.php @@ -15,6 +15,7 @@ use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\PrimaryKey; use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\Required; use Shopware\Core\Framework\DataAbstractionLayer\Field\IdField; +use Shopware\Core\Framework\DataAbstractionLayer\Field\JsonField; use Shopware\Core\Framework\DataAbstractionLayer\Field\ManyToOneAssociationField; use Shopware\Core\Framework\DataAbstractionLayer\Field\StringField; use Shopware\Core\Framework\DataAbstractionLayer\Field\UpdatedAtField; @@ -45,14 +46,22 @@ public function getEntityClass(): string protected function defineFields(): FieldCollection { return new FieldCollection([ - new AutoIncrementField(), (new IdField('id', 'id'))->addFlags(new PrimaryKey(), new Required()), new FkField('run_id', 'runId', SwagMigrationRunDefinition::class), - (new StringField('profile_name', 'profileName', 255))->addFlags(new Required()), - (new StringField('gateway_name', 'gatewayName', 255))->addFlags(new Required()), + (new StringField('profile_name', 'profileName', 64))->addFlags(new Required()), + (new StringField('gateway_name', 'gatewayName', 64))->addFlags(new Required()), (new StringField('level', 'level', 64))->addFlags(new Required()), (new StringField('code', 'code'))->addFlags(new Required()), (new BoolField('user_fixable', 'userFixable'))->addFlags(new Required()), + new StringField('entity_name', 'entityName', 64), + new StringField('field_name', 'fieldName', 64), + new StringField('field_source_path', 'fieldSourcePath', 255), + new JsonField('source_data', 'sourceData'), + new JsonField('converted_data', 'convertedData'), + new JsonField('used_mapping', 'usedMapping'), + new StringField('exception_message', 'exceptionMessage', 255), + new JsonField('exception_trace', 'exceptionTrace'), + new AutoIncrementField(), new CreatedAtField(), new UpdatedAtField(), new ManyToOneAssociationField('run', 'run_id', SwagMigrationRunDefinition::class), diff --git a/src/Migration/Logging/SwagMigrationLoggingEntity.php b/src/Migration/Logging/SwagMigrationLoggingEntity.php index 037905697..9d4621725 100644 --- a/src/Migration/Logging/SwagMigrationLoggingEntity.php +++ b/src/Migration/Logging/SwagMigrationLoggingEntity.php @@ -33,6 +33,34 @@ class SwagMigrationLoggingEntity extends Entity protected int $autoIncrement; + protected ?string $entityName = null; + + protected ?string $fieldName = null; + + protected ?string $fieldSourcePath = null; + + /** + * @var array>|null + */ + protected ?array $sourceData = null; + + /** + * @var array>|null + */ + protected ?array $convertedData = null; + + /** + * @var array|null + */ + protected ?array $usedMapping = null; + + protected ?string $exceptionMessage = null; + + /** + * @var array>|null + */ + protected ?array $exceptionTrace = null; + public function getRunId(): string { return $this->runId; @@ -112,4 +140,108 @@ public function setAutoIncrement(int $autoIncrement): void { $this->autoIncrement = $autoIncrement; } + + public function getEntityName(): ?string + { + return $this->entityName; + } + + public function setEntityName(string $entityName): void + { + $this->entityName = $entityName; + } + + public function getFieldName(): ?string + { + return $this->fieldName; + } + + public function setFieldName(string $fieldName): void + { + $this->fieldName = $fieldName; + } + + public function getFieldSourcePath(): ?string + { + return $this->fieldSourcePath; + } + + public function setFieldSourcePath(string $fieldSourcePath): void + { + $this->fieldSourcePath = $fieldSourcePath; + } + + /** + * @return array>|null + */ + public function getSourceData(): ?array + { + return $this->sourceData; + } + + /** + * @param array> $sourceData + */ + public function setSourceData(array $sourceData): void + { + $this->sourceData = $sourceData; + } + + /** + * @return array>|null + */ + public function getConvertedData(): ?array + { + return $this->convertedData; + } + + /** + * @param array> $convertedData + */ + public function setConvertedData(array $convertedData): void + { + $this->convertedData = $convertedData; + } + + /** + * @return array|null + */ + public function getUsedMapping(): ?array + { + return $this->usedMapping; + } + + /** + * @param array $usedMapping + */ + public function setUsedMapping(array $usedMapping): void + { + $this->usedMapping = $usedMapping; + } + + public function getExceptionMessage(): ?string + { + return $this->exceptionMessage; + } + + public function setExceptionMessage(string $exceptionMessage): void + { + $this->exceptionMessage = $exceptionMessage; + } + + /** + * @return array>|null + */ + public function getExceptionTrace(): ?array + { + return $this->exceptionTrace; + } + + /** + * @param array> $exceptionTrace + */ + public function setExceptionTrace(array $exceptionTrace): void + { + $this->exceptionTrace = $exceptionTrace; + } } diff --git a/src/Migration/Media/Processor/HttpDownloadServiceBase.php b/src/Migration/Media/Processor/HttpDownloadServiceBase.php index 6dc4dd56e..fd6dcd973 100644 --- a/src/Migration/Media/Processor/HttpDownloadServiceBase.php +++ b/src/Migration/Media/Processor/HttpDownloadServiceBase.php @@ -23,6 +23,7 @@ use Shopware\Core\Framework\Uuid\Uuid; use SwagMigrationAssistant\Exception\MigrationException; use SwagMigrationAssistant\Migration\Gateway\HttpClientInterface; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\Log\CannotGetFileRunLog; use SwagMigrationAssistant\Migration\Logging\Log\ExceptionRunLog; use SwagMigrationAssistant\Migration\Logging\Log\TemporaryFileErrorLog; @@ -62,8 +63,6 @@ abstract public function supports(MigrationContextInterface $migrationContext): */ public function process(MigrationContextInterface $migrationContext, Context $context, array $workload): array { - $connection = $migrationContext->getConnection(); - // Map workload with uuids as keys $mappedWorkload = []; foreach ($workload as $work) { @@ -76,12 +75,14 @@ public function process(MigrationContextInterface $migrationContext, Context $co // prepare http client $client = $this->getHttpClient($migrationContext); if ($client === null) { - $this->loggingService->addLogEntry(new ExceptionRunLog( - $migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - new \Exception('Http download client can not be constructed.') - )); + $exception = new \Exception('Http download client can not be constructed.'); + + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withExceptionMessage($exception->getMessage()) + ->withExceptionTrace($exception->getTrace()) + ->build(ExceptionRunLog::class) + ); $this->loggingService->saveLogging($context); return $workload; @@ -120,13 +121,11 @@ function (MediaProcessWorkloadStruct $work) use ($uuid) { if ($work->getErrorCount() > ProcessMediaHandler::MEDIA_ERROR_THRESHOLD) { $failureUuids[] = $uuid; $work->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry(new CannotGetFileRunLog( - $work->getRunId(), - $connection->getProfileName(), - $connection->getGatewayName(), - $work->getAdditionalData()['uri'], - $result['reason'] ?? null - )); + + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(CannotGetFileRunLog::class) + ); } continue; @@ -141,11 +140,11 @@ function (MediaProcessWorkloadStruct $work) use ($uuid) { if ($filePath === false) { $failureUuids[] = $uuid; $work->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry(new TemporaryFileErrorLog( - $work->getRunId(), - $connection->getProfileName(), - $connection->getGatewayName(), - )); + + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(TemporaryFileErrorLog::class) + ); continue; } @@ -182,12 +181,12 @@ function (MediaProcessWorkloadStruct $work) use ($uuid) { } catch (\Exception $e) { $failureUuids[] = $uuid; $work->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry(new ExceptionRunLog( - $work->getRunId(), - $connection->getProfileName(), - $connection->getGatewayName(), - $e, - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withExceptionMessage($e->getMessage()) + ->withExceptionTrace($e->getTrace()) + ->build(ExceptionRunLog::class) + ); } finally { // clear up temp data \unlink($filePath); @@ -279,15 +278,13 @@ private function doNormalDownloadRequest(MigrationContextInterface $migrationCon $workload->setCurrentOffset((int) $additionalData['file_size']); $workload->setState(MediaProcessWorkloadStruct::FINISH_STATE); } catch (\Throwable $exception) { - $connection = $migrationContext->getConnection(); - // this should never happen because of Promises, but just in case something is wrong with request construction - $this->loggingService->addLogEntry(new ExceptionRunLog( - $workload->getRunId(), - $connection->getProfileName(), - $connection->getGatewayName(), - $exception, - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withExceptionMessage($exception->getMessage()) + ->withExceptionTrace($exception->getTrace()) + ->build(ExceptionRunLog::class) + ); $promise = null; $workload->setErrorCount($workload->getErrorCount() + 1); @@ -303,14 +300,14 @@ private function persistFileToMedia(string $filePath, string $uuid, string $name $mimeType = \mime_content_type($filePath); if ($fileSize === false || $fileSize === 0 || $mimeType === false) { - $connection = $migrationContext->getConnection(); + $exception = new \Exception('Downloaded file is empty or could not determine mime type.'); - $this->loggingService->addLogEntry(new ExceptionRunLog( - $migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - new \Exception('Downloaded file is empty or could not determine mime type.'), - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withExceptionMessage($exception->getMessage()) + ->withExceptionTrace($exception->getTrace()) + ->build(ExceptionRunLog::class) + ); return; } @@ -340,14 +337,12 @@ private function persistFileToMedia(string $filePath, string $uuid, string $name } elseif (\in_array($mediaException->getErrorCode(), [MediaException::MEDIA_ILLEGAL_FILE_NAME, MediaException::MEDIA_EMPTY_FILE_NAME], true)) { $this->fileSaver->persistFileToMedia($mediaFile, Uuid::randomHex(), $uuid, $context); } else { - $connection = $migrationContext->getConnection(); - - $this->loggingService->addLogEntry(new ExceptionRunLog( - $migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - $mediaException, - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withExceptionMessage($mediaException->getMessage()) + ->withExceptionTrace($mediaException->getTrace()) + ->build(ExceptionRunLog::class) + ); } } }); diff --git a/src/Migration/MessageQueue/Handler/ProcessMediaHandler.php b/src/Migration/MessageQueue/Handler/ProcessMediaHandler.php index a13511080..98e82551d 100644 --- a/src/Migration/MessageQueue/Handler/ProcessMediaHandler.php +++ b/src/Migration/MessageQueue/Handler/ProcessMediaHandler.php @@ -13,6 +13,7 @@ use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Exception\MigrationException; use SwagMigrationAssistant\Exception\NoConnectionFoundException; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\Log\ExceptionRunLog; use SwagMigrationAssistant\Migration\Logging\Log\ProcessorNotFoundLog; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; @@ -84,20 +85,19 @@ public function __invoke(ProcessMediaMessage $message): void $workload = $processor->process($migrationContext, $context, $workload); $this->processFailures($context, $migrationContext, $processor, $workload); } catch (NoConnectionFoundException) { - $this->loggingService->addLogEntry(new ProcessorNotFoundLog( - $message->getRunId(), - $connection->getProfileName(), - $connection->getGatewayName() - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(ProcessorNotFoundLog::class) + ); $this->loggingService->saveLogging($context); } catch (\Exception $e) { - $this->loggingService->addLogEntry(new ExceptionRunLog( - $message->getRunId(), - $connection->getProfileName(), - $connection->getGatewayName(), - $e - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withExceptionMessage($e->getMessage()) + ->withExceptionTrace($e->getTrace()) + ->build(ExceptionRunLog::class) + ); $this->loggingService->saveLogging($context); } diff --git a/src/Migration/Run/RunService.php b/src/Migration/Run/RunService.php index abf30983d..e98526fcd 100644 --- a/src/Migration/Run/RunService.php +++ b/src/Migration/Run/RunService.php @@ -31,6 +31,7 @@ use SwagMigrationAssistant\Migration\DataSelection\DataSelectionCollection; use SwagMigrationAssistant\Migration\DataSelection\DataSelectionRegistryInterface; use SwagMigrationAssistant\Migration\EnvironmentInformation; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\Log\ThemeCompilingErrorRunLog; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; use SwagMigrationAssistant\Migration\Mapping\MappingServiceInterface; @@ -96,7 +97,6 @@ public function startMigrationRun(array $dataSelectionIds, Context $context): vo } $connectionId = $connection->getId(); - // ToDo: MIG-965 - Check how we could put this into the MQ $this->cleanupUnwrittenRunDataOfLastInactiveRun($context); $runUuid = $this->createPlainMigrationRun($connectionId, $context); @@ -255,11 +255,13 @@ public function assignThemeToSalesChannel(string $runUuid, Context $context): vo try { $this->themeService->assignTheme($defaultTheme, $salesChannel, $context); } catch (\Throwable) { - $this->loggingService->addLogEntry(new ThemeCompilingErrorRunLog( - $runUuid, - $connection->getProfileName(), - $connection->getGatewayName(), - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + (new SwagMigrationLogBuilder( + $runUuid, + $connection->getProfileName(), + $connection->getGatewayName(), + ))->build(ThemeCompilingErrorRunLog::class) + ); } } diff --git a/src/Migration/Service/MediaFileProcessorService.php b/src/Migration/Service/MediaFileProcessorService.php index 99193d038..21fc5a23a 100644 --- a/src/Migration/Service/MediaFileProcessorService.php +++ b/src/Migration/Service/MediaFileProcessorService.php @@ -14,6 +14,7 @@ use SwagMigrationAssistant\Exception\DataSetNotFoundException; use SwagMigrationAssistant\Migration\DataSelection\DataSet\DataSet; use SwagMigrationAssistant\Migration\DataSelection\DataSet\DataSetRegistry; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\Log\DataSetNotFoundLog; use SwagMigrationAssistant\Migration\Logging\LoggingService; use SwagMigrationAssistant\Migration\MessageQueue\Message\ProcessMediaMessage; @@ -130,14 +131,9 @@ private function addMessageToBus(string $runUuid, Context $context, DataSet $dat private function logDataSetNotFoundException(MigrationContextInterface $migrationContext): void { - $connection = $migrationContext->getConnection(); - - $this->loggingService->addLogEntry( - new DataSetNotFoundLog( - $migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(DataSetNotFoundLog::class) ); } } diff --git a/src/Migration/Service/MigrationDataConverter.php b/src/Migration/Service/MigrationDataConverter.php index 6ebdd668a..62a0479b1 100644 --- a/src/Migration/Service/MigrationDataConverter.php +++ b/src/Migration/Service/MigrationDataConverter.php @@ -15,6 +15,7 @@ use SwagMigrationAssistant\Migration\Converter\ConverterInterface; use SwagMigrationAssistant\Migration\Converter\ConverterRegistryInterface; use SwagMigrationAssistant\Migration\DataSelection\DataSet\DataSet; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\Log\ExceptionRunLog; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; use SwagMigrationAssistant\Migration\Mapping\MappingDeltaResult; @@ -67,14 +68,12 @@ public function convert(array $data, MigrationContextInterface $migrationContext $this->mediaFileService->writeMediaFile($context); } } catch (\Throwable $exception) { - $connection = $migrationContext->getConnection(); - - $this->loggingService->addLogEntry(new ExceptionRunLog( - $migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - $exception - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withExceptionMessage($exception->getMessage()) + ->withExceptionTrace($exception->getTrace()) + ->build(ExceptionRunLog::class) + ); $this->loggingService->saveLogging($context); } @@ -105,14 +104,12 @@ private function convertData( 'convertFailure' => $convertFailureFlag, ]; } catch (\Throwable $exception) { - $connection = $migrationContext->getConnection(); - - $this->loggingService->addLogEntry(new ExceptionRunLog( - $runUuid, - $connection->getProfileName(), - $connection->getGatewayName(), - $exception - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withExceptionMessage($exception->getMessage()) + ->withExceptionTrace($exception->getTrace()) + ->build(ExceptionRunLog::class) + ); $createData[] = [ 'entity' => $dataSet::getEntity(), diff --git a/src/Migration/Service/MigrationDataFetcher.php b/src/Migration/Service/MigrationDataFetcher.php index 7874c8076..8cd178e9d 100644 --- a/src/Migration/Service/MigrationDataFetcher.php +++ b/src/Migration/Service/MigrationDataFetcher.php @@ -11,6 +11,7 @@ use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Migration\EnvironmentInformation; use SwagMigrationAssistant\Migration\Gateway\GatewayRegistryInterface; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\Log\ExceptionRunLog; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; use SwagMigrationAssistant\Migration\MigrationContextInterface; @@ -34,14 +35,12 @@ public function fetchData(MigrationContextInterface $migrationContext, Context $ try { return $this->gatewayRegistry->getGateway($migrationContext)->read($migrationContext); } catch (\Throwable $exception) { - $connection = $migrationContext->getConnection(); - - $this->loggingService->addLogEntry(new ExceptionRunLog( - $migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - $exception - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withExceptionMessage($exception->getMessage()) + ->withExceptionTrace($exception->getTrace()) + ->build(ExceptionRunLog::class) + ); $this->loggingService->saveLogging($context); } diff --git a/src/Migration/Service/MigrationDataWriter.php b/src/Migration/Service/MigrationDataWriter.php index 399efe930..4ed4c23a7 100644 --- a/src/Migration/Service/MigrationDataWriter.php +++ b/src/Migration/Service/MigrationDataWriter.php @@ -20,6 +20,7 @@ use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Exception\WriterNotFoundException; use SwagMigrationAssistant\Migration\Data\SwagMigrationDataCollection; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\Log\ExceptionRunLog; use SwagMigrationAssistant\Migration\Logging\Log\WriteExceptionRunLog; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; @@ -104,14 +105,12 @@ public function writeData(MigrationContextInterface $migrationContext, Context $ $currentWriter = $this->writerRegistry->getWriter($dataSet::getEntity()); $currentWriter->writeData(\array_values($converted), $this->writeContext); } catch (WriterNotFoundException $writerNotFoundException) { - $connection = $migrationContext->getConnection(); - - $this->loggingService->addLogEntry(new ExceptionRunLog( - $migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - $writerNotFoundException - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withExceptionMessage($writerNotFoundException->getMessage()) + ->withExceptionTrace($writerNotFoundException->getTrace()) + ->build(ExceptionRunLog::class) + ); $this->loggingService->saveLogging($context); foreach ($updateWrittenData as &$data) { @@ -166,8 +165,6 @@ private function handleWriteException( MigrationContextInterface $migrationContext, Context $context, ): void { - $connection = $migrationContext->getConnection(); - $writeErrors = $this->extractWriteErrorsWithIndex($exception); $currentWriter = $this->writerRegistry->getWriter($entityName); $newData = []; @@ -184,12 +181,10 @@ private function handleWriteException( $updateWrittenData[$dataId]['written'] = false; $updateWrittenData[$dataId]['writeFailure'] = true; - $this->loggingService->addLogEntry(new WriteExceptionRunLog( - $migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - $writeErrors[$index], - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(WriteExceptionRunLog::class) + ); ++$index; } @@ -235,19 +230,17 @@ private function writePerEntity( MigrationContextInterface $migrationContext, Context $context, ): void { - $connection = $migrationContext->getConnection(); - foreach ($converted as $dataId => $entity) { try { $currentWriter = $this->writerRegistry->getWriter($entityName); $currentWriter->writeData([$entity], $this->writeContext); } catch (\Throwable $exception) { - $this->loggingService->addLogEntry(new ExceptionRunLog( - $migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - $exception, - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withExceptionMessage($exception->getMessage()) + ->withExceptionTrace($exception->getTrace()) + ->build(ExceptionRunLog::class) + ); $updateWrittenData[$dataId]['written'] = false; $updateWrittenData[$dataId]['writeFailure'] = true; diff --git a/src/Migration/Subscriber/MessageQueueSubscriber.php b/src/Migration/Subscriber/MessageQueueSubscriber.php index 5066dcf02..7cb8fe09f 100644 --- a/src/Migration/Subscriber/MessageQueueSubscriber.php +++ b/src/Migration/Subscriber/MessageQueueSubscriber.php @@ -11,8 +11,9 @@ use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; use Shopware\Core\Framework\Log\Package; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\Log\MessageQueueExceptionLog; -use SwagMigrationAssistant\Migration\Logging\Log\RunAbortedAutomatically; +use SwagMigrationAssistant\Migration\Logging\Log\RunAbortedAutomaticallyLog; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; use SwagMigrationAssistant\Migration\MessageQueue\Message\MigrationProcessMessage; use SwagMigrationAssistant\Migration\Run\MigrationProgress; @@ -88,13 +89,16 @@ public function onWorkerMessageFailed(WorkerMessageFailedEvent $event): void * Raise exception counter and log the exception */ $progress->raiseExceptionCount(); - $this->loggingService->addLogEntry(new MessageQueueExceptionLog( - $run->getId(), - $connection?->getProfileName() ?? 'unknown', - $connection?->getGatewayName() ?? 'unknown', - $event->getThrowable(), - $progress->getExceptionCount() - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + (new SwagMigrationLogBuilder( + $run->getId(), + $connection?->getProfileName() ?? 'unknown', + $connection?->getGatewayName() ?? 'unknown' + )) + ->withExceptionMessage($event->getThrowable()->getMessage()) + ->withExceptionTrace($event->getThrowable()->getTrace()) + ->build(MessageQueueExceptionLog::class) + ); /* * Check if run is already in aborting state and failed again there, then set run status to aborted and log the error. @@ -104,12 +108,16 @@ public function onWorkerMessageFailed(WorkerMessageFailedEvent $event): void $progress->setIsAborted(true); $this->updateRun($run->getId(), $progress, $message->getContext()); - $this->loggingService->addLogEntry(new RunAbortedAutomatically( - $run->getId(), - $connection?->getProfileName() ?? 'unknown', - $connection?->getGatewayName() ?? 'unknown', - $event->getThrowable(), - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + (new SwagMigrationLogBuilder( + $run->getId(), + $connection?->getProfileName() ?? 'unknown', + $connection?->getGatewayName() ?? 'unknown' + )) + ->withExceptionMessage($event->getThrowable()->getMessage()) + ->withExceptionTrace($event->getThrowable()->getTrace()) + ->build(RunAbortedAutomaticallyLog::class) + ); $this->loggingService->saveLogging($message->getContext()); return; diff --git a/src/Profile/Shopware/Converter/CategoryConverter.php b/src/Profile/Shopware/Converter/CategoryConverter.php index 1beef67df..e26fea2f4 100644 --- a/src/Profile/Shopware/Converter/CategoryConverter.php +++ b/src/Profile/Shopware/Converter/CategoryConverter.php @@ -14,6 +14,7 @@ use SwagMigrationAssistant\Exception\MigrationException; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\Log\EmptyNecessaryFieldRunLog; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; use SwagMigrationAssistant\Migration\Mapping\Lookup\DefaultCmsPageLookup; @@ -88,12 +89,10 @@ public function convert( } if (!isset($data['_locale'])) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - 'locale' - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(EmptyNecessaryFieldRunLog::class) + ); return new ConvertStruct(null, $data); } diff --git a/src/Profile/Shopware/Converter/CrossSellingConverter.php b/src/Profile/Shopware/Converter/CrossSellingConverter.php index c9e56d3ca..e1df85531 100644 --- a/src/Profile/Shopware/Converter/CrossSellingConverter.php +++ b/src/Profile/Shopware/Converter/CrossSellingConverter.php @@ -12,6 +12,7 @@ use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; use SwagMigrationAssistant\Migration\Logging\Log\AssociationRequiredMissingLog; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\MigrationContextInterface; #[Package('fundamentals@after-sales')] @@ -61,12 +62,10 @@ public function convert(array $data, Context $context, MigrationContextInterface $sourceProductMapping = $this->getProductMapping($data['articleID']); if ($sourceProductMapping === null) { - $this->loggingService->addLogEntry(new AssociationRequiredMissingLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - $data['type'] - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(AssociationRequiredMissingLog::class) + ); return new ConvertStruct(null, $data); } @@ -74,12 +73,10 @@ public function convert(array $data, Context $context, MigrationContextInterface $relatedProductMapping = $this->getProductMapping($data['relatedarticle']); if ($relatedProductMapping === null) { - $this->loggingService->addLogEntry(new AssociationRequiredMissingLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - $data['type'] - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(AssociationRequiredMissingLog::class) + ); return new ConvertStruct(null, $data); } diff --git a/src/Profile/Shopware/Converter/CustomerConverter.php b/src/Profile/Shopware/Converter/CustomerConverter.php index d03ca2b35..eb5471518 100644 --- a/src/Profile/Shopware/Converter/CustomerConverter.php +++ b/src/Profile/Shopware/Converter/CustomerConverter.php @@ -16,6 +16,7 @@ use Shopware\Core\System\SalesChannel\SalesChannelCollection; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\Log\EmptyNecessaryFieldRunLog; use SwagMigrationAssistant\Migration\Logging\Log\FieldReassignedRunLog; use SwagMigrationAssistant\Migration\Logging\Log\UnknownEntityLog; @@ -110,23 +111,19 @@ public function convert( $fields = $this->checkForEmptyRequiredDataFields($data, $this->requiredDataFieldKeys); if (!empty($fields)) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - \implode(',', $fields) - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(EmptyNecessaryFieldRunLog::class) + ); return new ConvertStruct(null, $oldData); } if (!$this->checkEmailValidity($data['email'])) { - $this->loggingService->addLogEntry(new InvalidEmailAddressLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - $data['email'] - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(InvalidEmailAddressLog::class) + ); return new ConvertStruct(null, $oldData); } @@ -234,12 +231,10 @@ public function convert( ); if ($mapping === null) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - 'defaultpayment' - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(EmptyNecessaryFieldRunLog::class) + ); return new ConvertStruct(null, $oldData); } @@ -296,12 +291,10 @@ public function convert( if (!isset($converted['defaultBillingAddressId'], $converted['defaultShippingAddressId'])) { $this->mappingService->deleteMapping($converted['id'], $this->connectionId, $this->context); - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - 'address data' - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(EmptyNecessaryFieldRunLog::class) + ); return new ConvertStruct(null, $oldData); } @@ -343,15 +336,10 @@ protected function getDefaultPaymentMethod(array $originalData): ?string ); if ($paymentMethodMapping === null) { - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry(new UnknownEntityLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::CUSTOMER, - $this->oldCustomerId - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(UnknownEntityLog::class) + ); return null; } @@ -373,14 +361,10 @@ protected function applyAddresses(array &$originalData, array &$converted, strin $fields = $this->checkForEmptyRequiredDataFields($address, $this->requiredAddressDataFieldKeys); if (!empty($fields)) { - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - \implode(',', $fields) - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(EmptyNecessaryFieldRunLog::class) + ); continue; } @@ -552,8 +536,6 @@ protected function applyCountryTranslation(array &$country, array $data): void */ protected function getCountryState(array $oldAddressData, string $newCountryId): array { - $connection = $this->migrationContext->getConnection(); - if (!isset($oldAddressData['state_id'])) { return []; } @@ -561,14 +543,9 @@ protected function getCountryState(array $oldAddressData, string $newCountryId): $state = ['countryId' => $newCountryId]; if (!isset($oldAddressData['state_id'], $oldAddressData['country']['countryiso'], $oldAddressData['state']['shortcode'])) { - $this->loggingService->addLogEntry( - new UnknownEntityLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::CUSTOMER, - $this->oldCustomerId - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(UnknownEntityLog::class) ); return []; @@ -599,14 +576,9 @@ protected function getCountryState(array $oldAddressData, string $newCountryId): $oldAddressData['state']['position'], $oldAddressData['state']['active'] )) { - $this->loggingService->addLogEntry( - new UnknownEntityLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::CUSTOMER, - $this->oldCustomerId - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(UnknownEntityLog::class) ); return []; @@ -675,15 +647,10 @@ protected function checkUnsetDefaultShippingAndDefaultBillingAddress(array &$ori $converted['defaultShippingAddressId'] = $addresses[0]['id']; unset($originalData['default_billing_address_id'], $originalData['default_shipping_address_id']); - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry(new FieldReassignedRunLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - 'default billing and shipping address', - 'first address' - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(FieldReassignedRunLog::class) + ); } } @@ -697,15 +664,10 @@ protected function checkUnsetDefaultShippingAddress(array &$originalData, array $converted['defaultShippingAddressId'] = $converted['defaultBillingAddressId']; unset($originalData['default_shipping_address_id']); - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry(new FieldReassignedRunLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - 'default shipping address', - 'default billing address' - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(FieldReassignedRunLog::class) + ); } } @@ -719,15 +681,10 @@ protected function checkUnsetDefaultBillingAddress(array &$originalData, array & $converted['defaultBillingAddressId'] = $converted['defaultShippingAddressId']; unset($originalData['default_billing_address_id']); - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry(new FieldReassignedRunLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - 'default billing address', - 'default shipping address' - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(FieldReassignedRunLog::class) + ); } } @@ -741,15 +698,10 @@ protected function getSalutation(string $salutation): ?string ); if ($mapping === null) { - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry(new UnknownEntityLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::CUSTOMER, - $this->oldCustomerId - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(UnknownEntityLog::class) + ); return null; } diff --git a/src/Profile/Shopware/Converter/LanguageConverter.php b/src/Profile/Shopware/Converter/LanguageConverter.php index 367c84ad8..eba545df3 100644 --- a/src/Profile/Shopware/Converter/LanguageConverter.php +++ b/src/Profile/Shopware/Converter/LanguageConverter.php @@ -11,6 +11,7 @@ use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\Log\EntityAlreadyExistsRunLog; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; use SwagMigrationAssistant\Migration\Mapping\Lookup\LanguageLookup; @@ -52,11 +53,10 @@ public function convert(array $data, Context $context, MigrationContextInterface $languageUuid = $this->languageLookup->get($data['locale'], $context); if ($languageUuid !== null) { - $this->loggingService->addLogEntry(new EntityAlreadyExistsRunLog( - $migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(EntityAlreadyExistsRunLog::class) + ); return new ConvertStruct(null, $data); } diff --git a/src/Profile/Shopware/Converter/MainVariantRelationConverter.php b/src/Profile/Shopware/Converter/MainVariantRelationConverter.php index f4a81ff31..ced400034 100644 --- a/src/Profile/Shopware/Converter/MainVariantRelationConverter.php +++ b/src/Profile/Shopware/Converter/MainVariantRelationConverter.php @@ -12,6 +12,7 @@ use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; use SwagMigrationAssistant\Migration\Logging\Log\AssociationRequiredMissingLog; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\MigrationContextInterface; #[Package('fundamentals@after-sales')] @@ -21,8 +22,6 @@ abstract class MainVariantRelationConverter extends ShopwareConverter protected string $connectionId = ''; - private string $runUuid; - public function getSourceIdentifier(array $data): string { return $data['id']; @@ -32,7 +31,6 @@ public function convert(array $data, Context $context, MigrationContextInterface { $this->generateChecksum($data); $this->context = $context; - $this->runUuid = $migrationContext->getRunUuid(); $connection = $migrationContext->getConnection(); if ($connection !== null) { $this->connectionId = $connection->getId(); @@ -65,13 +63,23 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($mainProductMapping === null) { - $this->addAssociationRequiredLog($migrationContext); + $this->addAssociationRequiredLog( + $migrationContext, + 'id', + DefaultEntities::PRODUCT_CONTAINER, + $data + ); return new ConvertStruct(null, $data); } if ($variantProductMapping === null) { - $this->addAssociationRequiredLog($migrationContext); + $this->addAssociationRequiredLog( + $migrationContext, + 'ordernumber', + DefaultEntities::PRODUCT, + $data + ); return new ConvertStruct(null, $data); } @@ -98,17 +106,18 @@ public function convert(array $data, Context $context, MigrationContextInterface return new ConvertStruct($converted, $returnData, $this->mainMapping['id'] ?? null); } - private function addAssociationRequiredLog(MigrationContextInterface $migrationContext): void + /** + * @param array $data + */ + private function addAssociationRequiredLog(MigrationContextInterface $migrationContext, string $field, string $entity, array $data): void { - $connection = $migrationContext->getConnection(); - - $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $this->runUuid, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::MAIN_VARIANT_RELATION - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName($entity) + ->withFieldName($field) + ->withFieldSourcePath($field) + ->withSourceData([$data]) + ->build(AssociationRequiredMissingLog::class) ); } } diff --git a/src/Profile/Shopware/Converter/NewsletterRecipientConverter.php b/src/Profile/Shopware/Converter/NewsletterRecipientConverter.php index 9d929a63c..8e755c11c 100644 --- a/src/Profile/Shopware/Converter/NewsletterRecipientConverter.php +++ b/src/Profile/Shopware/Converter/NewsletterRecipientConverter.php @@ -12,6 +12,7 @@ use Shopware\Core\Framework\Uuid\Uuid; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\Log\EmptyNecessaryFieldRunLog; use SwagMigrationAssistant\Migration\Logging\Log\UnknownEntityLog; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; @@ -65,12 +66,10 @@ public function convert( $fields = $this->checkForEmptyRequiredDataFields($data, $this->requiredDataFieldKeys); if (!empty($fields)) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - \implode(',', $fields) - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(EmptyNecessaryFieldRunLog::class) + ); return new ConvertStruct(null, $data); } @@ -160,15 +159,10 @@ protected function getSalutation(string $salutation, MigrationContextInterface $ ); if ($salutationMapping === null) { - $connection = $migrationContext->getConnection(); - - $this->loggingService->addLogEntry(new UnknownEntityLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::NEWSLETTER_RECIPIENT, - $this->oldNewsletterRecipientId - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(UnknownEntityLog::class) + ); return null; } @@ -192,14 +186,10 @@ protected function getSalesChannel(array $data): ?string } if (!isset($salesChannelMapping)) { - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - 'salesChannel' - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(EmptyNecessaryFieldRunLog::class) + ); return null; } @@ -218,14 +208,10 @@ protected function getStatus(MigrationContextInterface $migrationContext): ?stri ); if ($status === null) { - $connection = $migrationContext->getConnection(); - - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - 'status' - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(EmptyNecessaryFieldRunLog::class) + ); } return $status; diff --git a/src/Profile/Shopware/Converter/NumberRangeConverter.php b/src/Profile/Shopware/Converter/NumberRangeConverter.php index c524cfe81..9f75f0202 100644 --- a/src/Profile/Shopware/Converter/NumberRangeConverter.php +++ b/src/Profile/Shopware/Converter/NumberRangeConverter.php @@ -17,6 +17,7 @@ use Shopware\Core\System\NumberRange\NumberRangeEntity; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\Log\EmptyNecessaryFieldRunLog; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; use SwagMigrationAssistant\Migration\Mapping\Lookup\LanguageLookup; @@ -74,13 +75,9 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->connectionId = $connection->getId(); if (!\array_key_exists($data['name'], self::TYPE_MAPPING)) { - $this->loggingService->addLogEntry( - new UnsupportedNumberRangeTypeLog( - $migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - $data['name'] - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(UnsupportedNumberRangeTypeLog::class) ); return new ConvertStruct(null, $data); @@ -91,12 +88,10 @@ public function convert(array $data, Context $context, MigrationContextInterface $converted['typeId'] = $this->getProductNumberRangeTypeUuid($data['name']); if (empty($converted['typeId'])) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - 'typeId' - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(EmptyNecessaryFieldRunLog::class) + ); return new ConvertStruct(null, $data); } diff --git a/src/Profile/Shopware/Converter/OrderConverter.php b/src/Profile/Shopware/Converter/OrderConverter.php index 59446bf75..bf83762fe 100644 --- a/src/Profile/Shopware/Converter/OrderConverter.php +++ b/src/Profile/Shopware/Converter/OrderConverter.php @@ -28,6 +28,7 @@ use SwagMigrationAssistant\Exception\MigrationException; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\Log\EmptyNecessaryFieldRunLog; use SwagMigrationAssistant\Migration\Logging\Log\UnknownEntityLog; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; @@ -135,12 +136,10 @@ public function convert( } if (!empty($fields)) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - \implode(',', $fields) - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(EmptyNecessaryFieldRunLog::class) + ); return new ConvertStruct(null, $data); } @@ -216,12 +215,10 @@ public function convert( $currencyUuid = $this->currencyLookup->get($data['currency'], $context); } if ($currencyUuid === null) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - 'currency' - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(EmptyNecessaryFieldRunLog::class) + ); return new ConvertStruct(null, $data); } @@ -245,13 +242,10 @@ public function convert( ); if ($stateMapping === null) { - $this->loggingService->addLogEntry(new UnknownEntityLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::ORDER, - $this->oldId - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(UnknownEntityLog::class) + ); return new ConvertStruct(null, $data); } @@ -323,12 +317,10 @@ public function convert( $billingAddress = $this->getAddress($data['billingaddress']); if (empty($billingAddress)) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - 'billingaddress' - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(EmptyNecessaryFieldRunLog::class) + ); return new ConvertStruct(null, $data); } @@ -429,15 +421,10 @@ protected function applyTransactions(array $data, array &$converted): void ); if ($mapping === null) { - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry(new UnknownEntityLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::ORDER_TRANSACTION, - $this->oldId - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(UnknownEntityLog::class) + ); return; } @@ -489,15 +476,10 @@ protected function getPaymentMethod(array $originalData): ?string ); if ($paymentMethodMapping === null) { - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry(new UnknownEntityLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::ORDER_TRANSACTION, - $this->oldId - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(UnknownEntityLog::class) + ); return null; } @@ -514,16 +496,13 @@ protected function getPaymentMethod(array $originalData): ?string */ protected function getAddress(array $originalData, string $type = self::BILLING_ADDRESS): array { - $connection = $this->migrationContext->getConnection(); $fields = $this->checkForEmptyRequiredDataFields($originalData, $this->requiredAddressDataFieldKeys); if (!empty($fields)) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - \implode(',', $fields) - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(EmptyNecessaryFieldRunLog::class) + ); return []; } @@ -656,8 +635,6 @@ protected function applyCountryTranslation(array &$country, array $data): void */ protected function getCountryState(array $oldAddressData, string $newCountryId): array { - $connection = $this->migrationContext->getConnection(); - if (!isset($oldAddressData['stateID'])) { return []; } @@ -665,14 +642,9 @@ protected function getCountryState(array $oldAddressData, string $newCountryId): $state = ['countryId' => $newCountryId]; if (!isset($oldAddressData['stateID'], $oldAddressData['country']['countryiso'], $oldAddressData['state']['shortcode'])) { - $this->loggingService->addLogEntry( - new UnknownEntityLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::ORDER, - $this->oldId - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(UnknownEntityLog::class) ); return []; @@ -703,14 +675,9 @@ protected function getCountryState(array $oldAddressData, string $newCountryId): $oldAddressData['state']['position'], $oldAddressData['state']['active'] )) { - $this->loggingService->addLogEntry( - new UnknownEntityLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::ORDER, - $this->oldId - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(UnknownEntityLog::class) ); return []; @@ -784,15 +751,10 @@ protected function getDeliveries(array $data, array $converted, CalculatedPrice ); if ($deliveryStateMapping === null) { - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry(new UnknownEntityLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::ORDER, - $this->oldId - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(UnknownEntityLog::class) + ); return []; } @@ -869,15 +831,10 @@ protected function getShippingMethod(string $shippingMethodId): ?string ); if ($shippingMethodMapping === null) { - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry(new UnknownEntityLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::ORDER, - $this->oldId - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(UnknownEntityLog::class) + ); return null; } @@ -1038,15 +995,10 @@ protected function getSalutation(string $salutation): ?string ); if ($salutationMapping === null) { - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry(new UnknownEntityLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::ORDER, - $this->oldId - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(UnknownEntityLog::class) + ); return null; } @@ -1071,15 +1023,10 @@ private function getOrderLineItemDownload(array $originalEsdItem): ?array ); if (!\is_array($mediaMapping)) { - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry(new UnknownEntityLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::ORDER, - $this->oldId - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(UnknownEntityLog::class) + ); return null; } diff --git a/src/Profile/Shopware/Converter/OrderDocumentConverter.php b/src/Profile/Shopware/Converter/OrderDocumentConverter.php index 590967155..9745d3856 100644 --- a/src/Profile/Shopware/Converter/OrderDocumentConverter.php +++ b/src/Profile/Shopware/Converter/OrderDocumentConverter.php @@ -16,7 +16,8 @@ use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; use SwagMigrationAssistant\Migration\Logging\Log\AssociationRequiredMissingLog; -use SwagMigrationAssistant\Migration\Logging\Log\DocumentTypeNotSupported; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; +use SwagMigrationAssistant\Migration\Logging\Log\DocumentTypeNotSupportedLog; use SwagMigrationAssistant\Migration\Logging\Log\EmptyNecessaryFieldRunLog; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; use SwagMigrationAssistant\Migration\Mapping\Lookup\DocumentTypeLookup; @@ -83,26 +84,18 @@ public function convert(array $data, Context $context, MigrationContextInterface $converted = []; if (empty($data['hash'])) { - $this->loggingService->addLogEntry( - new EmptyNecessaryFieldRunLog( - $this->migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - 'hash' - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(EmptyNecessaryFieldRunLog::class) ); return new ConvertStruct(null, $oldData); } if (!isset($data['documenttype'])) { - $this->loggingService->addLogEntry( - new EmptyNecessaryFieldRunLog( - $this->migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - 'documenttype' - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(EmptyNecessaryFieldRunLog::class) ); return new ConvertStruct(null, $oldData); @@ -116,13 +109,9 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($orderMapping === null) { - $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $this->migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::ORDER_DOCUMENT - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $oldData); @@ -202,14 +191,10 @@ protected function getDocumentType(array $data): array return $documentType; } - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry(new DocumentTypeNotSupported( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - $mappedKey - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(DocumentTypeNotSupportedLog::class) + ); $mapping = $this->mappingService->getOrCreateMapping( $this->connectionId, diff --git a/src/Profile/Shopware/Converter/ProductConverter.php b/src/Profile/Shopware/Converter/ProductConverter.php index 7772f4091..7827133e8 100644 --- a/src/Profile/Shopware/Converter/ProductConverter.php +++ b/src/Profile/Shopware/Converter/ProductConverter.php @@ -18,7 +18,8 @@ use SwagMigrationAssistant\Exception\MigrationException; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; -use SwagMigrationAssistant\Migration\Logging\Log\CannotConvertChildEntity; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; +use SwagMigrationAssistant\Migration\Logging\Log\CannotConvertChildEntityLog; use SwagMigrationAssistant\Migration\Logging\Log\EmptyNecessaryFieldRunLog; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; use SwagMigrationAssistant\Migration\Mapping\Lookup\DeliveryTimeLookup; @@ -146,12 +147,10 @@ public function convert( $fields = $this->checkForEmptyRequiredDataFields($data, $this->requiredDataFieldKeys); if (!empty($fields)) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - \implode(',', $fields) - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(EmptyNecessaryFieldRunLog::class) + ); return new ConvertStruct(null, $data); } @@ -387,14 +386,10 @@ private function getProductData(array &$data, array $converted): array $converted['price'] = $this->getPrice($data['prices'][0], $converted['tax']['taxRate']); if (empty($converted['price'])) { - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - 'currency' - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(EmptyNecessaryFieldRunLog::class) + ); } $converted['prices'] = $this->getPrices($data['prices'], $converted); @@ -894,16 +889,11 @@ private function getEsdFiles(array $esdFiles, string $oldVariantId, array $conve $newMedia['id'] = $mapping['entityUuid']; $this->mappingIds[] = $mapping['id']; - $connection = $this->migrationContext->getConnection(); - if (empty($esdFile['name'])) { - $this->loggingService->addLogEntry(new CannotConvertChildEntity( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::PRODUCT, - $this->oldProductId - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(CannotConvertChildEntityLog::class) + ); continue; } @@ -911,13 +901,10 @@ private function getEsdFiles(array $esdFiles, string $oldVariantId, array $conve try { $path = \unserialize($esdFile['path'], ['allowed_classes' => false]); } catch (\Throwable) { - $this->loggingService->addLogEntry(new CannotConvertChildEntity( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::PRODUCT, - $this->oldProductId - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(CannotConvertChildEntityLog::class) + ); continue; } @@ -945,13 +932,10 @@ private function getEsdFiles(array $esdFiles, string $oldVariantId, array $conve $albumId = $this->mediaFolderLookup->get(ProductDownloadDefinition::ENTITY_NAME, $this->context); if ($albumId === null) { - $this->loggingService->addLogEntry(new CannotConvertChildEntity( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::PRODUCT, - $this->oldProductId - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(CannotConvertChildEntityLog::class) + ); continue; } @@ -980,15 +964,10 @@ private function getMedia(array $media, string $oldVariantId, array $converted): $mediaObjects = []; foreach ($media as $mediaData) { if (!isset($mediaData['media']['id'])) { - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry(new CannotConvertChildEntity( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::PRODUCT, - $this->oldProductId - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(CannotConvertChildEntityLog::class) + ); continue; } @@ -1373,14 +1352,10 @@ private function getPrices(array $priceData, array $converted): array $priceArray = $this->getPrice($price, $converted['tax']['taxRate']); if (empty($priceArray)) { - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - 'currencyId' - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(EmptyNecessaryFieldRunLog::class) + ); continue; } diff --git a/src/Profile/Shopware/Converter/ProductReviewConverter.php b/src/Profile/Shopware/Converter/ProductReviewConverter.php index 2d794306e..34f3afa33 100644 --- a/src/Profile/Shopware/Converter/ProductReviewConverter.php +++ b/src/Profile/Shopware/Converter/ProductReviewConverter.php @@ -12,6 +12,7 @@ use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; use SwagMigrationAssistant\Migration\Logging\Log\AssociationRequiredMissingLog; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\Log\EmptyNecessaryFieldRunLog; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; use SwagMigrationAssistant\Migration\Mapping\Lookup\LanguageLookup; @@ -45,12 +46,10 @@ public function convert(array $data, Context $context, MigrationContextInterface $connectionId = $connection->getId(); if (!empty($fields)) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - \implode(',', $fields) - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(EmptyNecessaryFieldRunLog::class) + ); return new ConvertStruct(null, $data); } @@ -86,15 +85,9 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($mapping === null) { - $connection = $migrationContext->getConnection(); - - $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::PRODUCT_REVIEW - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $originalData); @@ -129,13 +122,9 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($mapping === null) { - $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::PRODUCT_REVIEW - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $originalData); @@ -146,13 +135,9 @@ public function convert(array $data, Context $context, MigrationContextInterface $converted['languageId'] = $this->languageLookup->get($mainLocale, $context); if ($converted['languageId'] === null) { - $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::PRODUCT_REVIEW - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $originalData); diff --git a/src/Profile/Shopware/Converter/PromotionConverter.php b/src/Profile/Shopware/Converter/PromotionConverter.php index 321ae4310..54bf3ccce 100644 --- a/src/Profile/Shopware/Converter/PromotionConverter.php +++ b/src/Profile/Shopware/Converter/PromotionConverter.php @@ -15,10 +15,10 @@ use Shopware\Core\Framework\Rule\Container\AndRule; use Shopware\Core\Framework\Rule\Container\OrRule; use Shopware\Core\System\SalesChannel\SalesChannelCollection; -use SwagMigrationAssistant\Migration\Connection\SwagMigrationConnectionEntity; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; use SwagMigrationAssistant\Migration\Logging\Log\AssociationRequiredMissingLog; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; use SwagMigrationAssistant\Migration\Mapping\MappingServiceInterface; use SwagMigrationAssistant\Migration\MigrationContextInterface; @@ -35,8 +35,6 @@ abstract class PromotionConverter extends ShopwareConverter */ private array $productUuids; - private string $runId; - /** * @param EntityRepository $salesChannelRepository */ @@ -57,7 +55,6 @@ public function convert(array $data, Context $context, MigrationContextInterface { $this->generateChecksum($data); $this->context = $context; - $this->runId = $migrationContext->getRunUuid(); $connection = $migrationContext->getConnection(); $this->connectionId = ''; @@ -88,7 +85,7 @@ public function convert(array $data, Context $context, MigrationContextInterface } $this->setSalesChannel($data, $converted, $migrationContext); - $this->setProductNumbers($data, $connection); + $this->setProductNumbers($data, $migrationContext); $this->setDiscount($data, $converted); $this->setShippingDiscount($data, $converted); $this->setCartRule($data, $converted, $migrationContext); @@ -351,7 +348,7 @@ private function getDiscountRule(array $data): ?array /** * @param array $data */ - private function setProductNumbers(array &$data, SwagMigrationConnectionEntity $connection): void + private function setProductNumbers(array &$data, MigrationContextInterface $migrationContext): void { if (!isset($data['restrictarticles'])) { return; @@ -370,13 +367,9 @@ private function setProductNumbers(array &$data, SwagMigrationConnectionEntity $ ); if ($productMapping === null) { - $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::PROMOTION - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(AssociationRequiredMissingLog::class) ); continue; @@ -505,15 +498,9 @@ private function setCartRule(array &$data, array &$converted, MigrationContextIn unset($data['bindtosupplier']); $oneRuleAdded = true; } else { - $connection = $migrationContext->getConnection(); - - $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::PROMOTION_DISCOUNT - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(AssociationRequiredMissingLog::class) ); } } @@ -562,15 +549,9 @@ private function setSalesChannel(array &$data, array &$converted, MigrationConte ); if ($salesChannelMapping === null) { - $connection = $migrationContext->getConnection(); - - $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::PROMOTION - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(AssociationRequiredMissingLog::class) ); return; @@ -636,14 +617,10 @@ private function setCustomerRule(array &$data, array &$converted, MigrationConte ); if ($customerGroupMapping === null) { - $connection = $migrationContext->getConnection(); - - $this->loggingService->addLogEntry(new AssociationRequiredMissingLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::PROMOTION - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(AssociationRequiredMissingLog::class) + ); return; } diff --git a/src/Profile/Shopware/Converter/PropertyGroupOptionConverter.php b/src/Profile/Shopware/Converter/PropertyGroupOptionConverter.php index 069f464ca..97586f041 100644 --- a/src/Profile/Shopware/Converter/PropertyGroupOptionConverter.php +++ b/src/Profile/Shopware/Converter/PropertyGroupOptionConverter.php @@ -11,7 +11,8 @@ use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; -use SwagMigrationAssistant\Migration\Logging\Log\CannotConvertChildEntity; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; +use SwagMigrationAssistant\Migration\Logging\Log\CannotConvertChildEntityLog; use SwagMigrationAssistant\Migration\Logging\Log\EmptyNecessaryFieldRunLog; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; use SwagMigrationAssistant\Migration\Mapping\Lookup\LanguageLookup; @@ -78,12 +79,10 @@ public function convert(array $data, Context $context, MigrationContextInterface } if (!isset($data['group']['name'])) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - 'group' - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(EmptyNecessaryFieldRunLog::class) + ); return new ConvertStruct(null, $data); } @@ -132,15 +131,10 @@ public function convert(array $data, Context $context, MigrationContextInterface protected function setMedia(array &$converted, array $data): void { if (!isset($data['media']['id'])) { - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry(new CannotConvertChildEntity( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::PROPERTY_GROUP_OPTION, - $data['id'] - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(CannotConvertChildEntityLog::class) + ); return; } diff --git a/src/Profile/Shopware/Converter/SalesChannelConverter.php b/src/Profile/Shopware/Converter/SalesChannelConverter.php index 3707dbc9d..4232a6578 100644 --- a/src/Profile/Shopware/Converter/SalesChannelConverter.php +++ b/src/Profile/Shopware/Converter/SalesChannelConverter.php @@ -23,6 +23,7 @@ use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; use SwagMigrationAssistant\Migration\Logging\Log\AssociationRequiredMissingLog; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; use SwagMigrationAssistant\Migration\Mapping\Lookup\CurrencyLookup; use SwagMigrationAssistant\Migration\Mapping\Lookup\LanguageLookup; @@ -98,13 +99,9 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($customerGroupMapping === null) { - $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::SALES_CHANNEL - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $data); @@ -115,13 +112,9 @@ public function convert(array $data, Context $context, MigrationContextInterface $languageUuid = $this->languageLookup->get($data['locale'], $context); if ($languageUuid === null) { - $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::SALES_CHANNEL - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $data); @@ -139,13 +132,9 @@ public function convert(array $data, Context $context, MigrationContextInterface $currencyUuid = $this->currencyLookup->get($data['currency'], $context); if ($currencyUuid === null) { - $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::SALES_CHANNEL - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $data); @@ -166,13 +155,9 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($categoryMapping === null) { - $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::SALES_CHANNEL - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $data); @@ -390,15 +375,9 @@ protected function filterDisabledPackLanguages(array &$converted): void $converted['languageId'] = Defaults::LANGUAGE_SYSTEM; } - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry( - new DeactivatedPackLanguageLog( - $this->migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - $packLanguageId, - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(DeactivatedPackLanguageLog::class) ); } } diff --git a/src/Profile/Shopware/Converter/SeoUrlConverter.php b/src/Profile/Shopware/Converter/SeoUrlConverter.php index 9552887d1..3f4099a42 100644 --- a/src/Profile/Shopware/Converter/SeoUrlConverter.php +++ b/src/Profile/Shopware/Converter/SeoUrlConverter.php @@ -12,11 +12,12 @@ use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; use SwagMigrationAssistant\Migration\Logging\Log\AssociationRequiredMissingLog; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; use SwagMigrationAssistant\Migration\Mapping\Lookup\LanguageLookup; use SwagMigrationAssistant\Migration\Mapping\MappingServiceInterface; use SwagMigrationAssistant\Migration\MigrationContextInterface; -use SwagMigrationAssistant\Profile\Shopware\Logging\Log\UnsupportedSeoUrlType; +use SwagMigrationAssistant\Profile\Shopware\Logging\Log\UnsupportedSeoUrlTypeLog; #[Package('fundamentals@after-sales')] abstract class SeoUrlConverter extends ShopwareConverter @@ -67,13 +68,9 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($mapping === null) { - $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::SEO_URL - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $originalData); @@ -84,13 +81,9 @@ public function convert(array $data, Context $context, MigrationContextInterface $converted['languageId'] = $this->languageLookup->get($data['_locale'], $context); if ($converted['languageId'] === null) { - $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::SEO_URL - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $originalData); @@ -115,13 +108,9 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($mapping === null) { - $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::SEO_URL - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $originalData); @@ -141,13 +130,9 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($mapping === null) { - $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::SEO_URL - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $originalData); @@ -157,13 +142,9 @@ public function convert(array $data, Context $context, MigrationContextInterface $converted['pathInfo'] = '/navigation/' . $mapping['entityUuid']; $this->mappingIds[] = $mapping['id']; } else { - $this->loggingService->addLogEntry( - new UnsupportedSeoUrlType( - $migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - $originalData['id'] - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(UnsupportedSeoUrlTypeLog::class) ); return new ConvertStruct(null, $originalData); diff --git a/src/Profile/Shopware/Converter/ShippingMethodConverter.php b/src/Profile/Shopware/Converter/ShippingMethodConverter.php index 95ceaa3c7..1ed8e79ce 100644 --- a/src/Profile/Shopware/Converter/ShippingMethodConverter.php +++ b/src/Profile/Shopware/Converter/ShippingMethodConverter.php @@ -13,13 +13,14 @@ use Shopware\Core\Framework\Rule\Container\OrRule; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\Log\EmptyNecessaryFieldRunLog; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; use SwagMigrationAssistant\Migration\Mapping\Lookup\CountryLookup; use SwagMigrationAssistant\Migration\Mapping\Lookup\LanguageLookup; use SwagMigrationAssistant\Migration\Mapping\MappingServiceInterface; use SwagMigrationAssistant\Migration\MigrationContextInterface; -use SwagMigrationAssistant\Profile\Shopware\Logging\Log\UnsupportedShippingCalculationType; +use SwagMigrationAssistant\Profile\Shopware\Logging\Log\UnsupportedShippingCalculationTypeLog; use SwagMigrationAssistant\Profile\Shopware\Logging\Log\UnsupportedShippingPriceLog; use SwagMigrationAssistant\Profile\Shopware\Premapping\DefaultShippingAvailabilityRuleReader; use SwagMigrationAssistant\Profile\Shopware\Premapping\DeliveryTimeReader; @@ -95,12 +96,10 @@ public function convert(array $data, Context $context, MigrationContextInterface } if (empty($data['id'])) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - 'id', - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(EmptyNecessaryFieldRunLog::class) + ); return new ConvertStruct(null, $data); } @@ -148,12 +147,10 @@ public function convert(array $data, Context $context, MigrationContextInterface $fields = $this->checkForEmptyRequiredConvertedFields($converted, $this->requiredDataFields); if (!empty($fields)) { foreach ($fields as $field) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - $field - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(EmptyNecessaryFieldRunLog::class) + ); } return new ConvertStruct(null, $data); @@ -184,12 +181,10 @@ public function convert(array $data, Context $context, MigrationContextInterface if (!isset($data['calculation']) || !\array_key_exists($data['calculation'], self::CALCULATION_TYPE_MAPPING) ) { - $this->loggingService->addLogEntry(new UnsupportedShippingCalculationType( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - $data['calculation'] - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(UnsupportedShippingCalculationTypeLog::class) + ); } else { $calculationType = self::CALCULATION_TYPE_MAPPING[$data['calculation']]; $converted['prices'] = $this->getShippingCosts($migrationContext, $data, $calculationType, $priceRule); @@ -241,12 +236,10 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->updateMainMapping($migrationContext, $context); if (!\is_array($this->mainMapping) || !\array_key_exists('id', $this->mainMapping)) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - 'id', - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(EmptyNecessaryFieldRunLog::class) + ); return new ConvertStruct(null, $data); } @@ -635,8 +628,6 @@ protected function getSalesChannelAndCustomerGroupCalculationRule(array $data): */ protected function getShippingCosts(MigrationContextInterface $migrationContext, array $data, int $calculationType, ?array $rule): array { - $connection = $migrationContext->getConnection(); - $shippingCosts = $data['shippingCosts']; $taxRate = 0.0; if (isset($data['tax']['tax'])) { @@ -646,12 +637,10 @@ protected function getShippingCosts(MigrationContextInterface $migrationContext, $convertedCosts = []; foreach ($shippingCosts as $key => $shippingCost) { if (empty($shippingCost['id'])) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - 'id' - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(EmptyNecessaryFieldRunLog::class) + ); continue; } @@ -681,12 +670,10 @@ protected function getShippingCosts(MigrationContextInterface $migrationContext, } if (!isset($currencyMapping)) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - 'currency' - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(EmptyNecessaryFieldRunLog::class) + ); continue; } @@ -698,12 +685,10 @@ protected function getShippingCosts(MigrationContextInterface $migrationContext, } if (isset($shippingCost['factor']) && $shippingCost['factor'] > 0) { - $this->loggingService->addLogEntry(new UnsupportedShippingPriceLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - $this->oldShippingMethod - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(UnsupportedShippingPriceLog::class) + ); continue; } diff --git a/src/Profile/Shopware/Converter/TranslationConverter.php b/src/Profile/Shopware/Converter/TranslationConverter.php index 59f43c53b..ed7d7283d 100644 --- a/src/Profile/Shopware/Converter/TranslationConverter.php +++ b/src/Profile/Shopware/Converter/TranslationConverter.php @@ -20,13 +20,14 @@ use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; use SwagMigrationAssistant\Migration\Logging\Log\AssociationRequiredMissingLog; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\Log\EmptyNecessaryFieldRunLog; -use SwagMigrationAssistant\Migration\Logging\Log\InvalidUnserializedData; +use SwagMigrationAssistant\Migration\Logging\Log\InvalidUnserializedDataLog; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; use SwagMigrationAssistant\Migration\Mapping\Lookup\LanguageLookup; use SwagMigrationAssistant\Migration\Mapping\MappingServiceInterface; use SwagMigrationAssistant\Migration\MigrationContextInterface; -use SwagMigrationAssistant\Profile\Shopware\Logging\Log\UnsupportedTranslationType; +use SwagMigrationAssistant\Profile\Shopware\Logging\Log\UnsupportedTranslationTypeLog; #[Package('fundamentals@after-sales')] abstract class TranslationConverter extends ShopwareConverter @@ -62,12 +63,10 @@ public function convert( } if (!isset($data['locale'])) { - $this->loggingService->addLogEntry(new EmptyNecessaryFieldRunLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - 'locale' - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(EmptyNecessaryFieldRunLog::class) + ); return new ConvertStruct(null, $data); } @@ -96,13 +95,9 @@ public function convert( return $this->createProductMediaTranslation($data); } - $this->loggingService->addLogEntry( - new UnsupportedTranslationType( - $migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - $data['id'] - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(UnsupportedTranslationTypeLog::class) ); return new ConvertStruct(null, $data); @@ -132,15 +127,9 @@ protected function createProductTranslation(array &$data): ConvertStruct } if ($mapping === null) { - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::TRANSLATION - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $sourceData); @@ -245,15 +234,9 @@ protected function createProductVariantTranslation(array &$data): ConvertStruct unset($data['ordernumber']); if ($mapping === null) { - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::TRANSLATION - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $sourceData); @@ -323,15 +306,9 @@ protected function createManufacturerProductTranslation(array $data): ConvertStr ); if ($mapping === null) { - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::TRANSLATION - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $sourceData); @@ -407,15 +384,9 @@ protected function createUnitTranslation(array $data): ConvertStruct ); if ($mapping === null) { - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::TRANSLATION - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $sourceData); @@ -496,15 +467,9 @@ protected function createCategoryTranslation(array $data): ConvertStruct ); if ($mapping === null) { - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::TRANSLATION - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $sourceData); @@ -595,15 +560,9 @@ protected function createConfiguratorOptionTranslation(array $data): ConvertStru ); if ($mapping === null) { - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::TRANSLATION - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $sourceData); @@ -676,15 +635,9 @@ protected function createConfiguratorOptionGroupTranslation(array $data): Conver ); if ($mapping === null) { - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::TRANSLATION - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $sourceData); @@ -760,15 +713,9 @@ protected function createPropertyValueTranslation(array $data): ConvertStruct ); if ($mapping === null) { - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::TRANSLATION - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $sourceData); @@ -839,15 +786,9 @@ protected function createPropertyOptionTranslation(array $data): ConvertStruct ); if ($mapping === null) { - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::TRANSLATION - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $sourceData); @@ -973,16 +914,10 @@ protected function unserializeTranslation(array $data, string $entity): ?array } if (!\is_array($objectData)) { - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry( - new InvalidUnserializedData( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - $entity, - $objectDataSerialized - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName($entity) + ->build(InvalidUnserializedDataLog::class) ); return null; @@ -1010,15 +945,9 @@ protected function createProductMediaTranslation(array $data): ConvertStruct ); if ($mapping === null) { - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry( - new AssociationRequiredMissingLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - DefaultEntities::TRANSLATION - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(AssociationRequiredMissingLog::class) ); return new ConvertStruct(null, $sourceData); diff --git a/src/Profile/Shopware/Gateway/Api/Reader/TableCountReader.php b/src/Profile/Shopware/Gateway/Api/Reader/TableCountReader.php index 550f9c3ac..92807550d 100644 --- a/src/Profile/Shopware/Gateway/Api/Reader/TableCountReader.php +++ b/src/Profile/Shopware/Gateway/Api/Reader/TableCountReader.php @@ -10,6 +10,7 @@ use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Exception\MigrationException; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\Log\CannotReadEntityCountLog; use SwagMigrationAssistant\Migration\Logging\LoggingService; use SwagMigrationAssistant\Migration\MigrationContextInterface; @@ -67,18 +68,12 @@ private function prepareTotals(array $result): array private function logExceptions(array $exceptionArray, MigrationContextInterface $migrationContext, Context $context): void { - $connection = $migrationContext->getConnection(); - foreach ($exceptionArray as $exception) { - $this->loggingService->addLogEntry(new CannotReadEntityCountLog( - $migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - $exception['table'], - $exception['condition'], - $exception['code'], - $exception['message'] - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withExceptionMessage($exception['message']) + ->build(CannotReadEntityCountLog::class) + ); } $this->loggingService->saveLogging($context); diff --git a/src/Profile/Shopware/Logging/Log/DeactivatedPackLanguageLog.php b/src/Profile/Shopware/Logging/Log/DeactivatedPackLanguageLog.php index f416ad2eb..d9dd97796 100644 --- a/src/Profile/Shopware/Logging/Log/DeactivatedPackLanguageLog.php +++ b/src/Profile/Shopware/Logging/Log/DeactivatedPackLanguageLog.php @@ -8,25 +8,11 @@ namespace SwagMigrationAssistant\Profile\Shopware\Logging\Log; use Shopware\Core\Framework\Log\Package; -use SwagMigrationAssistant\Migration\Logging\Log\BaseRunLogEntry; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class DeactivatedPackLanguageLog extends BaseRunLogEntry +readonly class DeactivatedPackLanguageLog extends AbstractSwagMigrationLogEntry { - public function __construct( - string $runId, - string $profileName, - string $gatewayName, - /** @phpstan-ignore property.onlyWritten */ - private readonly string $languageId, - ) { - parent::__construct( - $runId, - $profileName, - $gatewayName, - ); - } - public function isUserFixable(): bool { return false; diff --git a/src/Profile/Shopware/Logging/Log/InvalidEmailAddressLog.php b/src/Profile/Shopware/Logging/Log/InvalidEmailAddressLog.php index d97c58344..a6b8a6539 100644 --- a/src/Profile/Shopware/Logging/Log/InvalidEmailAddressLog.php +++ b/src/Profile/Shopware/Logging/Log/InvalidEmailAddressLog.php @@ -8,25 +8,11 @@ namespace SwagMigrationAssistant\Profile\Shopware\Logging\Log; use Shopware\Core\Framework\Log\Package; -use SwagMigrationAssistant\Migration\Logging\Log\BaseRunLogEntry; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class InvalidEmailAddressLog extends BaseRunLogEntry +readonly class InvalidEmailAddressLog extends AbstractSwagMigrationLogEntry { - public function __construct( - string $runId, - string $profileName, - string $gatewayName, - /** @phpstan-ignore property.onlyWritten */ - private readonly string $email, - ) { - parent::__construct( - $runId, - $profileName, - $gatewayName, - ); - } - public function isUserFixable(): bool { return false; diff --git a/src/Profile/Shopware/Logging/Log/UnsupportedMailTemplateType.php b/src/Profile/Shopware/Logging/Log/UnsupportedMailTemplateTypeLog.php similarity index 58% rename from src/Profile/Shopware/Logging/Log/UnsupportedMailTemplateType.php rename to src/Profile/Shopware/Logging/Log/UnsupportedMailTemplateTypeLog.php index b5346a9a1..db0a5182d 100644 --- a/src/Profile/Shopware/Logging/Log/UnsupportedMailTemplateType.php +++ b/src/Profile/Shopware/Logging/Log/UnsupportedMailTemplateTypeLog.php @@ -8,25 +8,11 @@ namespace SwagMigrationAssistant\Profile\Shopware\Logging\Log; use Shopware\Core\Framework\Log\Package; -use SwagMigrationAssistant\Migration\Logging\Log\BaseRunLogEntry; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class UnsupportedMailTemplateType extends BaseRunLogEntry +readonly class UnsupportedMailTemplateTypeLog extends AbstractSwagMigrationLogEntry { - public function __construct( - string $runId, - string $profileName, - string $gatewayName, - /** @phpstan-ignore property.onlyWritten */ - private readonly string $type, - ) { - parent::__construct( - $runId, - $profileName, - $gatewayName, - ); - } - public function isUserFixable(): bool { return false; diff --git a/src/Profile/Shopware/Logging/Log/UnsupportedNumberRangeTypeLog.php b/src/Profile/Shopware/Logging/Log/UnsupportedNumberRangeTypeLog.php index 35ec60b72..305ccde17 100644 --- a/src/Profile/Shopware/Logging/Log/UnsupportedNumberRangeTypeLog.php +++ b/src/Profile/Shopware/Logging/Log/UnsupportedNumberRangeTypeLog.php @@ -8,25 +8,11 @@ namespace SwagMigrationAssistant\Profile\Shopware\Logging\Log; use Shopware\Core\Framework\Log\Package; -use SwagMigrationAssistant\Migration\Logging\Log\BaseRunLogEntry; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class UnsupportedNumberRangeTypeLog extends BaseRunLogEntry +readonly class UnsupportedNumberRangeTypeLog extends AbstractSwagMigrationLogEntry { - public function __construct( - string $runId, - string $profileName, - string $gatewayName, - /** @phpstan-ignore property.onlyWritten */ - private readonly string $type, - ) { - parent::__construct( - $runId, - $profileName, - $gatewayName, - ); - } - public function isUserFixable(): bool { return false; diff --git a/src/Profile/Shopware/Logging/Log/UnsupportedTranslationType.php b/src/Profile/Shopware/Logging/Log/UnsupportedSeoUrlTypeLog.php similarity index 85% rename from src/Profile/Shopware/Logging/Log/UnsupportedTranslationType.php rename to src/Profile/Shopware/Logging/Log/UnsupportedSeoUrlTypeLog.php index 6f61a5bd6..adc268f1d 100644 --- a/src/Profile/Shopware/Logging/Log/UnsupportedTranslationType.php +++ b/src/Profile/Shopware/Logging/Log/UnsupportedSeoUrlTypeLog.php @@ -8,10 +8,10 @@ namespace SwagMigrationAssistant\Profile\Shopware\Logging\Log; use Shopware\Core\Framework\Log\Package; -use SwagMigrationAssistant\Migration\Logging\Log\UnsupportedObjectType; +use SwagMigrationAssistant\Migration\Logging\Log\UnsupportedObjectTypeLog; #[Package('fundamentals@after-sales')] -class UnsupportedTranslationType extends UnsupportedObjectType +readonly class UnsupportedSeoUrlTypeLog extends UnsupportedObjectTypeLog { public function getLevel(): string { diff --git a/src/Profile/Shopware/Logging/Log/UnsupportedShippingCalculationType.php b/src/Profile/Shopware/Logging/Log/UnsupportedShippingCalculationTypeLog.php similarity index 58% rename from src/Profile/Shopware/Logging/Log/UnsupportedShippingCalculationType.php rename to src/Profile/Shopware/Logging/Log/UnsupportedShippingCalculationTypeLog.php index 184d1784e..38916b61b 100644 --- a/src/Profile/Shopware/Logging/Log/UnsupportedShippingCalculationType.php +++ b/src/Profile/Shopware/Logging/Log/UnsupportedShippingCalculationTypeLog.php @@ -8,25 +8,11 @@ namespace SwagMigrationAssistant\Profile\Shopware\Logging\Log; use Shopware\Core\Framework\Log\Package; -use SwagMigrationAssistant\Migration\Logging\Log\BaseRunLogEntry; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class UnsupportedShippingCalculationType extends BaseRunLogEntry +readonly class UnsupportedShippingCalculationTypeLog extends AbstractSwagMigrationLogEntry { - public function __construct( - string $runId, - string $profileName, - string $gatewayName, - /** @phpstan-ignore property.onlyWritten */ - private readonly string $type, - ) { - parent::__construct( - $runId, - $profileName, - $gatewayName, - ); - } - public function isUserFixable(): bool { return false; diff --git a/src/Profile/Shopware/Logging/Log/UnsupportedShippingPriceLog.php b/src/Profile/Shopware/Logging/Log/UnsupportedShippingPriceLog.php index 5b4a6dd5c..26c99147e 100644 --- a/src/Profile/Shopware/Logging/Log/UnsupportedShippingPriceLog.php +++ b/src/Profile/Shopware/Logging/Log/UnsupportedShippingPriceLog.php @@ -8,25 +8,11 @@ namespace SwagMigrationAssistant\Profile\Shopware\Logging\Log; use Shopware\Core\Framework\Log\Package; -use SwagMigrationAssistant\Migration\Logging\Log\BaseRunLogEntry; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class UnsupportedShippingPriceLog extends BaseRunLogEntry +readonly class UnsupportedShippingPriceLog extends AbstractSwagMigrationLogEntry { - public function __construct( - string $runId, - string $profileName, - string $gatewayName, - /** @phpstan-ignore property.onlyWritten */ - private readonly string $shippingMethodId, - ) { - parent::__construct( - $runId, - $profileName, - $gatewayName, - ); - } - public function isUserFixable(): bool { return false; diff --git a/src/Profile/Shopware/Logging/Log/UnsupportedSeoUrlType.php b/src/Profile/Shopware/Logging/Log/UnsupportedTranslationTypeLog.php similarity index 85% rename from src/Profile/Shopware/Logging/Log/UnsupportedSeoUrlType.php rename to src/Profile/Shopware/Logging/Log/UnsupportedTranslationTypeLog.php index 2ed91dbee..c7bb3c133 100644 --- a/src/Profile/Shopware/Logging/Log/UnsupportedSeoUrlType.php +++ b/src/Profile/Shopware/Logging/Log/UnsupportedTranslationTypeLog.php @@ -8,10 +8,10 @@ namespace SwagMigrationAssistant\Profile\Shopware\Logging\Log; use Shopware\Core\Framework\Log\Package; -use SwagMigrationAssistant\Migration\Logging\Log\UnsupportedObjectType; +use SwagMigrationAssistant\Migration\Logging\Log\UnsupportedObjectTypeLog; #[Package('fundamentals@after-sales')] -class UnsupportedSeoUrlType extends UnsupportedObjectType +readonly class UnsupportedTranslationTypeLog extends UnsupportedObjectTypeLog { public function getLevel(): string { diff --git a/src/Profile/Shopware/Media/LocalMediaProcessor.php b/src/Profile/Shopware/Media/LocalMediaProcessor.php index 22dc1520c..85bae475a 100644 --- a/src/Profile/Shopware/Media/LocalMediaProcessor.php +++ b/src/Profile/Shopware/Media/LocalMediaProcessor.php @@ -15,6 +15,7 @@ use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\Log\Package; use Shopware\Core\Framework\Uuid\Uuid; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\Log\CannotGetFileRunLog; use SwagMigrationAssistant\Migration\Logging\Log\ExceptionRunLog; use SwagMigrationAssistant\Migration\Logging\Log\MimeTypeErrorLog; @@ -116,8 +117,6 @@ private function copyMediaFiles( MigrationContextInterface $migrationContext, Context $context, ): array { - $connection = $migrationContext->getConnection(); - $processedMedia = []; $failedMedia = []; @@ -130,12 +129,10 @@ private function copyMediaFiles( if ($resolver === null) { $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry(new CannotGetFileRunLog( - $mappedWorkload[$mediaId]->getRunId(), - $connection->getProfileName(), - $connection->getGatewayName(), - $sourcePath - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(CannotGetFileRunLog::class) + ); $processedMedia[] = $mediaId; $failedMedia[] = $mediaId; @@ -148,11 +145,11 @@ private function copyMediaFiles( if ($filePath === false) { $failedMedia[] = $mediaId; $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry(new TemporaryFileErrorLog( - $mappedWorkload[$mediaId]->getRunId(), - $connection->getProfileName(), - $connection->getGatewayName(), - )); + + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(TemporaryFileErrorLog::class) + ); continue; } @@ -177,22 +174,21 @@ private function copyMediaFiles( } catch (\Exception $e) { $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); $failedMedia[] = $mediaId; - $this->loggingService->addLogEntry(new ExceptionRunLog( - $mappedWorkload[$mediaId]->getRunId(), - $connection->getProfileName(), - $connection->getGatewayName(), - $e, - )); + + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withExceptionMessage($e->getMessage()) + ->withExceptionTrace($e->getTrace()) + ->build(ExceptionRunLog::class) + ); } \unlink($filePath); } else { $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry(new CannotGetFileRunLog( - $mappedWorkload[$mediaId]->getRunId(), - $connection->getProfileName(), - $connection->getGatewayName(), - $sourcePath - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(CannotGetFileRunLog::class) + ); $failedMedia[] = $mediaId; } } @@ -222,16 +218,13 @@ private function persistFileToMedia( $mimeType = \mime_content_type($filePath); if ($mimeType === false) { - $connection = $migrationContext->getConnection(); - $failedMedia[] = $mediaId; $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry(new MimeTypeErrorLog( - $mappedWorkload[$mediaId]->getRunId(), - $connection->getProfileName(), - $connection->getGatewayName(), - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(MimeTypeErrorLog::class) + ); return; } diff --git a/src/Profile/Shopware/Media/LocalOrderDocumentProcessor.php b/src/Profile/Shopware/Media/LocalOrderDocumentProcessor.php index d4140c5df..8dffb83bb 100644 --- a/src/Profile/Shopware/Media/LocalOrderDocumentProcessor.php +++ b/src/Profile/Shopware/Media/LocalOrderDocumentProcessor.php @@ -14,6 +14,7 @@ use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\Log\Package; use Shopware\Core\Framework\Uuid\Uuid; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\Log\CannotGetFileRunLog; use SwagMigrationAssistant\Migration\Logging\Log\ExceptionRunLog; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; @@ -90,8 +91,6 @@ private function copyMediaFiles( MigrationContextInterface $migrationContext, Context $context, ): array { - $connection = $migrationContext->getConnection(); - $installationRoot = $this->getInstallationRoot($migrationContext); $processedMedia = []; $failedMedia = []; @@ -102,12 +101,10 @@ private function copyMediaFiles( if (!\is_file($sourcePath)) { $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry(new CannotGetFileRunLog( - $mappedWorkload[$mediaId]->getRunId(), - $connection->getProfileName(), - $connection->getGatewayName(), - $sourcePath - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(CannotGetFileRunLog::class) + ); $processedMedia[] = $mediaId; $failedMedia[] = $mediaId; @@ -125,12 +122,12 @@ private function copyMediaFiles( $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry(new ExceptionRunLog( - $mappedWorkload[$mediaId]->getRunId(), - $connection->getProfileName(), - $connection->getGatewayName(), - $e, - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withExceptionMessage($e->getMessage()) + ->withExceptionTrace($e->getTrace()) + ->build(ExceptionRunLog::class) + ); } } diff --git a/src/Profile/Shopware/Media/LocalProductDownloadProcessor.php b/src/Profile/Shopware/Media/LocalProductDownloadProcessor.php index 65c4a3a86..39527fcb4 100644 --- a/src/Profile/Shopware/Media/LocalProductDownloadProcessor.php +++ b/src/Profile/Shopware/Media/LocalProductDownloadProcessor.php @@ -15,6 +15,7 @@ use Shopware\Core\Framework\Log\Package; use Shopware\Core\Framework\Uuid\Uuid; use SwagMigrationAssistant\Exception\MigrationException; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\Log\CannotGetFileRunLog; use SwagMigrationAssistant\Migration\Logging\Log\ExceptionRunLog; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; @@ -95,8 +96,6 @@ private function copyMediaFiles( MigrationContextInterface $migrationContext, Context $context, ): array { - $connection = $migrationContext->getConnection(); - $installationRoot = $this->getInstallationRoot($migrationContext); $processedMedia = []; $failedMedia = []; @@ -107,12 +106,10 @@ private function copyMediaFiles( if (!\is_file($sourcePath)) { $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry(new CannotGetFileRunLog( - $mappedWorkload[$mediaId]->getRunId(), - $connection->getProfileName(), - $connection->getGatewayName(), - $sourcePath, - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->build(CannotGetFileRunLog::class) + ); $processedMedia[] = $mediaId; $failedMedia[] = $mediaId; @@ -130,12 +127,12 @@ private function copyMediaFiles( $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry(new ExceptionRunLog( - $mappedWorkload[$mediaId]->getRunId(), - $connection->getProfileName(), - $connection->getGatewayName(), - $e, - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withExceptionMessage($e->getMessage()) + ->withExceptionTrace($e->getTrace()) + ->build(ExceptionRunLog::class) + ); } } diff --git a/src/Profile/Shopware6/Converter/DocumentBaseConfigConverter.php b/src/Profile/Shopware6/Converter/DocumentBaseConfigConverter.php index ebcd5e525..72fcb88d0 100644 --- a/src/Profile/Shopware6/Converter/DocumentBaseConfigConverter.php +++ b/src/Profile/Shopware6/Converter/DocumentBaseConfigConverter.php @@ -10,6 +10,7 @@ use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; use SwagMigrationAssistant\Migration\Mapping\Lookup\DocumentTypeLookup; use SwagMigrationAssistant\Migration\Mapping\Lookup\GlobalDocumentBaseConfigLookup; @@ -57,14 +58,10 @@ protected function convertData(array $data): ConvertStruct $converted['documentTypeId'] = $this->documentTypeLookup->get($converted['documentType']['technicalName'], $this->context); if ($converted['documentTypeId'] === null) { - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry(new UnsupportedDocumentTypeLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - $data['documentType']['technicalName'] - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(UnsupportedDocumentTypeLog::class) + ); return new ConvertStruct(null, $data, $converted['id'] ?? null); } diff --git a/src/Profile/Shopware6/Converter/DocumentConverter.php b/src/Profile/Shopware6/Converter/DocumentConverter.php index bcc45aa97..75ad9ca16 100644 --- a/src/Profile/Shopware6/Converter/DocumentConverter.php +++ b/src/Profile/Shopware6/Converter/DocumentConverter.php @@ -10,6 +10,7 @@ use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; use SwagMigrationAssistant\Migration\Mapping\Lookup\DocumentTypeLookup; use SwagMigrationAssistant\Migration\Mapping\MappingServiceInterface; @@ -63,14 +64,10 @@ protected function convertData(array $data): ConvertStruct $converted['documentTypeId'] = $this->documentTypeLookup->get($converted['documentType']['technicalName'], $this->context); if ($converted['documentTypeId'] === null) { - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry(new UnsupportedDocumentTypeLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - $data['documentType']['technicalName'] - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(UnsupportedDocumentTypeLog::class) + ); return new ConvertStruct(null, $data, $this->mainMapping['id'] ?? null); } diff --git a/src/Profile/Shopware6/Converter/MailTemplateConverter.php b/src/Profile/Shopware6/Converter/MailTemplateConverter.php index 6e6699062..d079a2702 100644 --- a/src/Profile/Shopware6/Converter/MailTemplateConverter.php +++ b/src/Profile/Shopware6/Converter/MailTemplateConverter.php @@ -10,13 +10,14 @@ use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; use SwagMigrationAssistant\Migration\Mapping\Lookup\MailTemplateTypeLookup; use SwagMigrationAssistant\Migration\Mapping\Lookup\SystemDefaultMailTemplateLookup; use SwagMigrationAssistant\Migration\Mapping\MappingServiceInterface; use SwagMigrationAssistant\Migration\Media\MediaFileServiceInterface; use SwagMigrationAssistant\Migration\MigrationContextInterface; -use SwagMigrationAssistant\Profile\Shopware\Logging\Log\UnsupportedMailTemplateType; +use SwagMigrationAssistant\Profile\Shopware\Logging\Log\UnsupportedMailTemplateTypeLog; use SwagMigrationAssistant\Profile\Shopware6\DataSelection\DataSet\MailTemplateDataSet; use SwagMigrationAssistant\Profile\Shopware6\Shopware6MajorProfile; @@ -64,15 +65,9 @@ protected function convertData(array $data): ConvertStruct } else { $typeUuid = $this->mailTemplateTypeLookup->get($converted['mailTemplateType']['technicalName'], $this->context); if ($typeUuid === null) { - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry( - new UnsupportedMailTemplateType( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - $converted['mailTemplateType']['technicalName'] - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(UnsupportedMailTemplateTypeLog::class) ); return new ConvertStruct(null, $data, $converted['id'] ?? null); diff --git a/src/Profile/Shopware6/Converter/MediaFolderConverter.php b/src/Profile/Shopware6/Converter/MediaFolderConverter.php index 5cb6c6016..3453c1c18 100644 --- a/src/Profile/Shopware6/Converter/MediaFolderConverter.php +++ b/src/Profile/Shopware6/Converter/MediaFolderConverter.php @@ -10,6 +10,7 @@ use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; use SwagMigrationAssistant\Migration\Mapping\Lookup\MediaDefaultFolderLookup; use SwagMigrationAssistant\Migration\Mapping\Lookup\MediaThumbnailSizeLookup; @@ -58,15 +59,9 @@ protected function convertData(array $data): ConvertStruct $converted['parentId'] = $this->mediaFolderLookup->get($data['defaultFolder']['entity'], $this->context); if ($converted['parentId'] === null) { - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry( - new UnsupportedMediaDefaultFolderLog( - $this->migrationContext->getRunUuid(), - $connection->getProfileName(), - $connection->getGatewayName(), - $data['defaultFolder']['entity'] - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(UnsupportedMediaDefaultFolderLog::class) ); } diff --git a/src/Profile/Shopware6/Converter/NumberRangeConverter.php b/src/Profile/Shopware6/Converter/NumberRangeConverter.php index 8175e8819..b905eab80 100644 --- a/src/Profile/Shopware6/Converter/NumberRangeConverter.php +++ b/src/Profile/Shopware6/Converter/NumberRangeConverter.php @@ -14,6 +14,7 @@ use Shopware\Core\System\NumberRange\Aggregate\NumberRangeState\NumberRangeStateCollection; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; use SwagMigrationAssistant\Migration\Mapping\Lookup\NumberRangeLookup; use SwagMigrationAssistant\Migration\Mapping\Lookup\NumberRangeTypeLookup; @@ -62,15 +63,9 @@ protected function convertData(array $data): ConvertStruct $data['id'] ); - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry( - new UnsupportedNumberRangeTypeLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - $converted['type']['technicalName'] - ) + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(UnsupportedNumberRangeTypeLog::class) ); return new ConvertStruct(null, $data, $this->mainMapping['id'] ?? null); diff --git a/src/Profile/Shopware6/Converter/SalesChannelConverter.php b/src/Profile/Shopware6/Converter/SalesChannelConverter.php index 6bac57c34..cfe101ee8 100644 --- a/src/Profile/Shopware6/Converter/SalesChannelConverter.php +++ b/src/Profile/Shopware6/Converter/SalesChannelConverter.php @@ -132,7 +132,6 @@ protected function convertData(array $data): ConvertStruct } unset( - // ToDo implement if these associations are migrated $converted['mailHeaderFooterId'] ); diff --git a/src/Profile/Shopware6/Converter/ShopwareConverter.php b/src/Profile/Shopware6/Converter/ShopwareConverter.php index 59603d80d..8499a7513 100644 --- a/src/Profile/Shopware6/Converter/ShopwareConverter.php +++ b/src/Profile/Shopware6/Converter/ShopwareConverter.php @@ -12,6 +12,7 @@ use SwagMigrationAssistant\Migration\Converter\Converter; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\Logging\Log\AssociationRequiredMissingLog; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; use SwagMigrationAssistant\Migration\Mapping\MappingServiceInterface; use SwagMigrationAssistant\Migration\MigrationContextInterface; @@ -147,14 +148,10 @@ protected function updateAssociationIds(array &$associationArray, string $entity if (empty($newAssociationId)) { if ($logMissing) { - $connection = $this->migrationContext->getConnection(); - - $this->loggingService->addLogEntry(new AssociationRequiredMissingLog( - $this->runId, - $connection->getProfileName(), - $connection->getGatewayName(), - $sourceEntity - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->build(AssociationRequiredMissingLog::class) + ); } if ($unsetMissing) { diff --git a/src/Profile/Shopware6/Gateway/Connection/AuthClient.php b/src/Profile/Shopware6/Gateway/Connection/AuthClient.php index 281988054..ebb2849ee 100644 --- a/src/Profile/Shopware6/Gateway/Connection/AuthClient.php +++ b/src/Profile/Shopware6/Gateway/Connection/AuthClient.php @@ -98,13 +98,13 @@ private function renewBearerToken(): void $connection = $this->migrationContext->getConnection(); if ($connection === null) { - return; // TODO: throw exception + return; } $credentials = $connection->getCredentialFields(); if ($credentials === null) { - return; // TODO: throw exception + return; } $response = $this->apiClient->post('/api/oauth/token', [ diff --git a/src/Profile/Shopware6/Gateway/Connection/ConnectionFactory.php b/src/Profile/Shopware6/Gateway/Connection/ConnectionFactory.php index 4869e07a5..67e107828 100644 --- a/src/Profile/Shopware6/Gateway/Connection/ConnectionFactory.php +++ b/src/Profile/Shopware6/Gateway/Connection/ConnectionFactory.php @@ -50,7 +50,7 @@ public function createApiClient(MigrationContextInterface $migrationContext): ?H new Client($options), $this->connectionRepository, $migrationContext, - Context::createDefaultContext() // ToDo maybe replace this with the real context from the request, because this could cause caching issues (but it will only write data to DB). + Context::createDefaultContext() ); } } diff --git a/src/Profile/Shopware6/Logging/Log/UnsupportedDocumentTypeLog.php b/src/Profile/Shopware6/Logging/Log/UnsupportedDocumentTypeLog.php index 70f08b20c..757e66603 100644 --- a/src/Profile/Shopware6/Logging/Log/UnsupportedDocumentTypeLog.php +++ b/src/Profile/Shopware6/Logging/Log/UnsupportedDocumentTypeLog.php @@ -8,25 +8,11 @@ namespace SwagMigrationAssistant\Profile\Shopware6\Logging\Log; use Shopware\Core\Framework\Log\Package; -use SwagMigrationAssistant\Migration\Logging\Log\BaseRunLogEntry; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class UnsupportedDocumentTypeLog extends BaseRunLogEntry +readonly class UnsupportedDocumentTypeLog extends AbstractSwagMigrationLogEntry { - public function __construct( - string $runId, - string $profileName, - string $gatewayName, - /** @phpstan-ignore property.onlyWritten */ - private readonly string $technicalName, - ) { - parent::__construct( - $runId, - $profileName, - $gatewayName - ); - } - public function isUserFixable(): bool { return false; diff --git a/src/Profile/Shopware6/Logging/Log/UnsupportedMediaDefaultFolderLog.php b/src/Profile/Shopware6/Logging/Log/UnsupportedMediaDefaultFolderLog.php index 1c9a5a370..a3126791a 100644 --- a/src/Profile/Shopware6/Logging/Log/UnsupportedMediaDefaultFolderLog.php +++ b/src/Profile/Shopware6/Logging/Log/UnsupportedMediaDefaultFolderLog.php @@ -8,25 +8,11 @@ namespace SwagMigrationAssistant\Profile\Shopware6\Logging\Log; use Shopware\Core\Framework\Log\Package; -use SwagMigrationAssistant\Migration\Logging\Log\BaseRunLogEntry; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; #[Package('fundamentals@after-sales')] -class UnsupportedMediaDefaultFolderLog extends BaseRunLogEntry +readonly class UnsupportedMediaDefaultFolderLog extends AbstractSwagMigrationLogEntry { - public function __construct( - string $runId, - string $profileName, - string $gatewayName, - /** @phpstan-ignore property.onlyWritten */ - private readonly string $defaultEntity, - ) { - parent::__construct( - $runId, - $profileName, - $gatewayName - ); - } - public function isUserFixable(): bool { return false; diff --git a/src/Profile/Shopware6/Media/HttpOrderDocumentGenerationService.php b/src/Profile/Shopware6/Media/HttpOrderDocumentGenerationService.php index ae1f07d6b..267ab7c76 100644 --- a/src/Profile/Shopware6/Media/HttpOrderDocumentGenerationService.php +++ b/src/Profile/Shopware6/Media/HttpOrderDocumentGenerationService.php @@ -20,6 +20,7 @@ use SwagMigrationAssistant\Migration\Connection\SwagMigrationConnectionEntity; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; use SwagMigrationAssistant\Migration\Gateway\HttpClientInterface; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Logging\Log\CannotGetFileRunLog; use SwagMigrationAssistant\Migration\Logging\Log\ExceptionRunLog; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; @@ -89,12 +90,14 @@ public function process( $client = $this->connectionFactory->createApiClient($migrationContext); if ($client === null) { - $this->loggingService->addLogEntry(new ExceptionRunLog( - $runId, - $connection->getProfileName(), - $connection->getGatewayName(), - new \Exception('Connection to the source system could not be established') - )); + $exception = new \Exception('Connection to the source system could not be established'); + + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withExceptionMessage($exception->getMessage()) + ->withExceptionTrace($exception->getTrace()) + ->build(ExceptionRunLog::class) + ); $this->loggingService->saveLogging($context); return $workload; @@ -126,7 +129,15 @@ function (MediaProcessWorkloadStruct $work) use ($uuid) { } if ($state !== 'fulfilled') { - $this->handleFailedRequest($oldWorkload, $mappedWorkload[$uuid], $uuid, $additionalData, $failureUuids, $result['reason'] ?? null); + $this->handleFailedRequest( + $migrationContext, + $oldWorkload, + $mappedWorkload[$uuid], + $uuid, + $additionalData, + $failureUuids, + $result['reason'] ?? null + ); continue; } @@ -267,6 +278,7 @@ private function handleCompleteRequest(Context $context, array $result, string $ * @param list $failureUuids */ private function handleFailedRequest( + MigrationContextInterface $migrationContext, MediaProcessWorkloadStruct $oldWorkload, MediaProcessWorkloadStruct &$mappedWorkload, string $uuid, @@ -281,13 +293,12 @@ private function handleFailedRequest( if ($mappedWorkload->getErrorCount() > ProcessMediaHandler::MEDIA_ERROR_THRESHOLD) { $failureUuids[] = $uuid; $mappedWorkload->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry(new CannotGetFileRunLog( - $mappedWorkload->getRunId(), - $this->connection->getProfileName(), - $this->connection->getGatewayName(), - $mappedWorkload->getAdditionalData()['uri'], - $clientException - )); + $this->loggingService->addLogEntry( // TODO: add optional fields + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withExceptionMessage($clientException?->getMessage() ?? 'Unknown error occurred') + ->withExceptionTrace($clientException?->getTrace() ?? []) + ->build(CannotGetFileRunLog::class) + ); } } } diff --git a/tests/Migration/Controller/HistoryControllerTest.php b/tests/Migration/Controller/HistoryControllerTest.php index fb0222050..4f7929e42 100644 --- a/tests/Migration/Controller/HistoryControllerTest.php +++ b/tests/Migration/Controller/HistoryControllerTest.php @@ -19,7 +19,7 @@ use SwagMigrationAssistant\Controller\HistoryController; use SwagMigrationAssistant\Migration\History\HistoryService; use SwagMigrationAssistant\Migration\History\HistoryServiceInterface; -use SwagMigrationAssistant\Migration\Logging\Log\LogEntryInterface; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; use SwagMigrationAssistant\Migration\Logging\SwagMigrationLoggingCollection; use SwagMigrationAssistant\Migration\MigrationContext; use SwagMigrationAssistant\Migration\Run\MigrationStep; @@ -102,7 +102,7 @@ protected function setUp(): void 'runId' => $this->runUuid, 'profileName' => Shopware55Profile::PROFILE_NAME, 'gatewayName' => ShopwareLocalGateway::GATEWAY_NAME, - 'level' => LogEntryInterface::LOG_LEVEL_ERROR, + 'level' => AbstractSwagMigrationLogEntry::LOG_LEVEL_ERROR, 'code' => 'migration_error_1', 'userFixable' => false, ], diff --git a/tests/Migration/Logging/LoggingServiceTest.php b/tests/Migration/Logging/LoggingServiceTest.php index 5b633be76..61db1c4e5 100644 --- a/tests/Migration/Logging/LoggingServiceTest.php +++ b/tests/Migration/Logging/LoggingServiceTest.php @@ -15,9 +15,9 @@ use Shopware\Core\Framework\Log\Package; use Shopware\Core\Framework\Test\TestCaseBase\IntegrationTestBehaviour; use Shopware\Core\Framework\Uuid\Uuid; -use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; use SwagMigrationAssistant\Migration\Logging\Log\AssociationRequiredMissingLog; -use SwagMigrationAssistant\Migration\Logging\Log\CannotConvertChildEntity; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; +use SwagMigrationAssistant\Migration\Logging\Log\CannotConvertChildEntityLog; use SwagMigrationAssistant\Migration\Logging\LoggingService; use SwagMigrationAssistant\Migration\Logging\SwagMigrationLoggingCollection; use SwagMigrationAssistant\Migration\Run\MigrationStep; @@ -60,8 +60,16 @@ protected function setUp(): void public function testAddLogEntry(): void { - $log1 = new AssociationRequiredMissingLog($this->runUuid, 'Profile name', 'Gateway name', DefaultEntities::PRODUCT_MANUFACTURER); - $log2 = new CannotConvertChildEntity($this->runUuid, 'Profile name', 'Gateway name', DefaultEntities::PRODUCT, '200'); + $log1 = (new SwagMigrationLogBuilder( + $this->runUuid, + 'Profile name', + 'Gateway name', + ))->build(AssociationRequiredMissingLog::class); + $log2 = (new SwagMigrationLogBuilder( + $this->runUuid, + 'Profile name', + 'Gateway name', + ))->build(CannotConvertChildEntityLog::class); $this->loggingService->addLogEntry($log1); $this->loggingService->addLogEntry($log2); diff --git a/tests/Migration/Media/Process/HttpDownloadServiceBaseTest.php b/tests/Migration/Media/Process/HttpDownloadServiceBaseTest.php index 9f6c9da05..478997d72 100644 --- a/tests/Migration/Media/Process/HttpDownloadServiceBaseTest.php +++ b/tests/Migration/Media/Process/HttpDownloadServiceBaseTest.php @@ -196,12 +196,20 @@ public function testProcessWithRequestFailure(): void ], $resultWorkload); static::assertEquals([ [ - 'runId' => $this->runId, + 'runId' => $this->migrationContext->getRunUuid(), 'level' => 'warning', 'code' => 'SWAG_MIGRATION_CANNOT_GET_FILE', 'profileName' => '', 'gatewayName' => '', 'userFixable' => false, + 'entityName' => null, + 'fieldName' => null, + 'fieldSourcePath' => null, + 'sourceData' => null, + 'convertedData' => null, + 'usedMapping' => null, + 'exceptionMessage' => null, + 'exceptionTrace' => null, ], ], $this->loggingService->getLoggingArray()); } diff --git a/tests/Migration/Services/MigrationDataProcessingTest.php b/tests/Migration/Services/MigrationDataProcessingTest.php index 169ea5293..c5de03b02 100644 --- a/tests/Migration/Services/MigrationDataProcessingTest.php +++ b/tests/Migration/Services/MigrationDataProcessingTest.php @@ -29,7 +29,7 @@ use SwagMigrationAssistant\Migration\Data\SwagMigrationDataDefinition; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; use SwagMigrationAssistant\Migration\Gateway\Reader\ReaderRegistry; -use SwagMigrationAssistant\Migration\Logging\Log\LogEntryInterface; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry; use SwagMigrationAssistant\Migration\Logging\SwagMigrationLoggingCollection; use SwagMigrationAssistant\Migration\Mapping\MappingService; use SwagMigrationAssistant\Migration\Mapping\SwagMigrationMappingDefinition; @@ -348,8 +348,8 @@ public function testFetchInvalidCustomerData(): void $type = $log->getLevel(); if ( - ($type === LogEntryInterface::LOG_LEVEL_INFO && $log->getCode() === 'SWAG_MIGRATION_ENTITY_FIELD_REASSIGNED') - || ($type === LogEntryInterface::LOG_LEVEL_WARNING && $log->getCode() === 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD') + ($type === AbstractSwagMigrationLogEntry::LOG_LEVEL_INFO && $log->getCode() === 'SWAG_MIGRATION_ENTITY_FIELD_REASSIGNED') + || ($type === AbstractSwagMigrationLogEntry::LOG_LEVEL_WARNING && $log->getCode() === 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD') ) { ++$countValidLogging; diff --git a/tests/Profile/Shopware54/Converter/OrderDocumentConverterTest.php b/tests/Profile/Shopware54/Converter/OrderDocumentConverterTest.php index bd4faab9e..9e0017e60 100644 --- a/tests/Profile/Shopware54/Converter/OrderDocumentConverterTest.php +++ b/tests/Profile/Shopware54/Converter/OrderDocumentConverterTest.php @@ -15,7 +15,8 @@ use Shopware\Core\Framework\Uuid\Uuid; use SwagMigrationAssistant\Migration\Connection\SwagMigrationConnectionEntity; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; -use SwagMigrationAssistant\Migration\Logging\Log\DocumentTypeNotSupported; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; +use SwagMigrationAssistant\Migration\Logging\Log\DocumentTypeNotSupportedLog; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; use SwagMigrationAssistant\Migration\Mapping\Lookup\DocumentTypeLookup; use SwagMigrationAssistant\Migration\Mapping\Lookup\MediaDefaultFolderLookup; @@ -174,12 +175,13 @@ public function testConvertShouldLogUnknownType(): void foreach ($orderDocumentConverterClasses as $orderDocumentConverterClass => $expected) { $loggerMock = $this->createMock(LoggingServiceInterface::class); - $loggerMock->expects(static::exactly(1))->method('addLogEntry')->with(new DocumentTypeNotSupported( - $this->runId, - Shopware54Profile::PROFILE_NAME, - ShopwareLocalGateway::GATEWAY_NAME, - $expected - )); + $loggerMock->expects(static::exactly(1))->method('addLogEntry')->with( + (new SwagMigrationLogBuilder( + $this->runId, + Shopware54Profile::PROFILE_NAME, + ShopwareLocalGateway::GATEWAY_NAME + ))->build(DocumentTypeNotSupportedLog::class) + ); $orderDocumentConverter = $this->createDocumentConverter($orderDocumentConverterClass, $mappingServiceMock, $loggerMock); $convertResult = $orderDocumentConverter->convert( diff --git a/tests/Profile/Shopware55/Converter/ShippingMethodConverterTest.php b/tests/Profile/Shopware55/Converter/ShippingMethodConverterTest.php index 9b49a7e1a..6cf42e995 100644 --- a/tests/Profile/Shopware55/Converter/ShippingMethodConverterTest.php +++ b/tests/Profile/Shopware55/Converter/ShippingMethodConverterTest.php @@ -21,12 +21,13 @@ use Shopware\Core\System\Locale\LocaleEntity; use SwagMigrationAssistant\Migration\Connection\SwagMigrationConnectionEntity; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; +use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; use SwagMigrationAssistant\Migration\Mapping\Lookup\CountryLookup; use SwagMigrationAssistant\Migration\Mapping\Lookup\LanguageLookup; use SwagMigrationAssistant\Migration\MigrationContext; use SwagMigrationAssistant\Profile\Shopware\Converter\ShippingMethodConverter; use SwagMigrationAssistant\Profile\Shopware\DataSelection\DataSet\ShippingMethodDataSet; -use SwagMigrationAssistant\Profile\Shopware\Logging\Log\UnsupportedShippingCalculationType; +use SwagMigrationAssistant\Profile\Shopware\Logging\Log\UnsupportedShippingCalculationTypeLog; use SwagMigrationAssistant\Profile\Shopware\Logging\Log\UnsupportedShippingPriceLog; use SwagMigrationAssistant\Profile\Shopware\Premapping\DefaultShippingAvailabilityRuleReader; use SwagMigrationAssistant\Profile\Shopware\Premapping\DeliveryTimeReader; @@ -160,7 +161,9 @@ public function testConvertWithInvalidCalculation(): void $convertResult = $this->shippingMethodConverter->convert($shippingMethodData[0], $this->context, $this->migrationContext); $logs = $this->loggingService->getLoggingArray(); - $error = new UnsupportedShippingCalculationType('', 'Profile name', 'Gateway name', '5'); + + $error = (new SwagMigrationLogBuilder('', 'Profile name', 'Gateway name')) + ->build(UnsupportedShippingCalculationTypeLog::class); static::assertNull($convertResult->getUnmapped()); static::assertNotNull($convertResult->getConverted()); @@ -175,7 +178,9 @@ public function testConvertWithFactor(): void $convertResult = $this->shippingMethodConverter->convert($shippingMethodData[0], $this->context, $this->migrationContext); $logs = $this->loggingService->getLoggingArray(); - $error = new UnsupportedShippingPriceLog('', 'Profile name', 'Gateway name', '15'); + + $error = (new SwagMigrationLogBuilder('', 'Profile name', 'Gateway name')) + ->build(UnsupportedShippingPriceLog::class); static::assertNull($convertResult->getUnmapped()); static::assertNotNull($convertResult->getConverted()); diff --git a/tests/testData/sw55.sql b/tests/_fixtures/database/sw55.sql similarity index 100% rename from tests/testData/sw55.sql rename to tests/_fixtures/database/sw55.sql From 638b84db0b185fa985a28b92a386a6fb09048e9d Mon Sep 17 00:00:00 2001 From: Lars Kemper Date: Tue, 26 Aug 2025 09:20:10 +0200 Subject: [PATCH 03/46] refactor!: migration connection usage (#43) --- CHANGELOG.md | 5 ++ CHANGELOG_de-DE.md | 5 ++ UPGRADE.md | 69 +++++++++++++++++ phpstan.neon.dist | 10 --- src/Controller/StatusController.php | 8 +- src/Migration/Converter/Converter.php | 3 +- src/Migration/Converter/ConverterRegistry.php | 7 +- src/Migration/Gateway/GatewayInterface.php | 3 +- src/Migration/Gateway/GatewayRegistry.php | 11 +-- .../Gateway/GatewayRegistryInterface.php | 3 +- .../Media/MediaFileProcessorRegistry.php | 9 +-- .../Handler/Processor/AbortingProcessor.php | 5 -- src/Migration/MigrationContext.php | 74 ++++++++++--------- src/Migration/MigrationContextFactory.php | 47 +++++++----- .../MigrationContextFactoryInterface.php | 2 - src/Migration/MigrationContextInterface.php | 14 +++- .../Premapping/AbstractPremappingReader.php | 6 +- .../Service/MigrationDataConverter.php | 5 +- src/Migration/Service/MigrationDataWriter.php | 7 +- src/Migration/Service/PremappingService.php | 19 +---- .../Shopware/Converter/AttributeConverter.php | 8 +- .../Shopware/Converter/CategoryConverter.php | 8 +- .../Converter/CrossSellingConverter.php | 5 +- .../Shopware/Converter/CurrencyConverter.php | 5 +- .../Shopware/Converter/CustomerConverter.php | 8 +- .../Converter/CustomerGroupConverter.php | 8 +- .../Converter/CustomerWishlistConverter.php | 5 +- .../Shopware/Converter/LanguageConverter.php | 5 +- .../MainVariantRelationConverter.php | 4 +- .../Shopware/Converter/MediaConverter.php | 5 +- .../Converter/MediaFolderConverter.php | 5 +- .../NewsletterRecipientConverter.php | 5 +- .../Converter/NumberRangeConverter.php | 3 - .../Shopware/Converter/OrderConverter.php | 8 +- .../Converter/OrderDocumentConverter.php | 8 +- .../Shopware/Converter/ProductConverter.php | 8 +- .../ProductOptionRelationConverter.php | 5 +- .../ProductPropertyRelationConverter.php | 5 +- .../Shopware/Converter/PromotionConverter.php | 5 +- .../PropertyGroupOptionConverter.php | 5 +- .../Converter/SalesChannelConverter.php | 5 +- .../Shopware/Converter/SeoUrlConverter.php | 5 +- .../Converter/ShippingMethodConverter.php | 5 +- .../Shopware/Converter/ShopwareConverter.php | 2 +- .../Converter/TranslationConverter.php | 12 +-- .../Gateway/Api/ShopwareApiGateway.php | 21 +----- .../Gateway/Connection/ConnectionFactory.php | 16 +--- .../Gateway/Local/ShopwareLocalGateway.php | 5 +- .../Media/LocalOrderDocumentProcessor.php | 7 +- .../Media/LocalProductDownloadProcessor.php | 7 +- .../Media/Strategy/Md5StrategyResolver.php | 7 +- .../Media/Strategy/PlainStrategyResolver.php | 7 +- .../DefaultShippingAvailabilityRuleReader.php | 7 +- .../Premapping/DeliveryTimeReader.php | 7 +- .../NewsletterRecipientStatusReader.php | 7 +- .../Shopware6/Converter/ShopwareConverter.php | 5 +- .../Gateway/Api/Shopware6ApiGateway.php | 20 +---- .../Gateway/Connection/AuthClient.php | 38 +++------- .../Gateway/Connection/ConnectionFactory.php | 8 +- .../HttpOrderDocumentGenerationService.php | 8 +- tests/LocalConnectionTestCase.php | 14 ++-- .../Converter/ConverterRegistryTest.php | 10 ++- .../DataSelectionRegistryTest.php | 16 ++-- .../DataSelection/DataSetRegistryTest.php | 10 ++- .../Migration/Gateway/GatewayServiceTest.php | 5 +- .../Media/MediaFileProcessorRegistryTest.php | 4 +- .../Process/HttpDownloadServiceBaseTest.php | 5 +- .../Handler/MigrationProcessHandlerTest.php | 6 +- .../Processor/AbortingProcessorTest.php | 2 +- .../Processor/CleanUpProcessorTest.php | 2 +- .../Processor/FetchingProcessorTest.php | 24 +++++- .../Processor/IndexingProcessorTest.php | 4 +- .../MediaProcessingProcessorTest.php | 10 ++- .../Processor/WritingProcessorTest.php | 4 +- .../Services/MigrationDataProcessingTest.php | 35 +++++---- .../Services/MigrationDataWriterTest.php | 55 ++++++++------ tests/Migration/Services/RunServiceTest.php | 2 +- .../Gateway/Dummy/Local/DummyLocalGateway.php | 5 +- .../Gateway/ApiEnvironmentReaderTest.php | 8 +- .../Shopware/Gateway/ApiReaderTest.php | 9 ++- .../Local/CategoryAttributeReaderTest.php | 5 +- .../Gateway/Local/CategoryReaderTest.php | 10 ++- .../Gateway/Local/CurrencyReaderTest.php | 5 +- .../Local/CustomerAttributeReaderTest.php | 5 +- .../CustomerGroupAttributeReaderTest.php | 5 +- .../Gateway/Local/CustomerGroupReaderTest.php | 5 +- .../Gateway/Local/CustomerReaderTest.php | 5 +- .../Gateway/Local/EnvironmentReaderTest.php | 5 +- .../Gateway/Local/LanguageReaderTest.php | 5 +- .../Local/MainVariantRelationReaderTest.php | 5 +- .../Local/ManufacturerAttributeReaderTest.php | 5 +- .../Gateway/Local/MediaAlbumReaderTest.php | 5 +- .../Gateway/Local/MediaReaderTest.php | 5 +- .../Local/NewsletterRecipientReaderTest.php | 5 +- .../Gateway/Local/NumberRangeReaderTest.php | 10 ++- .../Local/OrderAttributeReaderTest.php | 5 +- .../OrderDocumentAttributeReaderTest.php | 5 +- .../Gateway/Local/OrderDocumentReaderTest.php | 5 +- .../Gateway/Local/OrderReaderTest.php | 5 +- .../Local/ProductAttributeReaderTest.php | 5 +- .../Local/ProductPriceAttributeReaderTest.php | 5 +- .../Gateway/Local/ProductReviewReaderTest.php | 5 +- .../Local/PropertyGroupOptionReaderTest.php | 5 +- .../Gateway/Local/SalesChannelReaderTest.php | 5 +- .../Local/ShippingMethodReaderTest.php | 5 +- .../Gateway/Local/TableReaderTest.php | 5 +- .../Gateway/Local/TranslationReaderTest.php | 5 +- .../Shopware/Gateway/LocalGatewayTest.php | 12 +-- .../Gateway/ShopwareApiGatewayTest.php | 13 ++-- ...aultShippingAvailabilityRuleReaderTest.php | 15 ++-- .../Premapping/DeliveryTimeReaderTest.php | 7 +- .../NewsletterRecipientStatusReaderTest.php | 4 +- .../OrderDeliveryStateReaderTest.php | 2 +- .../Premapping/OrderStateReaderTest.php | 2 +- .../Premapping/PaymentMethodReaderTest.php | 2 +- .../Premapping/SalutationReaderTest.php | 3 +- .../Premapping/TransactionStateReaderTest.php | 3 +- .../Converter/OrderDocumentConverterTest.php | 5 +- .../Converter/ProductConverterTest.php | 5 +- .../CategoryAttributeConverterTest.php | 5 +- .../Converter/CategoryConverterTest.php | 5 +- .../Converter/CrossSellingConverterTest.php | 5 +- .../Converter/CurrencyConverterTest.php | 5 +- .../CustomerAttributeConverterTest.php | 5 +- .../Converter/CustomerConverterTest.php | 5 +- .../CustomerGroupAttributeConverterTest.php | 5 +- .../Converter/CustomerGroupConverterTest.php | 5 +- .../CustomerWishlistConverterTest.php | 5 +- .../Converter/LanguageConverterTest.php | 5 +- .../MainVariantRelationConverterTest.php | 5 +- .../ManufacturerAttributeConverterTest.php | 5 +- .../Converter/MediaConverterTest.php | 5 +- .../Converter/MediaFolderConverterTest.php | 5 +- .../NewsletterRecipientConverterTest.php | 5 +- .../Converter/NumberRangeConverterTest.php | 5 +- .../Converter/OrderAttributeConverterTest.php | 5 +- .../Converter/OrderConverterTest.php | 10 ++- .../ProductAttributeConverterTest.php | 5 +- .../Converter/ProductConverterTest.php | 5 +- .../ProductOptionRelationConverterTest.php | 5 +- .../ProductPriceAttributeConverterTest.php | 5 +- .../ProductPropertyRelationConverterTest.php | 5 +- .../Converter/ProductReviewConverterTest.php | 5 +- .../Converter/PromotionConverterTest.php | 5 +- .../PropertyGroupOptionConverterTest.php | 5 +- .../Converter/SalesChannelConverterTest.php | 5 +- .../Converter/ShippingMethodConverterTest.php | 5 +- .../Converter/TranslationConverterTest.php | 15 ++-- .../ProductAttributeConverterTest.php | 5 +- .../LanguageConverterConvertDataTest.php | 5 +- .../SeoUrlConverterConvertDataTest.php | 5 +- .../Converter/ShopwareConverterTest.php | 12 +-- .../Api/Reader/EnvironmentReaderTest.php | 10 ++- .../Gateway/Api/Shopware6ApiGatewayTest.php | 5 +- .../Connection/ConnectionFactoryTests.php | 2 +- .../Shopware6/Premapping/UserReaderTest.php | 2 +- 156 files changed, 649 insertions(+), 634 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa953bd64..deae4c9e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 16.0.0 +- [BREAKING] [#38](https://github.com/shopware/SwagMigrationAssistant/pull/38) feat!: add migration logging required fields +- [BREAKING] [#40](https://github.com/shopware/SwagMigrationAssistant/pull/40) refactor!: add migration logging optional fields +- [BREAKING] [#43](https://github.com/shopware/SwagMigrationAssistant/pull/43) refactor!: migration connection usage + # 15.0.3 - Fixed translations of error groups missing details like the entity - Fixed handling of customers without default payment method in SW6.7 migrations diff --git a/CHANGELOG_de-DE.md b/CHANGELOG_de-DE.md index 639bea015..bb81e7eeb 100644 --- a/CHANGELOG_de-DE.md +++ b/CHANGELOG_de-DE.md @@ -1,3 +1,8 @@ +# 16.0.0 +- [BREAKING] [#38](https://github.com/shopware/SwagMigrationAssistant/pull/38) feat!: Erforderliche Felder für Migrationsprotokollierung hinzufügen +- [BREAKING] [#40](https://github.com/shopware/SwagMigrationAssistant/pull/40) refactor!: Optionale Felder für Migrationsprotokollierung hinzufügen +- [BREAKING] [#43](https://github.com/shopware/SwagMigrationAssistant/pull/43) refactor!: Nutzung der Migrationsverbindung + # 15.0.3 - Übersetzungen von Fehlergruppen behoben, welche Details wie den Entitätsnamen nicht darstellten - Fehler bei Kunden ohne Standardzahlungsmethode in SW6.7 Migrationen behoben diff --git a/UPGRADE.md b/UPGRADE.md index df5a396fe..efde4f2d8 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,3 +1,72 @@ +# 16.0.0 + +- [BREAKING] [#38](https://github.com/shopware/SwagMigrationAssistant/pull/38) - feat!: add migration logging required fields + - [BREAKING] Truncated database entries of `swag_migration_logging` with `SwagMigrationAssistant\Core\Migration\Migration1754896654TruncateMigrationLogs` + - [BREAKING] Deleted columns `title`, `description`, `paramenters`, `title_snippet`, `description_snippet`, `entity` and `source_id` from `swag_migration_logging` with `SwagMigrationAssistant\Core\Migration\Migration1754897550AddRequiredFieldsToMigrationLogs` + - [BREAKING] Removed fields `title`, `description`, `parameters`, `title_snippet`, `description_snippet`, `entity` and `source_id` from log definition `SwagMigrationAssistant\Migration\Logging\SwagMigrationLoggingDefinition` + - [BREAKING] Removed properties `title`, `description`, `parameters`, `titleSnippet`, `descriptionSnippet`, `entity` and `sourceId` from log entity `SwagMigrationAssistant\Migration\Logging\SwagMigrationLoggingEntity` + - [BREAKING] Removed aggregations of `titleSnippet`, `entity` and `level` in `SwagMigrationAssistant\Migration\History\HistoryService` + - [BREAKING] Updated all log implementations in `SwagMigrationAssistant\Migration\Logging\Log\*` and `SwagMigrationAssistant\Profile\**\Logging\*`: + - deleted methods `getTitle()`, `getTitleSnippet()`, `getDescription()`, `getDescriptionSnippet()`, `getParameters()`, `getSourceId()` + - add method `isUserFixable()` + - Added columns `profile_name`, `gateway_name` and `user_fixable` to `swag_migration_logging` with `SwagMigrationAssistant\Core\Migration\Migration1754897550AddRequiredFieldsToMigrationLogs` + - Added fields `profile_name`, `gateway_name` and `user_fixable` to log definition `SwagMigrationAssistant\Migration\Logging\SwagMigrationLoggingDefinition` + - Added properties `profileName`, `gatewayName` and `userFixable` to log entity `SwagMigrationAssistant\Migration\Logging\SwagMigrationLoggingEntity` + +- [BREAKING] [#40](https://github.com/shopware/SwagMigrationAssistant/pull/40) - refactor!: add migration logging optional fields + - [BREAKING] Replaced `SwagMigrationAssistant\Migration\Logging\Log\BaseRunLogEntity` with `SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry` + - [BREAKING] Replaced `SwagMigrationAssistant\Migration\Logging\Log\LogEntryInterface` with `SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogEntry` + - [BREAKING] Updated all log implementations in `SwagMigrationAssistant\Migration\Logging\Log\*` and `SwagMigrationAssistant\Profile\**\Logging\*`: + - extend `SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry` instead of `SwagMigrationAssistant\Migration\Logging\Log\BaseRunLogEntity` + - implement `SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogEntry` instead of `SwagMigrationAssistant\Migration\Logging\Log\LogEntryInterface` + - mark class readonly + - [BREAKING] Renamed log classes to include `Log` suffix + - `SwagMigrationAssistant\Migration\Logging\LogCannotConvertChildEntity`, + - `SwagMigrationAssistant\Migration\Logging\LogCannotConvertEntity`, + - `SwagMigrationAssistant\Migration\Logging\LogDocumentTypeNotSupported`, + - `SwagMigrationAssistant\Migration\Logging\LogInvalidUnserializedData`, + - `SwagMigrationAssistant\Migration\Logging\LogInvalidUnserializedData`, + - `SwagMigrationAssistant\Migration\Logging\LogRunAbortedAutomatically` + - `SwagMigrationAssistant\Migration\Logging\LogUnsupportedObjectType` + - [BREAKING] Change method `addLogEntry()` of `SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface` and implementation `LoggingService` to require `SwagMigrationLogEntry` as parameter instead of `LogEntryInterface` + - Created `SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder` to build log entries of type `SwagMigrationLogEntry` + - Added columns to `swag_migration_logging` with `SwagMigrationAssistant\Core\Migration\Migration1754897550AddRequiredFieldsToMigrationLogs`: + - `entity_name` + - `field_name` + - `field_source_path` + - `source_data` + - `converted_data` + - `used_mapping` + - `exception_message` + - `exception_trace` + - Added fields to `swag_migration_logging` to log definition `SwagMigrationAssistant\Migration\Logging\SwagMigrationLoggingDefinition`: + - `entity_name` + - `field_name` + - `field_source_path` + - `source_data` + - `converted_data` + - `used_mapping` + - `exception_message` + - `exception_trace` + - Added properties and methods to log entity `SwagMigrationAssistant\Migration\Logging\SwagMigrationLoggingEntity`: + - `entityName` and `getEntityName()` + - `fieldName` and `getFieldName()` + - `fieldSourcePath` and `getFieldSourcePath()` + - `sourceData` and `getSourceData()` + - `convertedData` and `getConvertedData()` + - `usedMapping` and `getUsedMapping()` + - `exceptionMessage` and `getExceptionMessage()` + - `exceptionTrace` and `getExceptionTrace()` + +- [BREAKING] [#43](https://github.com/shopware/SwagMigrationAssistant/pull/43) refactor!: migration connection usage + - Changed signature of method `supports()` in `SwagMigrationAssistant\Migration\Gateway\GatewayInterface` to require `ProfileInterface` as parameter instead of `MigrationContextInterface` + - Changed signature of method `getGateways()` in `SwagMigrationAssistant\Migration\Gateway\GatewayRegistryInterface` to require `ProfileInterface` as parameter instead of `MigrationContextInterface` + - Changed signature of method `getGateways()` in `SwagMigrationAssistant\Migration\Gateway\GatewayRegistry` to require `ProfileInterface` as parameter instead of `MigrationContextInterface` + - Changed signature of constructor method of `SwagMigrationAssistant\Migration\MigrationContext` to require `SwagMigrationConnectionEntity` and additional optional parameter of `ProfileInterface` with default value `null` + - Added methods `setProfile()`, `getGateway()`, `setGateway()` and `setConnection()` to `SwagMigrationAssistant\Migration\MigrationContextInterface` + - Added methods `setProfile()`, `getGateway()`, `setGateway()` and `setConnection()` to `SwagMigrationAssistant\Migration\MigrationContext` + - Added null checks to methods `getProfile()` and `getGateway()` in `SwagMigrationAssistant\Migration\MigrationContext` to ensure that a profile and gateway is set before usage + # 14.0.0 - [BREAKING] MIG-1053 - Removed ability to set the `verify` flag for the guzzle API client. This is now always true by default. - [BREAKING] MIG-1053 - Refactored both Shopware 5 and Shopware 6 EnvironmentReader classes to provide more information about exceptions. diff --git a/phpstan.neon.dist b/phpstan.neon.dist index cfb461fc5..6eba37fa9 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -54,16 +54,6 @@ parameters: paths: - tests/**/*Test.php - - # TODO remove with #11883 - message: '#Strict comparison using === between SwagMigrationAssistant\\Migration\\Connection\\SwagMigrationConnectionEntity and null will always evaluate to false\.#' - paths: - - **/*.php - - - # TODO remove with #11883 - message: '#Strict comparison using !== between SwagMigrationAssistant\\Migration\\Connection\\SwagMigrationConnectionEntity and null will always evaluate to true\.#' - paths: - - **/*.php - rules: # Shopware core rules - Shopware\Core\DevOps\StaticAnalyze\PHPStan\Rules\Deprecation\DeprecatedMethodsThrowDeprecationRule diff --git a/src/Controller/StatusController.php b/src/Controller/StatusController.php index 4239acd5e..cdd95de87 100644 --- a/src/Controller/StatusController.php +++ b/src/Controller/StatusController.php @@ -87,8 +87,8 @@ public function getProfileInformation(Request $request): Response return new Response(); } - $migrationContext = $this->migrationContextFactory->createByProfileName($profileName); - $gateways = $this->gatewayRegistry->getGateways($migrationContext); + $profile = $this->profileRegistry->getProfile($profileName); + $gateways = $this->gatewayRegistry->getGateways($profile); $currentGateway = null; foreach ($gateways as $gateway) { @@ -151,8 +151,8 @@ public function getGateways(Request $request): JsonResponse throw RoutingException::missingRequestParameter('profileName'); } - $migrationContext = $this->migrationContextFactory->createByProfileName($profileName); - $gateways = $this->gatewayRegistry->getGateways($migrationContext); + $profile = $this->profileRegistry->getProfile($profileName); + $gateways = $this->gatewayRegistry->getGateways($profile); $gatewayNames = []; foreach ($gateways as $gateway) { diff --git a/src/Migration/Converter/Converter.php b/src/Migration/Converter/Converter.php index 5c4ee2cc2..c5460def6 100644 --- a/src/Migration/Converter/Converter.php +++ b/src/Migration/Converter/Converter.php @@ -76,7 +76,8 @@ protected function updateMainMapping(MigrationContextInterface $migrationContext $dataSet = $migrationContext->getDataSet(); $connection = $migrationContext->getConnection(); - if ($dataSet === null || $connection === null) { + + if ($dataSet === null) { return; } diff --git a/src/Migration/Converter/ConverterRegistry.php b/src/Migration/Converter/ConverterRegistry.php index 77a328830..86a11f66e 100644 --- a/src/Migration/Converter/ConverterRegistry.php +++ b/src/Migration/Converter/ConverterRegistry.php @@ -33,11 +33,6 @@ public function getConverter(MigrationContextInterface $migrationContext): Conve } } - $connection = $migrationContext->getConnection(); - if ($connection === null) { - throw MigrationException::migrationContextPropertyMissing('Connection'); - } - - throw MigrationException::converterNotFound($connection->getProfileName()); + throw MigrationException::converterNotFound($migrationContext->getProfile()->getName()); } } diff --git a/src/Migration/Gateway/GatewayInterface.php b/src/Migration/Gateway/GatewayInterface.php index ff489dd40..f875cb65f 100644 --- a/src/Migration/Gateway/GatewayInterface.php +++ b/src/Migration/Gateway/GatewayInterface.php @@ -11,6 +11,7 @@ use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Migration\EnvironmentInformation; use SwagMigrationAssistant\Migration\MigrationContextInterface; +use SwagMigrationAssistant\Migration\Profile\ProfileInterface; use SwagMigrationAssistant\Migration\TotalStruct; #[Package('fundamentals@after-sales')] @@ -23,7 +24,7 @@ public function getSnippetName(): string; /** * Identifier for a gateway registry */ - public function supports(MigrationContextInterface $migrationContext): bool; + public function supports(ProfileInterface $profile): bool; /** * Reads the given entity type from via context from its connection and returns the data diff --git a/src/Migration/Gateway/GatewayRegistry.php b/src/Migration/Gateway/GatewayRegistry.php index 7ba39d663..87074edd8 100644 --- a/src/Migration/Gateway/GatewayRegistry.php +++ b/src/Migration/Gateway/GatewayRegistry.php @@ -10,6 +10,7 @@ use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Exception\MigrationException; use SwagMigrationAssistant\Migration\MigrationContextInterface; +use SwagMigrationAssistant\Migration\Profile\ProfileInterface; #[Package('fundamentals@after-sales')] class GatewayRegistry implements GatewayRegistryInterface @@ -24,11 +25,11 @@ public function __construct(private readonly iterable $gateways) /** * @return GatewayInterface[] */ - public function getGateways(MigrationContextInterface $migrationContext): array + public function getGateways(ProfileInterface $profile): array { $gateways = []; foreach ($this->gateways as $gateway) { - if ($gateway->supports($migrationContext)) { + if ($gateway->supports($profile)) { $gateways[] = $gateway; } } @@ -39,15 +40,11 @@ public function getGateways(MigrationContextInterface $migrationContext): array public function getGateway(MigrationContextInterface $migrationContext): GatewayInterface { $connection = $migrationContext->getConnection(); - if ($connection === null) { - throw MigrationException::migrationContextPropertyMissing('Connection'); - } - $profileName = $connection->getProfileName(); $gatewayName = $connection->getGatewayName(); foreach ($this->gateways as $gateway) { - if ($gateway->supports($migrationContext) && $gateway->getName() === $gatewayName) { + if ($gateway->supports($migrationContext->getProfile()) && $gateway->getName() === $gatewayName) { return $gateway; } } diff --git a/src/Migration/Gateway/GatewayRegistryInterface.php b/src/Migration/Gateway/GatewayRegistryInterface.php index 9a6eb5548..9391bcd71 100644 --- a/src/Migration/Gateway/GatewayRegistryInterface.php +++ b/src/Migration/Gateway/GatewayRegistryInterface.php @@ -9,6 +9,7 @@ use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Migration\MigrationContextInterface; +use SwagMigrationAssistant\Migration\Profile\ProfileInterface; #[Package('fundamentals@after-sales')] interface GatewayRegistryInterface @@ -16,7 +17,7 @@ interface GatewayRegistryInterface /** * @return GatewayInterface[] */ - public function getGateways(MigrationContextInterface $migrationContext): array; + public function getGateways(ProfileInterface $profile): array; /** * Selects the correct gateway by the given migration context diff --git a/src/Migration/Media/MediaFileProcessorRegistry.php b/src/Migration/Media/MediaFileProcessorRegistry.php index eb2cd770d..44b431fd2 100644 --- a/src/Migration/Media/MediaFileProcessorRegistry.php +++ b/src/Migration/Media/MediaFileProcessorRegistry.php @@ -9,7 +9,6 @@ use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Exception\MigrationException; -use SwagMigrationAssistant\Migration\Connection\SwagMigrationConnectionEntity; use SwagMigrationAssistant\Migration\MigrationContextInterface; #[Package('fundamentals@after-sales')] @@ -34,10 +33,10 @@ public function getProcessor(MigrationContextInterface $migrationContext): Media } $connection = $migrationContext->getConnection(); - if ($connection === null) { - throw MigrationException::entityNotExists(SwagMigrationConnectionEntity::class, $migrationContext->getRunUuid()); - } - throw MigrationException::processorNotFound($connection->getProfileName(), $connection->getGatewayName()); + throw MigrationException::processorNotFound( + $connection->getProfileName(), + $connection->getGatewayName() + ); } } diff --git a/src/Migration/MessageQueue/Handler/Processor/AbortingProcessor.php b/src/Migration/MessageQueue/Handler/Processor/AbortingProcessor.php index 467a4c490..bf2a1773d 100644 --- a/src/Migration/MessageQueue/Handler/Processor/AbortingProcessor.php +++ b/src/Migration/MessageQueue/Handler/Processor/AbortingProcessor.php @@ -10,7 +10,6 @@ use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\Log\Package; -use SwagMigrationAssistant\Exception\MigrationException; use SwagMigrationAssistant\Migration\Data\SwagMigrationDataCollection; use SwagMigrationAssistant\Migration\Media\SwagMigrationMediaFileCollection; use SwagMigrationAssistant\Migration\MessageQueue\Message\MigrationProcessMessage; @@ -59,10 +58,6 @@ public function process( MigrationProgress $progress, ): void { $connection = $migrationContext->getConnection(); - if ($connection === null) { - throw MigrationException::noConnectionFound(); - } - $this->runService->cleanupMappingChecksums($connection->getId(), $context); $this->runTransitionService->forceTransitionToRunStep($migrationContext->getRunUuid(), MigrationStep::CLEANUP); diff --git a/src/Migration/MigrationContext.php b/src/Migration/MigrationContext.php index 1ba4cbc30..547f63dff 100644 --- a/src/Migration/MigrationContext.php +++ b/src/Migration/MigrationContext.php @@ -9,6 +9,7 @@ use Shopware\Core\Framework\Log\Package; use Shopware\Core\Framework\Struct\Struct; +use SwagMigrationAssistant\Exception\MigrationException; use SwagMigrationAssistant\Migration\Connection\SwagMigrationConnectionEntity; use SwagMigrationAssistant\Migration\DataSelection\DataSet\DataSet; use SwagMigrationAssistant\Migration\Gateway\GatewayInterface; @@ -19,48 +20,55 @@ class MigrationContext extends Struct implements MigrationContextInterface { final public const SOURCE_CONTEXT = 'MIGRATION_CONNECTION_CHECK_FOR_RUNNING_MIGRATION'; - private ProfileInterface $profile; - - private ?SwagMigrationConnectionEntity $connection; - - private string $runUuid; + public function __construct( + private SwagMigrationConnectionEntity $connection, + private ?ProfileInterface $profile = null, + private ?GatewayInterface $gateway = null, + private ?DataSet $dataSet = null, + private readonly string $runUuid = '', + private int $offset = 0, + private int $limit = 0, + ) { + } - private ?DataSet $dataSet; + public function getProfile(): ProfileInterface + { + if ($this->profile === null) { + throw MigrationException::migrationContextPropertyMissing('profile'); + } - private int $offset; + return $this->profile; + } - private int $limit; + public function setProfile(ProfileInterface $profile): void + { + $this->profile = $profile; + } - private GatewayInterface $gateway; + public function getGateway(): GatewayInterface + { + if ($this->gateway === null) { + throw MigrationException::migrationContextPropertyMissing('gateway'); + } - public function __construct( - ProfileInterface $profile, - ?SwagMigrationConnectionEntity $connection = null, - string $runUuid = '', - ?DataSet $dataSet = null, - int $offset = 0, - int $limit = 0, - ) { - $this->profile = $profile; - $this->connection = $connection; - $this->runUuid = $runUuid; - $this->dataSet = $dataSet; - $this->offset = $offset; - $this->limit = $limit; + return $this->gateway; } - public function getProfile(): ProfileInterface + public function setGateway(GatewayInterface $gateway): void { - return $this->profile; + $this->gateway = $gateway; } public function getConnection(): SwagMigrationConnectionEntity { - \assert($this->connection instanceof SwagMigrationConnectionEntity); - return $this->connection; } + public function setConnection(SwagMigrationConnectionEntity $connection): void + { + $this->connection = $connection; + } + public function getRunUuid(): string { return $this->runUuid; @@ -81,18 +89,18 @@ public function getOffset(): int return $this->offset; } - public function getLimit(): int + public function setOffset(int $offset): void { - return $this->limit; + $this->offset = $offset; } - public function getGateway(): GatewayInterface + public function getLimit(): int { - return $this->gateway; + return $this->limit; } - public function setGateway(GatewayInterface $gateway): void + public function setLimit(int $limit): void { - $this->gateway = $gateway; + $this->limit = $limit; } } diff --git a/src/Migration/MigrationContextFactory.php b/src/Migration/MigrationContextFactory.php index db3fe037f..11c7793c0 100644 --- a/src/Migration/MigrationContextFactory.php +++ b/src/Migration/MigrationContextFactory.php @@ -22,18 +22,18 @@ use SwagMigrationAssistant\Migration\Setting\GeneralSettingEntity; #[Package('fundamentals@after-sales')] -class MigrationContextFactory implements MigrationContextFactoryInterface +readonly class MigrationContextFactory implements MigrationContextFactoryInterface { /** * @param EntityRepository $generalSettingRepository * @param EntityRepository $migrationConnectionRepository */ public function __construct( - private readonly ProfileRegistryInterface $profileRegistry, - private readonly GatewayRegistryInterface $gatewayRegistry, - private readonly DataSetRegistryInterface $dataSetRegistry, - private readonly EntityRepository $generalSettingRepository, - private readonly EntityRepository $migrationConnectionRepository, + private ProfileRegistryInterface $profileRegistry, + private GatewayRegistryInterface $gatewayRegistry, + private DataSetRegistryInterface $dataSetRegistry, + private EntityRepository $generalSettingRepository, + private EntityRepository $migrationConnectionRepository, ) { } @@ -44,19 +44,23 @@ public function create( string $entity = '', ): ?MigrationContextInterface { $connection = $run->getConnection(); + if ($connection === null) { return null; } $profile = $this->profileRegistry->getProfile($connection->getProfileName()); + $migrationContext = new MigrationContext( - $profile, $connection, - $run->getId(), + $profile, null, + null, + $run->getId(), $offset, $limit ); + $gateway = $this->gatewayRegistry->getGateway($migrationContext); $migrationContext->setGateway($gateway); @@ -68,25 +72,18 @@ public function create( return $migrationContext; } - public function createByProfileName(string $profileName): MigrationContextInterface - { - $profile = $this->profileRegistry->getProfile($profileName); - - return new MigrationContext( - $profile - ); - } - public function createByConnection( SwagMigrationConnectionEntity $connection, ): MigrationContextInterface { $profile = $this->profileRegistry->getProfile( $connection->getProfileName() ); + $migrationContext = new MigrationContext( + $connection, $profile, - $connection ); + $gateway = $this->gatewayRegistry->getGateway($migrationContext); $migrationContext->setGateway($gateway); @@ -96,6 +93,7 @@ public function createByConnection( public function createBySelectedConnection(Context $context): MigrationContextInterface { $settings = $this->generalSettingRepository->search(new Criteria(), $context)->first(); + if (!$settings instanceof GeneralSettingEntity) { throw MigrationException::entityNotExists(GeneralSettingEntity::class, 'Default'); } @@ -104,9 +102,18 @@ public function createBySelectedConnection(Context $context): MigrationContextIn throw MigrationException::noConnectionIsSelected(); } - $connection = $this->migrationConnectionRepository->search(new Criteria([$settings->getSelectedConnectionId()]), $context)->first(); + $connection = $this->migrationConnectionRepository->search( + new Criteria( + [$settings->getSelectedConnectionId()] + ), + $context + )->first(); + if (!$connection instanceof SwagMigrationConnectionEntity) { - throw MigrationException::entityNotExists(SwagMigrationConnectionEntity::class, $settings->getSelectedConnectionId()); + throw MigrationException::entityNotExists( + SwagMigrationConnectionEntity::class, + $settings->getSelectedConnectionId() + ); } return $this->createByConnection($connection); diff --git a/src/Migration/MigrationContextFactoryInterface.php b/src/Migration/MigrationContextFactoryInterface.php index 234ad85ea..88ed520e9 100644 --- a/src/Migration/MigrationContextFactoryInterface.php +++ b/src/Migration/MigrationContextFactoryInterface.php @@ -17,8 +17,6 @@ interface MigrationContextFactoryInterface { public function create(SwagMigrationRunEntity $run, int $offset = 0, int $limit = 0, string $entity = ''): ?MigrationContextInterface; - public function createByProfileName(string $profileName): MigrationContextInterface; - public function createByConnection(SwagMigrationConnectionEntity $connection): MigrationContextInterface; public function createBySelectedConnection(Context $context): MigrationContextInterface; diff --git a/src/Migration/MigrationContextInterface.php b/src/Migration/MigrationContextInterface.php index b2b893a66..8acac406d 100644 --- a/src/Migration/MigrationContextInterface.php +++ b/src/Migration/MigrationContextInterface.php @@ -18,17 +18,25 @@ interface MigrationContextInterface { public function getProfile(): ProfileInterface; + public function setProfile(ProfileInterface $profile): void; + + public function getGateway(): GatewayInterface; + + public function setGateway(GatewayInterface $gateway): void; + public function getConnection(): SwagMigrationConnectionEntity; + public function setConnection(SwagMigrationConnectionEntity $connection): void; + public function getRunUuid(): string; public function getDataSet(): ?DataSet; public function getOffset(): int; - public function getLimit(): int; + public function setOffset(int $offset): void; - public function getGateway(): GatewayInterface; + public function getLimit(): int; - public function setGateway(GatewayInterface $gateway): void; + public function setLimit(int $limit): void; } diff --git a/src/Migration/Premapping/AbstractPremappingReader.php b/src/Migration/Premapping/AbstractPremappingReader.php index a659af993..fdf173cd8 100644 --- a/src/Migration/Premapping/AbstractPremappingReader.php +++ b/src/Migration/Premapping/AbstractPremappingReader.php @@ -20,12 +20,8 @@ abstract class AbstractPremappingReader implements PremappingReaderInterface protected function fillConnectionPremappingDictionary(MigrationContextInterface $migrationContext): void { - $connection = $migrationContext->getConnection(); - if ($connection === null) { - return; - } + $connectionMapping = $migrationContext->getConnection()->getPremapping(); - $connectionMapping = $connection->getPremapping(); if ($connectionMapping === null) { return; } diff --git a/src/Migration/Service/MigrationDataConverter.php b/src/Migration/Service/MigrationDataConverter.php index 62a0479b1..12383cd2b 100644 --- a/src/Migration/Service/MigrationDataConverter.php +++ b/src/Migration/Service/MigrationDataConverter.php @@ -143,14 +143,13 @@ private function filterDeltas(array $data, ConverterInterface $converter, Migrat $checksums[$converter->getSourceIdentifier($dataSet)] = \md5(\serialize($dataSet)); } - $connection = $migrationContext->getConnection(); $dataSet = $migrationContext->getDataSet(); - if ($connection === null || $dataSet === null) { + if ($dataSet === null) { return new MappingDeltaResult(); } - $connectionId = $connection->getId(); + $connectionId = $migrationContext->getConnection()->getId(); $entity = $dataSet::getEntity(); $result = $this->mappingService->getMappings($connectionId, $entity, \array_keys($checksums), $context); diff --git a/src/Migration/Service/MigrationDataWriter.php b/src/Migration/Service/MigrationDataWriter.php index 4ed4c23a7..a0f003e96 100644 --- a/src/Migration/Service/MigrationDataWriter.php +++ b/src/Migration/Service/MigrationDataWriter.php @@ -129,9 +129,9 @@ public function writeData(MigrationContextInterface $migrationContext, Context $ $migrationContext, $context ); - } catch (\Throwable $exception) { + } catch (\Throwable) { // Worst case: something unknown goes wrong (most likely some foreign key constraint that fails) - $this->writePerEntity($converted, $dataSet::getEntity(), $updateWrittenData, $migrationContext, $context); + $this->writePerEntity($converted, $dataSet::getEntity(), $updateWrittenData, $migrationContext); } finally { // Update written-Flag of the entity in the data table $this->entityWriter->update( @@ -196,7 +196,7 @@ private function handleWriteException( try { $currentWriter->writeData($newData, $this->writeContext); } catch (\Throwable) { - $this->writePerEntity($converted, $entityName, $updateWrittenData, $migrationContext, $context); + $this->writePerEntity($converted, $entityName, $updateWrittenData, $migrationContext); } } @@ -228,7 +228,6 @@ private function writePerEntity( string $entityName, array &$updateWrittenData, MigrationContextInterface $migrationContext, - Context $context, ): void { foreach ($converted as $dataId => $entity) { try { diff --git a/src/Migration/Service/PremappingService.php b/src/Migration/Service/PremappingService.php index 71d5a6f61..fb34741e2 100644 --- a/src/Migration/Service/PremappingService.php +++ b/src/Migration/Service/PremappingService.php @@ -68,10 +68,6 @@ public function writePremapping(Context $context, MigrationContextInterface $mig $connection = $migrationContext->getConnection(); - if ($connection === null) { - return; - } - foreach ($premapping as $item) { $entity = $item['entity']; @@ -118,13 +114,8 @@ public function writePremapping(Context $context, MigrationContextInterface $mig */ private function updateConnectionPremapping(Context $context, MigrationContextInterface $migrationContext, array $premapping): void { - $premapping = $this->updateConnectionPremappingStruct($migrationContext, $premapping); - $connection = $migrationContext->getConnection(); - - if ($connection === null) { - return; - } + $premapping = $this->updateConnectionPremappingStruct($migrationContext, $premapping); $this->connectionRepo->update( [ @@ -144,13 +135,7 @@ private function updateConnectionPremapping(Context $context, MigrationContextIn */ private function updateConnectionPremappingStruct(MigrationContextInterface $migrationContext, array $premapping): array { - $connection = $migrationContext->getConnection(); - - if ($connection === null) { - return []; - } - - $connectionPremapping = $connection->getPremapping(); + $connectionPremapping = $migrationContext->getConnection()->getPremapping(); if ($connectionPremapping === null) { $connectionPremapping = []; diff --git a/src/Profile/Shopware/Converter/AttributeConverter.php b/src/Profile/Shopware/Converter/AttributeConverter.php index 629301665..c1025b69b 100644 --- a/src/Profile/Shopware/Converter/AttributeConverter.php +++ b/src/Profile/Shopware/Converter/AttributeConverter.php @@ -39,12 +39,8 @@ public function convert(array $data, Context $context, MigrationContextInterface $converted = []; $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - $this->connectionName = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - $this->connectionName = $connection->getName(); - } + $this->connectionId = $connection->getId(); + $this->connectionName = $connection->getName(); $mapping = $this->mappingService->getOrCreateMapping( $this->connectionId, diff --git a/src/Profile/Shopware/Converter/CategoryConverter.php b/src/Profile/Shopware/Converter/CategoryConverter.php index e26fea2f4..6ce10089c 100644 --- a/src/Profile/Shopware/Converter/CategoryConverter.php +++ b/src/Profile/Shopware/Converter/CategoryConverter.php @@ -81,12 +81,8 @@ public function convert( $this->migrationContext = $migrationContext; $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - $this->connectionName = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - $this->connectionName = $connection->getName(); - } + $this->connectionId = $connection->getId(); + $this->connectionName = $connection->getName(); if (!isset($data['_locale'])) { $this->loggingService->addLogEntry( // TODO: add optional fields diff --git a/src/Profile/Shopware/Converter/CrossSellingConverter.php b/src/Profile/Shopware/Converter/CrossSellingConverter.php index e1df85531..a66276898 100644 --- a/src/Profile/Shopware/Converter/CrossSellingConverter.php +++ b/src/Profile/Shopware/Converter/CrossSellingConverter.php @@ -36,10 +36,7 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->runId = $migrationContext->getRunUuid(); $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $connection->getId(); $converted = []; $this->mainMapping = $this->mappingService->getOrCreateMapping( diff --git a/src/Profile/Shopware/Converter/CurrencyConverter.php b/src/Profile/Shopware/Converter/CurrencyConverter.php index 46fb4df64..37244e277 100644 --- a/src/Profile/Shopware/Converter/CurrencyConverter.php +++ b/src/Profile/Shopware/Converter/CurrencyConverter.php @@ -47,10 +47,7 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->mainLocale = $data['_locale']; $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $connection->getId(); $currencyUuid = $this->currencyLookup->get($data['currency'], $context); if ($currencyUuid !== null) { diff --git a/src/Profile/Shopware/Converter/CustomerConverter.php b/src/Profile/Shopware/Converter/CustomerConverter.php index eb5471518..4663eac34 100644 --- a/src/Profile/Shopware/Converter/CustomerConverter.php +++ b/src/Profile/Shopware/Converter/CustomerConverter.php @@ -101,12 +101,8 @@ public function convert( $this->migrationContext = $migrationContext; $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - $this->connectionName = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - $this->connectionName = $connection->getName(); - } + $this->connectionId = $connection->getId(); + $this->connectionName = $connection->getName(); $fields = $this->checkForEmptyRequiredDataFields($data, $this->requiredDataFieldKeys); diff --git a/src/Profile/Shopware/Converter/CustomerGroupConverter.php b/src/Profile/Shopware/Converter/CustomerGroupConverter.php index b77dcc163..53506e0e7 100644 --- a/src/Profile/Shopware/Converter/CustomerGroupConverter.php +++ b/src/Profile/Shopware/Converter/CustomerGroupConverter.php @@ -44,12 +44,8 @@ public function convert(array $data, Context $context, MigrationContextInterface unset($data['_locale']); $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - $this->connectionName = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - $this->connectionName = $connection->getName(); - } + $this->connectionId = $connection->getId(); + $this->connectionName = $connection->getName(); $this->mainMapping = $this->mappingService->getOrCreateMapping( $this->connectionId, diff --git a/src/Profile/Shopware/Converter/CustomerWishlistConverter.php b/src/Profile/Shopware/Converter/CustomerWishlistConverter.php index 516cb3dba..a19ff0aa4 100644 --- a/src/Profile/Shopware/Converter/CustomerWishlistConverter.php +++ b/src/Profile/Shopware/Converter/CustomerWishlistConverter.php @@ -27,10 +27,7 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->migrationContext = $migrationContext; $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $connection->getId(); $this->mainMapping = $this->mappingService->getOrCreateMapping( $this->connectionId, diff --git a/src/Profile/Shopware/Converter/LanguageConverter.php b/src/Profile/Shopware/Converter/LanguageConverter.php index eba545df3..04822064e 100644 --- a/src/Profile/Shopware/Converter/LanguageConverter.php +++ b/src/Profile/Shopware/Converter/LanguageConverter.php @@ -46,10 +46,7 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->context = $context; $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $connection->getId(); $languageUuid = $this->languageLookup->get($data['locale'], $context); if ($languageUuid !== null) { diff --git a/src/Profile/Shopware/Converter/MainVariantRelationConverter.php b/src/Profile/Shopware/Converter/MainVariantRelationConverter.php index ced400034..f76cd714a 100644 --- a/src/Profile/Shopware/Converter/MainVariantRelationConverter.php +++ b/src/Profile/Shopware/Converter/MainVariantRelationConverter.php @@ -32,9 +32,7 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->generateChecksum($data); $this->context = $context; $connection = $migrationContext->getConnection(); - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $connection->getId(); if (!isset($data['id'], $data['ordernumber'])) { return new ConvertStruct(null, $data); diff --git a/src/Profile/Shopware/Converter/MediaConverter.php b/src/Profile/Shopware/Converter/MediaConverter.php index c7285189e..d6b2e9cf8 100644 --- a/src/Profile/Shopware/Converter/MediaConverter.php +++ b/src/Profile/Shopware/Converter/MediaConverter.php @@ -57,10 +57,7 @@ public function convert( unset($data['_locale']); $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $connection->getId(); $converted = []; $this->mainMapping = $this->mappingService->getOrCreateMapping( diff --git a/src/Profile/Shopware/Converter/MediaFolderConverter.php b/src/Profile/Shopware/Converter/MediaFolderConverter.php index 30b4bdb25..d7cc78906 100644 --- a/src/Profile/Shopware/Converter/MediaFolderConverter.php +++ b/src/Profile/Shopware/Converter/MediaFolderConverter.php @@ -50,10 +50,7 @@ public function convert(array $data, Context $context, MigrationContextInterface unset($data['_locale']); $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $connection->getId(); $converted = []; $this->mainMapping = $this->mappingService->getOrCreateMapping( diff --git a/src/Profile/Shopware/Converter/NewsletterRecipientConverter.php b/src/Profile/Shopware/Converter/NewsletterRecipientConverter.php index 8e755c11c..32fc233fe 100644 --- a/src/Profile/Shopware/Converter/NewsletterRecipientConverter.php +++ b/src/Profile/Shopware/Converter/NewsletterRecipientConverter.php @@ -57,10 +57,7 @@ public function convert( MigrationContextInterface $migrationContext, ): ConvertStruct { $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $connection->getId(); $this->runId = $migrationContext->getRunUuid(); $fields = $this->checkForEmptyRequiredDataFields($data, $this->requiredDataFieldKeys); diff --git a/src/Profile/Shopware/Converter/NumberRangeConverter.php b/src/Profile/Shopware/Converter/NumberRangeConverter.php index 9f75f0202..48e3e4119 100644 --- a/src/Profile/Shopware/Converter/NumberRangeConverter.php +++ b/src/Profile/Shopware/Converter/NumberRangeConverter.php @@ -69,9 +69,6 @@ public function convert(array $data, Context $context, MigrationContextInterface } $connection = $migrationContext->getConnection(); - if ($connection === null) { - return new ConvertStruct(null, $data); - } $this->connectionId = $connection->getId(); if (!\array_key_exists($data['name'], self::TYPE_MAPPING)) { diff --git a/src/Profile/Shopware/Converter/OrderConverter.php b/src/Profile/Shopware/Converter/OrderConverter.php index bf83762fe..3a852bcad 100644 --- a/src/Profile/Shopware/Converter/OrderConverter.php +++ b/src/Profile/Shopware/Converter/OrderConverter.php @@ -120,12 +120,8 @@ public function convert( $this->migrationContext = $migrationContext; $connection = $migrationContext->getConnection(); - $this->connectionName = ''; - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - $this->connectionName = $connection->getName(); - } + $this->connectionId = $connection->getId(); + $this->connectionName = $connection->getName(); $fields = $this->checkForEmptyRequiredDataFields($data, $this->requiredDataFieldKeys); if (empty($data['billingaddress']['id'])) { diff --git a/src/Profile/Shopware/Converter/OrderDocumentConverter.php b/src/Profile/Shopware/Converter/OrderDocumentConverter.php index 9745d3856..7f1cdc686 100644 --- a/src/Profile/Shopware/Converter/OrderDocumentConverter.php +++ b/src/Profile/Shopware/Converter/OrderDocumentConverter.php @@ -73,12 +73,8 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->context = $context; $connection = $migrationContext->getConnection(); - $this->connectionName = ''; - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - $this->connectionName = $connection->getName(); - } + $this->connectionId = $connection->getId(); + $this->connectionName = $connection->getName(); $oldData = $data; $converted = []; diff --git a/src/Profile/Shopware/Converter/ProductConverter.php b/src/Profile/Shopware/Converter/ProductConverter.php index 7827133e8..f361f85e2 100644 --- a/src/Profile/Shopware/Converter/ProductConverter.php +++ b/src/Profile/Shopware/Converter/ProductConverter.php @@ -138,12 +138,8 @@ public function convert( $this->locale = $data['_locale']; $connection = $migrationContext->getConnection(); - $this->connectionName = ''; - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - $this->connectionName = $connection->getName(); - } + $this->connectionId = $connection->getId(); + $this->connectionName = $connection->getName(); $fields = $this->checkForEmptyRequiredDataFields($data, $this->requiredDataFieldKeys); if (!empty($fields)) { diff --git a/src/Profile/Shopware/Converter/ProductOptionRelationConverter.php b/src/Profile/Shopware/Converter/ProductOptionRelationConverter.php index 587823a86..411860f5c 100644 --- a/src/Profile/Shopware/Converter/ProductOptionRelationConverter.php +++ b/src/Profile/Shopware/Converter/ProductOptionRelationConverter.php @@ -34,10 +34,7 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->originalData = $data; $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $connection->getId(); $productContainerMapping = $this->mappingService->getMapping( $this->connectionId, diff --git a/src/Profile/Shopware/Converter/ProductPropertyRelationConverter.php b/src/Profile/Shopware/Converter/ProductPropertyRelationConverter.php index e1b25099c..55737062e 100644 --- a/src/Profile/Shopware/Converter/ProductPropertyRelationConverter.php +++ b/src/Profile/Shopware/Converter/ProductPropertyRelationConverter.php @@ -37,10 +37,7 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->originalData = $data; $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $connection->getId(); $productMapping = $this->mappingService->getMapping( $this->connectionId, diff --git a/src/Profile/Shopware/Converter/PromotionConverter.php b/src/Profile/Shopware/Converter/PromotionConverter.php index 54bf3ccce..6e68c4b33 100644 --- a/src/Profile/Shopware/Converter/PromotionConverter.php +++ b/src/Profile/Shopware/Converter/PromotionConverter.php @@ -57,10 +57,7 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->context = $context; $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $connection->getId(); $converted = []; $this->mainMapping = $this->mappingService->getOrCreateMapping( diff --git a/src/Profile/Shopware/Converter/PropertyGroupOptionConverter.php b/src/Profile/Shopware/Converter/PropertyGroupOptionConverter.php index 97586f041..f1f121031 100644 --- a/src/Profile/Shopware/Converter/PropertyGroupOptionConverter.php +++ b/src/Profile/Shopware/Converter/PropertyGroupOptionConverter.php @@ -73,10 +73,7 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->runId = $migrationContext->getRunUuid(); $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $connection->getId(); if (!isset($data['group']['name'])) { $this->loggingService->addLogEntry( // TODO: add optional fields diff --git a/src/Profile/Shopware/Converter/SalesChannelConverter.php b/src/Profile/Shopware/Converter/SalesChannelConverter.php index 4232a6578..1e911f66e 100644 --- a/src/Profile/Shopware/Converter/SalesChannelConverter.php +++ b/src/Profile/Shopware/Converter/SalesChannelConverter.php @@ -72,10 +72,7 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->oldIdentifier = $data['id']; $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $connection->getId(); $converted = []; $this->mainMapping = $this->mappingService->getOrCreateMapping( diff --git a/src/Profile/Shopware/Converter/SeoUrlConverter.php b/src/Profile/Shopware/Converter/SeoUrlConverter.php index 3f4099a42..565a5c662 100644 --- a/src/Profile/Shopware/Converter/SeoUrlConverter.php +++ b/src/Profile/Shopware/Converter/SeoUrlConverter.php @@ -44,10 +44,7 @@ public function convert(array $data, Context $context, MigrationContextInterface $originalData = $data; $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $connection->getId(); $converted = []; $this->mainMapping = $this->mappingService->getOrCreateMapping( diff --git a/src/Profile/Shopware/Converter/ShippingMethodConverter.php b/src/Profile/Shopware/Converter/ShippingMethodConverter.php index 1ed8e79ce..0c71b8c60 100644 --- a/src/Profile/Shopware/Converter/ShippingMethodConverter.php +++ b/src/Profile/Shopware/Converter/ShippingMethodConverter.php @@ -90,10 +90,7 @@ public function __construct( public function convert(array $data, Context $context, MigrationContextInterface $migrationContext): ConvertStruct { $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $connection->getId(); if (empty($data['id'])) { $this->loggingService->addLogEntry( // TODO: add optional fields diff --git a/src/Profile/Shopware/Converter/ShopwareConverter.php b/src/Profile/Shopware/Converter/ShopwareConverter.php index e01821c5a..b4766d28d 100644 --- a/src/Profile/Shopware/Converter/ShopwareConverter.php +++ b/src/Profile/Shopware/Converter/ShopwareConverter.php @@ -148,7 +148,7 @@ protected function getAttributes( } $connection = $this->migrationContext->getConnection(); - if ($context !== null && $connection !== null) { + if ($context !== null) { $connectionId = $connection->getId(); $mapping = $this->mappingService->getMapping( $connectionId, diff --git a/src/Profile/Shopware/Converter/TranslationConverter.php b/src/Profile/Shopware/Converter/TranslationConverter.php index ed7d7283d..abe5d81e6 100644 --- a/src/Profile/Shopware/Converter/TranslationConverter.php +++ b/src/Profile/Shopware/Converter/TranslationConverter.php @@ -57,10 +57,7 @@ public function convert( $this->runId = $migrationContext->getRunUuid(); $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $connection->getId(); if (!isset($data['locale'])) { $this->loggingService->addLogEntry( // TODO: add optional fields @@ -850,12 +847,11 @@ protected function createPropertyOptionTranslation(array $data): ConvertStruct */ protected function addAttribute(string $entityName, string $key, string $value, array &$translation, array &$objectData): void { - $connection = $this->migrationContext->getConnection(); - - if ($connection === null || $value === '') { + if ($value === '') { return; } + $connection = $this->migrationContext->getConnection(); $connectionName = ConnectionNameSanitizer::sanitize($connection->getName()); $isAttribute = \mb_strpos($key, '__attribute_'); @@ -909,7 +905,7 @@ protected function unserializeTranslation(array $data, string $entity): ?array try { $objectData = \unserialize($objectDataSerialized, ['allowed_classes' => false]); - } catch (\Throwable $error) { + } catch (\Throwable) { $objectData = null; } diff --git a/src/Profile/Shopware/Gateway/Api/ShopwareApiGateway.php b/src/Profile/Shopware/Gateway/Api/ShopwareApiGateway.php index 5c93752bb..cf5dcf06c 100644 --- a/src/Profile/Shopware/Gateway/Api/ShopwareApiGateway.php +++ b/src/Profile/Shopware/Gateway/Api/ShopwareApiGateway.php @@ -22,6 +22,7 @@ use SwagMigrationAssistant\Migration\Gateway\Reader\EnvironmentReaderInterface; use SwagMigrationAssistant\Migration\Gateway\Reader\ReaderRegistryInterface; use SwagMigrationAssistant\Migration\MigrationContextInterface; +use SwagMigrationAssistant\Migration\Profile\ProfileInterface; use SwagMigrationAssistant\Profile\Shopware\Gateway\ShopwareGatewayInterface; use SwagMigrationAssistant\Profile\Shopware\Gateway\TableCountReaderInterface; use SwagMigrationAssistant\Profile\Shopware\Gateway\TableReaderInterface; @@ -56,9 +57,9 @@ public function getSnippetName(): string return 'swag-migration.wizard.pages.connectionCreate.gateways.shopwareApi'; } - public function supports(MigrationContextInterface $migrationContext): bool + public function supports(ProfileInterface $profile): bool { - return $migrationContext->getProfile() instanceof ShopwareProfileInterface; + return $profile instanceof ShopwareProfileInterface; } public function read(MigrationContextInterface $migrationContext): array @@ -124,21 +125,7 @@ public function readEnvironmentInformation(MigrationContextInterface $migrationC $environmentDataArray['defaultShopLanguage'] = \str_replace('_', '-', $environmentDataArray['defaultShopLanguage']); $totals = $this->readTotals($migrationContext, $context); - - $connection = $migrationContext->getConnection(); - - if ($connection === null) { - return new EnvironmentInformation( - $profile->getSourceSystemName(), - $profile->getVersion(), - '', - [], - [], - null - ); - } - - $credentials = $connection->getCredentialFields(); + $credentials = $migrationContext->getConnection()->getCredentialFields(); if ($credentials === null) { return new EnvironmentInformation( diff --git a/src/Profile/Shopware/Gateway/Connection/ConnectionFactory.php b/src/Profile/Shopware/Gateway/Connection/ConnectionFactory.php index fa949b6a9..bf9792d2f 100644 --- a/src/Profile/Shopware/Gateway/Connection/ConnectionFactory.php +++ b/src/Profile/Shopware/Gateway/Connection/ConnectionFactory.php @@ -24,13 +24,7 @@ class ConnectionFactory implements ConnectionFactoryInterface, ResetInterface public function createApiClient(MigrationContextInterface $migrationContext): HttpClientInterface { - $connection = $migrationContext->getConnection(); - - if ($connection === null) { - throw MigrationException::noConnectionFound(); - } - - $credentials = $connection->getCredentialFields(); + $credentials = $migrationContext->getConnection()->getCredentialFields(); if (empty($credentials)) { throw MigrationException::invalidConnectionCredentials(); @@ -57,13 +51,7 @@ public function createDatabaseConnection(MigrationContextInterface $migrationCon return $this->externalConnection; } - $connection = $migrationContext->getConnection(); - - if ($connection === null) { - throw MigrationException::noConnectionFound(); - } - - $credentials = $connection->getCredentialFields(); + $credentials = $migrationContext->getConnection()->getCredentialFields(); if ($credentials === null) { throw MigrationException::invalidConnectionCredentials(); diff --git a/src/Profile/Shopware/Gateway/Local/ShopwareLocalGateway.php b/src/Profile/Shopware/Gateway/Local/ShopwareLocalGateway.php index 74ca7e151..c33c087f2 100644 --- a/src/Profile/Shopware/Gateway/Local/ShopwareLocalGateway.php +++ b/src/Profile/Shopware/Gateway/Local/ShopwareLocalGateway.php @@ -22,6 +22,7 @@ use SwagMigrationAssistant\Migration\Gateway\Reader\EnvironmentReaderInterface; use SwagMigrationAssistant\Migration\Gateway\Reader\ReaderRegistry; use SwagMigrationAssistant\Migration\MigrationContextInterface; +use SwagMigrationAssistant\Migration\Profile\ProfileInterface; use SwagMigrationAssistant\Migration\RequestStatusStruct; use SwagMigrationAssistant\Profile\Shopware\Gateway\Connection\ConnectionFactoryInterface; use SwagMigrationAssistant\Profile\Shopware\Gateway\ShopwareGatewayInterface; @@ -57,9 +58,9 @@ public function getSnippetName(): string return 'swag-migration.wizard.pages.connectionCreate.gateways.shopwareLocal'; } - public function supports(MigrationContextInterface $migrationContext): bool + public function supports(ProfileInterface $profile): bool { - return $migrationContext->getProfile() instanceof ShopwareProfileInterface; + return $profile instanceof ShopwareProfileInterface; } public function read(MigrationContextInterface $migrationContext): array diff --git a/src/Profile/Shopware/Media/LocalOrderDocumentProcessor.php b/src/Profile/Shopware/Media/LocalOrderDocumentProcessor.php index 8dffb83bb..e4d52ec39 100644 --- a/src/Profile/Shopware/Media/LocalOrderDocumentProcessor.php +++ b/src/Profile/Shopware/Media/LocalOrderDocumentProcessor.php @@ -66,12 +66,7 @@ public function process( private function getInstallationRoot(MigrationContextInterface $migrationContext): string { - $connection = $migrationContext->getConnection(); - if ($connection === null) { - return ''; - } - - $credentials = $connection->getCredentialFields(); + $credentials = $migrationContext->getConnection()->getCredentialFields(); if ($credentials === null) { return ''; diff --git a/src/Profile/Shopware/Media/LocalProductDownloadProcessor.php b/src/Profile/Shopware/Media/LocalProductDownloadProcessor.php index 39527fcb4..97f68097b 100644 --- a/src/Profile/Shopware/Media/LocalProductDownloadProcessor.php +++ b/src/Profile/Shopware/Media/LocalProductDownloadProcessor.php @@ -71,12 +71,7 @@ public function process( private function getInstallationRoot(MigrationContextInterface $migrationContext): string { - $connection = $migrationContext->getConnection(); - if ($connection === null) { - return ''; - } - - $credentials = $connection->getCredentialFields(); + $credentials = $migrationContext->getConnection()->getCredentialFields(); if ($credentials === null) { return ''; diff --git a/src/Profile/Shopware/Media/Strategy/Md5StrategyResolver.php b/src/Profile/Shopware/Media/Strategy/Md5StrategyResolver.php index 0086edc00..33bfe46fd 100644 --- a/src/Profile/Shopware/Media/Strategy/Md5StrategyResolver.php +++ b/src/Profile/Shopware/Media/Strategy/Md5StrategyResolver.php @@ -24,12 +24,7 @@ public function supports(string $path, MigrationContextInterface $migrationConte public function resolve(string $path, MigrationContextInterface $migrationContext): string { - $connection = $migrationContext->getConnection(); - if ($connection === null) { - return ''; - } - - $credentials = $connection->getCredentialFields(); + $credentials = $migrationContext->getConnection()->getCredentialFields(); if ($credentials === null) { return ''; diff --git a/src/Profile/Shopware/Media/Strategy/PlainStrategyResolver.php b/src/Profile/Shopware/Media/Strategy/PlainStrategyResolver.php index 16381b1e8..31b97845b 100644 --- a/src/Profile/Shopware/Media/Strategy/PlainStrategyResolver.php +++ b/src/Profile/Shopware/Media/Strategy/PlainStrategyResolver.php @@ -20,12 +20,7 @@ public function supports(string $path, MigrationContextInterface $migrationConte public function resolve(string $path, MigrationContextInterface $migrationContext): string { - $connection = $migrationContext->getConnection(); - if ($connection === null) { - return ''; - } - - $credentials = $connection->getCredentialFields(); + $credentials = $migrationContext->getConnection()->getCredentialFields(); if ($credentials === null) { return ''; diff --git a/src/Profile/Shopware/Premapping/DefaultShippingAvailabilityRuleReader.php b/src/Profile/Shopware/Premapping/DefaultShippingAvailabilityRuleReader.php index ee326b4a5..59844bd50 100644 --- a/src/Profile/Shopware/Premapping/DefaultShippingAvailabilityRuleReader.php +++ b/src/Profile/Shopware/Premapping/DefaultShippingAvailabilityRuleReader.php @@ -63,12 +63,7 @@ public function getPremapping(Context $context, MigrationContextInterface $migra protected function fillConnectionPremappingValue(MigrationContextInterface $migrationContext): void { - $connection = $migrationContext->getConnection(); - if ($connection === null) { - return; - } - - $mappingArray = $connection->getPremapping(); + $mappingArray = $migrationContext->getConnection()->getPremapping(); if ($mappingArray === null) { return; diff --git a/src/Profile/Shopware/Premapping/DeliveryTimeReader.php b/src/Profile/Shopware/Premapping/DeliveryTimeReader.php index fcae802c6..735fa78e8 100644 --- a/src/Profile/Shopware/Premapping/DeliveryTimeReader.php +++ b/src/Profile/Shopware/Premapping/DeliveryTimeReader.php @@ -63,12 +63,7 @@ public function getPremapping(Context $context, MigrationContextInterface $migra protected function fillConnectionPremappingValue(MigrationContextInterface $migrationContext): void { - $connection = $migrationContext->getConnection(); - if ($connection === null) { - return; - } - - $mappingArray = $connection->getPremapping(); + $mappingArray = $migrationContext->getConnection()->getPremapping(); if ($mappingArray === null) { return; diff --git a/src/Profile/Shopware/Premapping/NewsletterRecipientStatusReader.php b/src/Profile/Shopware/Premapping/NewsletterRecipientStatusReader.php index 8c758576f..bac7f4f8f 100644 --- a/src/Profile/Shopware/Premapping/NewsletterRecipientStatusReader.php +++ b/src/Profile/Shopware/Premapping/NewsletterRecipientStatusReader.php @@ -47,12 +47,7 @@ public function getPremapping(Context $context, MigrationContextInterface $migra protected function fillConnectionPremappingValue(MigrationContextInterface $migrationContext): void { - $connection = $migrationContext->getConnection(); - if ($connection === null) { - return; - } - - $mappingArray = $connection->getPremapping(); + $mappingArray = $migrationContext->getConnection()->getPremapping(); if ($mappingArray === null) { return; diff --git a/src/Profile/Shopware6/Converter/ShopwareConverter.php b/src/Profile/Shopware6/Converter/ShopwareConverter.php index 8499a7513..d2dcb8d2e 100644 --- a/src/Profile/Shopware6/Converter/ShopwareConverter.php +++ b/src/Profile/Shopware6/Converter/ShopwareConverter.php @@ -48,10 +48,7 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->migrationContext = $migrationContext; $connection = $migrationContext->getConnection(); - $this->connectionId = ''; - if ($connection !== null) { - $this->connectionId = $connection->getId(); - } + $this->connectionId = $connection->getId(); $this->runId = $this->migrationContext->getRunUuid(); diff --git a/src/Profile/Shopware6/Gateway/Api/Shopware6ApiGateway.php b/src/Profile/Shopware6/Gateway/Api/Shopware6ApiGateway.php index 57b1ee52c..030736020 100644 --- a/src/Profile/Shopware6/Gateway/Api/Shopware6ApiGateway.php +++ b/src/Profile/Shopware6/Gateway/Api/Shopware6ApiGateway.php @@ -19,6 +19,7 @@ use SwagMigrationAssistant\Migration\Gateway\Reader\EnvironmentReaderInterface; use SwagMigrationAssistant\Migration\Gateway\Reader\ReaderRegistryInterface; use SwagMigrationAssistant\Migration\MigrationContextInterface; +use SwagMigrationAssistant\Migration\Profile\ProfileInterface; use SwagMigrationAssistant\Profile\Shopware6\Gateway\ShopwareGatewayInterface; use SwagMigrationAssistant\Profile\Shopware6\Gateway\TableReaderInterface; use SwagMigrationAssistant\Profile\Shopware6\Gateway\TotalReaderInterface; @@ -54,9 +55,9 @@ public function getSnippetName(): string return 'swag-migration.wizard.pages.connectionCreate.gateways.shopwareApi'; } - public function supports(MigrationContextInterface $migrationContext): bool + public function supports(ProfileInterface $profile): bool { - return $migrationContext->getProfile() instanceof Shopware6ProfileInterface; + return $profile instanceof Shopware6ProfileInterface; } public function read(MigrationContextInterface $migrationContext): array @@ -83,20 +84,7 @@ public function readEnvironmentInformation(MigrationContextInterface $migrationC ); } - $connection = $migrationContext->getConnection(); - - if ($connection === null) { - return new EnvironmentInformation( - $profile->getSourceSystemName(), - $profile->getVersion(), - '', - [], - [], - null - ); - } - - $credentials = $connection->getCredentialFields(); + $credentials = $migrationContext->getConnection()->getCredentialFields(); if ($credentials === null) { return new EnvironmentInformation( diff --git a/src/Profile/Shopware6/Gateway/Connection/AuthClient.php b/src/Profile/Shopware6/Gateway/Connection/AuthClient.php index ebb2849ee..4f0657632 100644 --- a/src/Profile/Shopware6/Gateway/Connection/AuthClient.php +++ b/src/Profile/Shopware6/Gateway/Connection/AuthClient.php @@ -14,6 +14,7 @@ use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\Log\Package; +use SwagMigrationAssistant\Exception\MigrationException; use SwagMigrationAssistant\Migration\Connection\SwagMigrationConnectionCollection; use SwagMigrationAssistant\Migration\Gateway\HttpClientInterface; use SwagMigrationAssistant\Migration\MigrationContext; @@ -95,16 +96,10 @@ private function setupBearerTokenIfNeeded(): void private function renewBearerToken(): void { - $connection = $this->migrationContext->getConnection(); - - if ($connection === null) { - return; - } - - $credentials = $connection->getCredentialFields(); + $credentials = $this->migrationContext->getConnection()->getCredentialFields(); if ($credentials === null) { - return; + throw MigrationException::invalidConnectionCredentials(); } $response = $this->apiClient->post('/api/oauth/token', [ @@ -126,25 +121,20 @@ private function renewBearerToken(): void private function saveBearerToken(): void { $connection = $this->migrationContext->getConnection(); + $credentials = $connection->getCredentialFields(); - if ($connection === null) { - return; - } - - $credentialFields = $connection->getCredentialFields(); - - if ($credentialFields === null) { - return; + if ($credentials === null) { + throw MigrationException::invalidConnectionCredentials(); } $connectionUuid = $connection->getId(); - $credentialFields['bearer_token'] = $this->bearerToken; + $credentials['bearer_token'] = $this->bearerToken; - $this->context->scope(MigrationContext::SOURCE_CONTEXT, function (Context $context) use ($connectionUuid, $credentialFields): void { + $this->context->scope(MigrationContext::SOURCE_CONTEXT, function (Context $context) use ($connectionUuid, $credentials): void { $this->connectionRepository->update([ [ 'id' => $connectionUuid, - 'credentialFields' => $credentialFields, + 'credentialFields' => $credentials, ], ], $context); }); @@ -152,15 +142,7 @@ private function saveBearerToken(): void private function loadBearerToken(): void { - $connection = $this->migrationContext->getConnection(); - - if ($connection === null) { - $this->renewBearerToken(); - - return; - } - - $credentials = $connection->getCredentialFields(); + $credentials = $this->migrationContext->getConnection()->getCredentialFields(); if ($credentials === null) { $this->renewBearerToken(); diff --git a/src/Profile/Shopware6/Gateway/Connection/ConnectionFactory.php b/src/Profile/Shopware6/Gateway/Connection/ConnectionFactory.php index 67e107828..5c6019c1b 100644 --- a/src/Profile/Shopware6/Gateway/Connection/ConnectionFactory.php +++ b/src/Profile/Shopware6/Gateway/Connection/ConnectionFactory.php @@ -29,13 +29,7 @@ public function __construct(private readonly EntityRepository $connectionReposit public function createApiClient(MigrationContextInterface $migrationContext): ?HttpClientInterface { - $connection = $migrationContext->getConnection(); - - if ($connection === null) { - return null; - } - - $credentials = $connection->getCredentialFields(); + $credentials = $migrationContext->getConnection()->getCredentialFields(); if (empty($credentials) || !isset($credentials['endpoint'])) { return null; diff --git a/src/Profile/Shopware6/Media/HttpOrderDocumentGenerationService.php b/src/Profile/Shopware6/Media/HttpOrderDocumentGenerationService.php index 267ab7c76..dae35f759 100644 --- a/src/Profile/Shopware6/Media/HttpOrderDocumentGenerationService.php +++ b/src/Profile/Shopware6/Media/HttpOrderDocumentGenerationService.php @@ -71,13 +71,7 @@ public function process( $mappedWorkload = []; $documentIds = []; $runId = $migrationContext->getRunUuid(); - $connection = $migrationContext->getConnection(); - - if ($connection === null) { - return $workload; - } - - $this->connection = $connection; + $this->connection = $migrationContext->getConnection(); foreach ($workload as $work) { $mappedWorkload[$work->getMediaId()] = $work; diff --git a/tests/LocalConnectionTestCase.php b/tests/LocalConnectionTestCase.php index 08f5d83a3..1d0b01486 100644 --- a/tests/LocalConnectionTestCase.php +++ b/tests/LocalConnectionTestCase.php @@ -70,9 +70,8 @@ abstract protected function getDataSet(): DataSet; protected function setLimitAndOffset(int $limit, int $offset): void { - $reflectionClass = new \ReflectionClass($this->getMigrationContext()); - (new \ReflectionProperty($reflectionClass->getName(), 'limit'))->setValue($this->getMigrationContext(), $limit); - (new \ReflectionProperty($reflectionClass->getName(), 'offset'))->setValue($this->getMigrationContext(), $offset); + $this->getMigrationContext()->setLimit($limit); + $this->getMigrationContext()->setOffset($offset); } protected function getExternalConnection(): Connection @@ -97,15 +96,20 @@ protected function getMigrationContext(): MigrationContextInterface return $this->migrationContext; } + if ($this->migrationConnectionEntity === null) { + throw new \RuntimeException('Migration connection entity is not set. Please call before() method first.'); + } + if ($this->runId === null) { throw new \RuntimeException('RunId is not set. Please call before() method first.'); } $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->migrationConnectionEntity, - $this->runId, + new Shopware55Profile(), + null, $this->getDataSet(), + $this->runId, 0, 10 ); diff --git a/tests/Migration/Converter/ConverterRegistryTest.php b/tests/Migration/Converter/ConverterRegistryTest.php index ed8de4d71..5516056c8 100644 --- a/tests/Migration/Converter/ConverterRegistryTest.php +++ b/tests/Migration/Converter/ConverterRegistryTest.php @@ -153,10 +153,11 @@ public function testConverterCollection(ProfileInterface $profile, DataSet $data $connection->setProfileName(Shopware54Profile::PROFILE_NAME); $connection->setGatewayName(ShopwareLocalGateway::GATEWAY_NAME); $migrationContext = new MigrationContext( - $profile, $connection, - Uuid::randomHex(), + $profile, + null, $dataSet, + Uuid::randomHex(), 0, 250 ); @@ -171,10 +172,11 @@ public function testGetConverterNotFound(): void $connection->setProfileName(Shopware55Profile::PROFILE_NAME); $connection->setGatewayName(ShopwareLocalGateway::GATEWAY_NAME); $migrationContext = new MigrationContext( - new Shopware55Profile(), $connection, - Uuid::randomHex(), + new Shopware55Profile(), + null, new FooDataSet(), + Uuid::randomHex(), 0, 250 ); diff --git a/tests/Migration/DataSelection/DataSelectionRegistryTest.php b/tests/Migration/DataSelection/DataSelectionRegistryTest.php index bf8a37d33..7b7ed2700 100644 --- a/tests/Migration/DataSelection/DataSelectionRegistryTest.php +++ b/tests/Migration/DataSelection/DataSelectionRegistryTest.php @@ -81,8 +81,8 @@ protected function setUp(): void public function testGetDataSelections(): void { $migrationContext = new MigrationContext( - new Shopware55Profile(), - $this->connection + $this->connection, + new Shopware55Profile() ); $expected = [ @@ -109,8 +109,9 @@ public function testGetDataSelectionsWithOnlyOneDataSelection(): void { $this->dataSelectionRegistry = new DataSelectionRegistry(new DummyCollection([new MediaDataSelection()])); $migrationContext = new MigrationContext( + $this->connection, new Shopware55Profile(), - $this->connection + null ); $dataSelections = $this->dataSelectionRegistry->getDataSelections($migrationContext, $this->environmentInformation); @@ -124,8 +125,9 @@ public function testGetDataSelectionById(): void { $this->dataSelectionRegistry = new DataSelectionRegistry(new DummyCollection([new MediaDataSelection()])); $migrationContext = new MigrationContext( + $this->connection, new Shopware55Profile(), - $this->connection + null ); $dataSelections = $this->dataSelectionRegistry->getDataSelectionsByIds($migrationContext, $this->environmentInformation, ['media']); @@ -137,8 +139,9 @@ public function testGetDataSelectionById(): void public function testEntityNamesRequiredForCount(): void { $migrationContext = new MigrationContext( + $this->connection, new Shopware55Profile(), - $this->connection + null ); $dataSelections = $this->dataSelectionRegistry->getDataSelections($migrationContext, $this->environmentInformation); @@ -154,8 +157,9 @@ public function testEntityNamesRequiredForCount(): void public function testEntityNamesRequiredForCountValues(): void { $migrationContext = new MigrationContext( + $this->connection, new Shopware55Profile(), - $this->connection + null ); $dataSelections = $this->dataSelectionRegistry->getDataSelections($migrationContext, $this->environmentInformation); diff --git a/tests/Migration/DataSelection/DataSetRegistryTest.php b/tests/Migration/DataSelection/DataSetRegistryTest.php index 3b0e99662..2e2cd1a46 100644 --- a/tests/Migration/DataSelection/DataSetRegistryTest.php +++ b/tests/Migration/DataSelection/DataSetRegistryTest.php @@ -47,10 +47,11 @@ protected function setUp(): void public function testSupports(): void { $migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runId, + new Shopware55Profile(), + null, new ProductDataSet(), + $this->runId, 0, 250 ); @@ -66,10 +67,11 @@ public function testSupports(): void public function testDataSetNotFound(): void { $migrationContext = new MigrationContext( - new DummyProfile(), $this->connection, - $this->runId, + new DummyProfile(), + null, new FooDataSet(), + $this->runId, 0, 250 ); diff --git a/tests/Migration/Gateway/GatewayServiceTest.php b/tests/Migration/Gateway/GatewayServiceTest.php index 333129198..893b4b8ab 100644 --- a/tests/Migration/Gateway/GatewayServiceTest.php +++ b/tests/Migration/Gateway/GatewayServiceTest.php @@ -38,10 +38,11 @@ public function testGetGatewayNotFound(): void $connection->setCredentialFields([]); $migrationContext = new MigrationContext( - new DummyProfile(), $connection, - '', + new DummyProfile(), + null, new ProductDataSet(), + '', 0, 250 ); diff --git a/tests/Migration/Media/MediaFileProcessorRegistryTest.php b/tests/Migration/Media/MediaFileProcessorRegistryTest.php index b1dbb1735..81fa94c9a 100644 --- a/tests/Migration/Media/MediaFileProcessorRegistryTest.php +++ b/tests/Migration/Media/MediaFileProcessorRegistryTest.php @@ -46,9 +46,9 @@ public function testGetProcessorNotFound(): void $connection->setCredentialFields([]); $context = new MigrationContext( - new Shopware55Profile(), $connection, - '', + new Shopware55Profile(), + null, new FooDataSet() ); $context->setGateway(new DummyLocalGateway()); diff --git a/tests/Migration/Media/Process/HttpDownloadServiceBaseTest.php b/tests/Migration/Media/Process/HttpDownloadServiceBaseTest.php index 478997d72..06ed484a0 100644 --- a/tests/Migration/Media/Process/HttpDownloadServiceBaseTest.php +++ b/tests/Migration/Media/Process/HttpDownloadServiceBaseTest.php @@ -47,10 +47,11 @@ protected function setUp(): void $this->runId = Uuid::randomHex(); $this->loggingService = new DummyLoggingService(); $this->migrationContext = new MigrationContext( - new Shopware6MajorProfile('6.6.0'), new SwagMigrationConnectionEntity(), - Uuid::randomHex(), + new Shopware6MajorProfile('6.6.0'), null, + null, + Uuid::randomHex(), 0, 100 ); diff --git a/tests/Migration/MessageQueue/Handler/MigrationProcessHandlerTest.php b/tests/Migration/MessageQueue/Handler/MigrationProcessHandlerTest.php index 42d647392..fb8f01951 100644 --- a/tests/Migration/MessageQueue/Handler/MigrationProcessHandlerTest.php +++ b/tests/Migration/MessageQueue/Handler/MigrationProcessHandlerTest.php @@ -16,6 +16,7 @@ use Shopware\Core\Framework\Log\Package; use Shopware\Core\Framework\Uuid\Uuid; use SwagMigrationAssistant\Exception\MigrationException; +use SwagMigrationAssistant\Migration\Connection\SwagMigrationConnectionEntity; use SwagMigrationAssistant\Migration\MessageQueue\Handler\MigrationProcessHandler; use SwagMigrationAssistant\Migration\MessageQueue\Handler\MigrationProcessorRegistry; use SwagMigrationAssistant\Migration\MessageQueue\Handler\Processor\MigrationProcessorInterface; @@ -145,7 +146,10 @@ public function testInvoke(): void ->willReturn($this->createMock(MigrationProcessorInterface::class)); $migrationContextFactory = $this->createMock(MigrationContextFactoryInterface::class); - $migrationContextFactory->method('create')->willReturn(new MigrationContext(new Shopware55Profile())); + $migrationContextFactory->method('create')->willReturn(new MigrationContext( + new SwagMigrationConnectionEntity(), + new Shopware55Profile() + )); $this->migrationProcessHandler = new MigrationProcessHandler( $repository, diff --git a/tests/Migration/MessageQueue/Handler/Processor/AbortingProcessorTest.php b/tests/Migration/MessageQueue/Handler/Processor/AbortingProcessorTest.php index f5d739b6c..a7fd0b5a3 100644 --- a/tests/Migration/MessageQueue/Handler/Processor/AbortingProcessorTest.php +++ b/tests/Migration/MessageQueue/Handler/Processor/AbortingProcessorTest.php @@ -83,7 +83,7 @@ public function testProcessing(): void $connection = new SwagMigrationConnectionEntity(); $connection->setId(Uuid::randomHex()); - $migrationContext = new MigrationContext(new Shopware55Profile(), $connection); + $migrationContext = new MigrationContext($connection, new Shopware55Profile()); $this->processor->process( $migrationContext, diff --git a/tests/Migration/MessageQueue/Handler/Processor/CleanUpProcessorTest.php b/tests/Migration/MessageQueue/Handler/Processor/CleanUpProcessorTest.php index 759bd3631..5f3cd7320 100644 --- a/tests/Migration/MessageQueue/Handler/Processor/CleanUpProcessorTest.php +++ b/tests/Migration/MessageQueue/Handler/Processor/CleanUpProcessorTest.php @@ -58,7 +58,7 @@ public function testProcessing(): void $connection = new SwagMigrationConnectionEntity(); $connection->setId(Uuid::randomHex()); - $migrationContext = new MigrationContext(new Shopware55Profile(), $connection); + $migrationContext = new MigrationContext($connection, new Shopware55Profile()); $this->dbalConnection ->method('executeStatement') diff --git a/tests/Migration/MessageQueue/Handler/Processor/FetchingProcessorTest.php b/tests/Migration/MessageQueue/Handler/Processor/FetchingProcessorTest.php index d01af908c..df7ae7458 100644 --- a/tests/Migration/MessageQueue/Handler/Processor/FetchingProcessorTest.php +++ b/tests/Migration/MessageQueue/Handler/Processor/FetchingProcessorTest.php @@ -59,7 +59,7 @@ public function testProcessingWithoutData(): void $connection = new SwagMigrationConnectionEntity(); $connection->setId(Uuid::randomHex()); - $migrationContext = new MigrationContext(new Shopware55Profile(), $connection); + $migrationContext = new MigrationContext($connection, new Shopware55Profile()); $dataConverter = $this->createMock(MigrationDataConverter::class); $dataConverter @@ -106,7 +106,7 @@ public function testProcessing(): void $connection = new SwagMigrationConnectionEntity(); $connection->setId(Uuid::randomHex()); - $migrationContext = new MigrationContext(new Shopware55Profile(), $connection); + $migrationContext = new MigrationContext($connection, new Shopware55Profile()); $dataFetcher = $this->createMock(MigrationDataFetcher::class); $dataFetcher @@ -159,7 +159,15 @@ public function testProcessWithEmptyResultsShouldContinueWhileEntityTotalIsReach $connection = new SwagMigrationConnectionEntity(); $connection->setId(Uuid::randomHex()); - $migrationContext = new MigrationContext(new Shopware55Profile(), $connection, 'run-uuid', null, 0, 100); + $migrationContext = new MigrationContext( + $connection, + new Shopware55Profile(), + null, + null, + 'run-uuid', + 0, + 100 + ); $dataConverter = $this->createMock(MigrationDataConverter::class); // Method "convert" expected to be called 10 times @@ -219,7 +227,15 @@ public function testProcessShouldAddCurrentDataCountToProgress(): void $connection = new SwagMigrationConnectionEntity(); $connection->setId(Uuid::randomHex()); - $migrationContext = new MigrationContext(new Shopware55Profile(), $connection, 'run-uuid', null, 0, 100); + $migrationContext = new MigrationContext( + $connection, + new Shopware55Profile(), + null, + null, + 'run-uuid', + 0, + 100 + ); $dataConverter = $this->createMock(MigrationDataConverter::class); $dataFetcher = $this->createMock(MigrationDataFetcher::class); diff --git a/tests/Migration/MessageQueue/Handler/Processor/IndexingProcessorTest.php b/tests/Migration/MessageQueue/Handler/Processor/IndexingProcessorTest.php index 94be369d1..09723b7e9 100644 --- a/tests/Migration/MessageQueue/Handler/Processor/IndexingProcessorTest.php +++ b/tests/Migration/MessageQueue/Handler/Processor/IndexingProcessorTest.php @@ -71,7 +71,7 @@ public function testProcessingAndAborting(): void $connection = new SwagMigrationConnectionEntity(); $connection->setId(Uuid::randomHex()); - $migrationContext = new MigrationContext(new Shopware55Profile(), $connection); + $migrationContext = new MigrationContext($connection, new Shopware55Profile()); $runTransitionService = $this->createMock(RunTransitionServiceInterface::class); $runTransitionService @@ -119,7 +119,7 @@ public function testProcessing(): void $connection = new SwagMigrationConnectionEntity(); $connection->setId(Uuid::randomHex()); - $migrationContext = new MigrationContext(new Shopware55Profile(), $connection); + $migrationContext = new MigrationContext($connection, new Shopware55Profile()); $runTransitionService = $this->createMock(RunTransitionServiceInterface::class); $runTransitionService diff --git a/tests/Migration/MessageQueue/Handler/Processor/MediaProcessingProcessorTest.php b/tests/Migration/MessageQueue/Handler/Processor/MediaProcessingProcessorTest.php index 602d994f1..7f7a1c929 100644 --- a/tests/Migration/MessageQueue/Handler/Processor/MediaProcessingProcessorTest.php +++ b/tests/Migration/MessageQueue/Handler/Processor/MediaProcessingProcessorTest.php @@ -67,7 +67,13 @@ public function testProcessingWithoutMediaFiles(): void $connection = new SwagMigrationConnectionEntity(); $connection->setId(Uuid::randomHex()); - $migrationContext = new MigrationContext(new Shopware55Profile(), $connection, $run->getId()); + $migrationContext = new MigrationContext( + $connection, + new Shopware55Profile(), + null, + null, + $run->getId() + ); $runTransitionService = $this->createMock(RunTransitionServiceInterface::class); $runTransitionService @@ -114,7 +120,7 @@ public function testProcessing(): void $connection = new SwagMigrationConnectionEntity(); $connection->setId(Uuid::randomHex()); - $migrationContext = new MigrationContext(new Shopware55Profile(), $connection, $run->getId()); + $migrationContext = new MigrationContext($connection, new Shopware55Profile(), null, null, $run->getId()); $runTransitionService = $this->createMock(RunTransitionServiceInterface::class); $runTransitionService diff --git a/tests/Migration/MessageQueue/Handler/Processor/WritingProcessorTest.php b/tests/Migration/MessageQueue/Handler/Processor/WritingProcessorTest.php index 2663800dc..8c2a2898e 100644 --- a/tests/Migration/MessageQueue/Handler/Processor/WritingProcessorTest.php +++ b/tests/Migration/MessageQueue/Handler/Processor/WritingProcessorTest.php @@ -56,7 +56,7 @@ public function testProcessingWithoutData(): void $connection = new SwagMigrationConnectionEntity(); $connection->setId(Uuid::randomHex()); - $migrationContext = new MigrationContext(new Shopware55Profile(), $connection); + $migrationContext = new MigrationContext($connection, new Shopware55Profile()); $this->processor = new WritingProcessor( $this->createMock(EntityRepository::class), @@ -97,7 +97,7 @@ public function testProcessing(): void $connection = new SwagMigrationConnectionEntity(); $connection->setId(Uuid::randomHex()); - $migrationContext = new MigrationContext(new Shopware55Profile(), $connection); + $migrationContext = new MigrationContext($connection, new Shopware55Profile(), null); $migrationDataWriter = $this->createMock(MigrationDataWriter::class); $migrationDataWriter diff --git a/tests/Migration/Services/MigrationDataProcessingTest.php b/tests/Migration/Services/MigrationDataProcessingTest.php index c5de03b02..061ac313b 100644 --- a/tests/Migration/Services/MigrationDataProcessingTest.php +++ b/tests/Migration/Services/MigrationDataProcessingTest.php @@ -181,10 +181,11 @@ public function testFetchMediaDataApiGateway(): void { $context = Context::createDefaultContext(); $migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runUuid, + new Shopware55Profile(), + null, new MediaDataSet(), + $this->runUuid, 0, 250 ); @@ -209,10 +210,11 @@ public function testFetchCategoryDataApiGateway(): void { $context = Context::createDefaultContext(); $migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runUuid, + new Shopware55Profile(), + null, new CategoryDataSet(), + $this->runUuid, 0, 250 ); @@ -233,10 +235,11 @@ public function testFetchTranslationDataApiGateway(): void { $context = Context::createDefaultContext(); $migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runUuid, + new Shopware55Profile(), + null, new TranslationDataSet(), + $this->runUuid, 0, 250 ); @@ -257,10 +260,11 @@ public function testFetchCustomerDataApiGateway(): void { $context = Context::createDefaultContext(); $migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runUuid, + new Shopware55Profile(), + null, new CustomerDataSet(), + $this->runUuid, 0, 250 ); @@ -281,10 +285,11 @@ public function testFetchProductDataApiGateway(): void { $context = Context::createDefaultContext(); $migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runUuid, + new Shopware55Profile(), + null, new ProductDataSet(), + $this->runUuid, 0, 250 ); @@ -304,10 +309,11 @@ public function testFetchProductDataLocalGateway(): void { $context = Context::createDefaultContext(); $migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runUuid, + new Shopware55Profile(), + null, new ProductDataSet(), + $this->runUuid, 0, 250 ); @@ -327,10 +333,11 @@ public function testFetchInvalidCustomerData(): void { $context = Context::createDefaultContext(); $migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runUuid, + new Shopware55Profile(), + null, new InvalidCustomerDataSet(), + $this->runUuid, 0, 250 ); diff --git a/tests/Migration/Services/MigrationDataWriterTest.php b/tests/Migration/Services/MigrationDataWriterTest.php index 4f6ba7501..08cd48c34 100644 --- a/tests/Migration/Services/MigrationDataWriterTest.php +++ b/tests/Migration/Services/MigrationDataWriterTest.php @@ -336,10 +336,11 @@ public static function requiredProperties(): array public function testHandleWriteException(): void { $migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runUuid, + new Shopware55Profile(), + null, new ProductDataSet(), + $this->runUuid, 0, 250 ); @@ -374,10 +375,11 @@ public function testWriteInvalidData(string $missingProperty, bool $mappingExist { $context = Context::createDefaultContext(); $migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runUuid, + new Shopware55Profile(), + null, new CustomerDataSet(), + $this->runUuid, 0, 250 ); @@ -428,10 +430,11 @@ public function testWriteSalesChannelData(): void { $context = Context::createDefaultContext(); $migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runUuid, + new Shopware55Profile(), + null, new SalesChannelDataSet(), + $this->runUuid, 0, 250 ); @@ -455,10 +458,11 @@ public function testAssignThemeToSalesChannel(): void { $context = Context::createDefaultContext(); $migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runUuid, + new Shopware55Profile(), + null, new SalesChannelDataSet(), + $this->runUuid, 0, 250 ); @@ -481,10 +485,11 @@ public function testWriteCustomerData(): void { $context = Context::createDefaultContext(); $migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runUuid, + new Shopware55Profile(), + null, new CustomerDataSet(), + $this->runUuid, 0, 250 ); @@ -508,10 +513,11 @@ public function testWriteOrderData(): void $context = Context::createDefaultContext(); // Add users, who have ordered $userMigrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runUuid, + new Shopware55Profile(), + null, new CustomerDataSet(), + $this->runUuid, 0, 250 ); @@ -526,10 +532,11 @@ public function testWriteOrderData(): void // Add orders $migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runUuid, + new Shopware55Profile(), + null, new OrderDataSet(), + $this->runUuid, 0, 250 ); @@ -556,10 +563,11 @@ public function testWriteMediaData(): void { $context = Context::createDefaultContext(); $migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runUuid, + new Shopware55Profile(), + null, new MediaDataSet(), + $this->runUuid, 0, 250 ); @@ -581,10 +589,11 @@ public function testWriteCategoryData(): void { $context = Context::createDefaultContext(); $migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runUuid, + new Shopware55Profile(), + null, new CategoryDataSet(), + $this->runUuid, 0, 250 ); @@ -606,10 +615,11 @@ public function testWriteProductData(): void { $context = Context::createDefaultContext(); $migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runUuid, + new Shopware55Profile(), + null, new ProductDataSet(), + $this->runUuid, 0, 250 ); @@ -633,10 +643,11 @@ public function testWriteDataWithUnknownWriter(): void { $context = Context::createDefaultContext(); $migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runUuid, + new Shopware55Profile(), + null, new MediaDataSet(), + $this->runUuid, 0, 250 ); diff --git a/tests/Migration/Services/RunServiceTest.php b/tests/Migration/Services/RunServiceTest.php index a79357c3b..aee974830 100644 --- a/tests/Migration/Services/RunServiceTest.php +++ b/tests/Migration/Services/RunServiceTest.php @@ -123,8 +123,8 @@ protected function setUp(): void $this->migrationContextFactory = $this->createMock(MigrationContextFactory::class); $this->migrationContextFactory->method('createByConnection')->willReturn(new MigrationContext( - new Shopware55Profile(), $connectionEntity, + new Shopware55Profile(), )); $this->dataFetcher = $this->createMock(MigrationDataFetcher::class); diff --git a/tests/Mock/Gateway/Dummy/Local/DummyLocalGateway.php b/tests/Mock/Gateway/Dummy/Local/DummyLocalGateway.php index bafa4c631..e10b350b8 100644 --- a/tests/Mock/Gateway/Dummy/Local/DummyLocalGateway.php +++ b/tests/Mock/Gateway/Dummy/Local/DummyLocalGateway.php @@ -13,6 +13,7 @@ use SwagMigrationAssistant\Migration\EnvironmentInformation; use SwagMigrationAssistant\Migration\Gateway\GatewayInterface; use SwagMigrationAssistant\Migration\MigrationContextInterface; +use SwagMigrationAssistant\Migration\Profile\ProfileInterface; use SwagMigrationAssistant\Migration\TotalStruct; use SwagMigrationAssistant\Profile\Shopware\DataSelection\DataSet\CategoryDataSet; use SwagMigrationAssistant\Profile\Shopware\DataSelection\DataSet\CustomerDataSet; @@ -34,9 +35,9 @@ public function getName(): string return self::GATEWAY_NAME; } - public function supports(MigrationContextInterface $migrationContext): bool + public function supports(ProfileInterface $profile): bool { - return $migrationContext->getProfile() instanceof ShopwareProfileInterface; + return $profile instanceof ShopwareProfileInterface; } public function read(MigrationContextInterface $migrationContext): array diff --git a/tests/Profile/Shopware/Gateway/ApiEnvironmentReaderTest.php b/tests/Profile/Shopware/Gateway/ApiEnvironmentReaderTest.php index 3f00e62f3..1ef0cc180 100644 --- a/tests/Profile/Shopware/Gateway/ApiEnvironmentReaderTest.php +++ b/tests/Profile/Shopware/Gateway/ApiEnvironmentReaderTest.php @@ -19,6 +19,7 @@ use PHPUnit\Framework\TestCase; use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Exception\MigrationException; +use SwagMigrationAssistant\Migration\Connection\SwagMigrationConnectionEntity; use SwagMigrationAssistant\Migration\Gateway\HttpSimpleClient; use SwagMigrationAssistant\Migration\MigrationContext; use SwagMigrationAssistant\Migration\RequestStatusStruct; @@ -42,7 +43,8 @@ public function testEmptyClientReturnsRequestStatus(): void $environmentReader = new EnvironmentReader($connectionFactory); $migrationContext = new MigrationContext( - new Shopware55Profile() + new SwagMigrationConnectionEntity(), + new Shopware55Profile(), ); $response = $environmentReader->read($migrationContext); @@ -81,7 +83,8 @@ public function testResponseExceptions( $client = new HttpSimpleClient($options); $migrationContext = new MigrationContext( - new Shopware55Profile() + new SwagMigrationConnectionEntity(), + new Shopware55Profile(), ); $connectionFactory = $this->createMock(ConnectionFactory::class); @@ -230,6 +233,7 @@ public function testGetsEnvironmentInformation(): void $client = new HttpSimpleClient($options); $migrationContext = new MigrationContext( + new SwagMigrationConnectionEntity(), new Shopware55Profile() ); diff --git a/tests/Profile/Shopware/Gateway/ApiReaderTest.php b/tests/Profile/Shopware/Gateway/ApiReaderTest.php index d83186748..a216ff8b3 100644 --- a/tests/Profile/Shopware/Gateway/ApiReaderTest.php +++ b/tests/Profile/Shopware/Gateway/ApiReaderTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\TestCase; use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Exception\GatewayReadException; +use SwagMigrationAssistant\Migration\Connection\SwagMigrationConnectionEntity; use SwagMigrationAssistant\Migration\Gateway\HttpSimpleClient; use SwagMigrationAssistant\Migration\MigrationContext; use SwagMigrationAssistant\Profile\Shopware\DataSelection\DataSet\ProductDataSet; @@ -49,10 +50,10 @@ public function testRead(): void $client = new HttpSimpleClient($options); $migrationContext = new MigrationContext( + new SwagMigrationConnectionEntity(), new Shopware55Profile(), null, - '', - new ProductDataSet() + new ProductDataSet(), ); $mock = $this->getMockBuilder(ConnectionFactory::class)->getMock(); $mock->expects(static::once()) @@ -81,10 +82,10 @@ public function testReadGatewayException(): void $client = new HttpSimpleClient($options); $migrationContext = new MigrationContext( + new SwagMigrationConnectionEntity(), new Shopware55Profile(), null, - '', - new ProductDataSet() + new ProductDataSet(), ); $mock = $this->getMockBuilder(ConnectionFactory::class)->getMock(); $mock->expects(static::once()) diff --git a/tests/Profile/Shopware/Gateway/Local/CategoryAttributeReaderTest.php b/tests/Profile/Shopware/Gateway/Local/CategoryAttributeReaderTest.php index 83ffa7033..fe0119ad0 100644 --- a/tests/Profile/Shopware/Gateway/Local/CategoryAttributeReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/CategoryAttributeReaderTest.php @@ -32,10 +32,11 @@ protected function setUp(): void $this->categoryAttributeReader = new CategoryAttributeReader(new ConnectionFactory()); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runId, + new Shopware55Profile(), + null, new CategoryAttributeDataSet(), + $this->runId, 0, 10 ); diff --git a/tests/Profile/Shopware/Gateway/Local/CategoryReaderTest.php b/tests/Profile/Shopware/Gateway/Local/CategoryReaderTest.php index e506b333c..9ec0d3b7c 100644 --- a/tests/Profile/Shopware/Gateway/Local/CategoryReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/CategoryReaderTest.php @@ -32,10 +32,11 @@ protected function setUp(): void $this->categoryReader = new CategoryReader(new ConnectionFactory()); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runId, + new Shopware55Profile(), + null, new CategoryDataSet(), + $this->runId, 0, 10 ); @@ -67,10 +68,11 @@ public function testRead(): void static::assertSame('5', $data[3]['previousSiblingId']); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runId, + new Shopware55Profile(), + null, new CategoryDataSet(), + $this->runId, 10, 10 ); diff --git a/tests/Profile/Shopware/Gateway/Local/CurrencyReaderTest.php b/tests/Profile/Shopware/Gateway/Local/CurrencyReaderTest.php index a6971b7e5..835c6beb1 100644 --- a/tests/Profile/Shopware/Gateway/Local/CurrencyReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/CurrencyReaderTest.php @@ -32,10 +32,11 @@ protected function setUp(): void $this->currencyReader = new CurrencyReader(new ConnectionFactory()); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runId, + new Shopware55Profile(), + null, new CurrencyDataSet(), + $this->runId, 0, 10 ); diff --git a/tests/Profile/Shopware/Gateway/Local/CustomerAttributeReaderTest.php b/tests/Profile/Shopware/Gateway/Local/CustomerAttributeReaderTest.php index 4f6521933..6d6d92bdc 100644 --- a/tests/Profile/Shopware/Gateway/Local/CustomerAttributeReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/CustomerAttributeReaderTest.php @@ -32,10 +32,11 @@ protected function setUp(): void $this->customerAttributeReader = new CustomerAttributeReader(new ConnectionFactory()); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runId, + new Shopware55Profile(), + null, new CustomerAttributeDataSet(), + $this->runId, 0, 10 ); diff --git a/tests/Profile/Shopware/Gateway/Local/CustomerGroupAttributeReaderTest.php b/tests/Profile/Shopware/Gateway/Local/CustomerGroupAttributeReaderTest.php index 23f1d612e..b8c11ea84 100644 --- a/tests/Profile/Shopware/Gateway/Local/CustomerGroupAttributeReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/CustomerGroupAttributeReaderTest.php @@ -32,10 +32,11 @@ protected function setUp(): void $this->customerGroupAttributeReader = new CustomerGroupAttributeReader(new ConnectionFactory()); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runId, + new Shopware55Profile(), + null, new CustomerGroupAttributeDataSet(), + $this->runId, 0, 10 ); diff --git a/tests/Profile/Shopware/Gateway/Local/CustomerGroupReaderTest.php b/tests/Profile/Shopware/Gateway/Local/CustomerGroupReaderTest.php index aa302e178..011af1857 100644 --- a/tests/Profile/Shopware/Gateway/Local/CustomerGroupReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/CustomerGroupReaderTest.php @@ -32,10 +32,11 @@ protected function setUp(): void $this->customerGroupReader = new CustomerGroupReader(new ConnectionFactory()); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runId, + new Shopware55Profile(), + null, new CustomerGroupDataSet(), + $this->runId, 0, 10 ); diff --git a/tests/Profile/Shopware/Gateway/Local/CustomerReaderTest.php b/tests/Profile/Shopware/Gateway/Local/CustomerReaderTest.php index e7bca9c15..d3272eb1c 100644 --- a/tests/Profile/Shopware/Gateway/Local/CustomerReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/CustomerReaderTest.php @@ -32,10 +32,11 @@ protected function setUp(): void $this->customerReader = new CustomerReader(new ConnectionFactory()); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runId, + new Shopware55Profile(), + null, new CustomerDataSet(), + $this->runId, 0, 10 ); diff --git a/tests/Profile/Shopware/Gateway/Local/EnvironmentReaderTest.php b/tests/Profile/Shopware/Gateway/Local/EnvironmentReaderTest.php index cb9ef173c..7aa4a643b 100644 --- a/tests/Profile/Shopware/Gateway/Local/EnvironmentReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/EnvironmentReaderTest.php @@ -32,10 +32,11 @@ protected function setUp(): void $this->environmentReader = new EnvironmentReader(new ConnectionFactory()); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runId, + new Shopware55Profile(), + null, new CustomerDataSet(), + $this->runId, 0, 10 ); diff --git a/tests/Profile/Shopware/Gateway/Local/LanguageReaderTest.php b/tests/Profile/Shopware/Gateway/Local/LanguageReaderTest.php index 5ab00f05b..4b8d1c35e 100644 --- a/tests/Profile/Shopware/Gateway/Local/LanguageReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/LanguageReaderTest.php @@ -32,10 +32,11 @@ protected function setUp(): void $this->languageReader = new LanguageReader(new ConnectionFactory()); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runId, + new Shopware55Profile(), + null, new LanguageDataSet(), + $this->runId, 0, 10 ); diff --git a/tests/Profile/Shopware/Gateway/Local/MainVariantRelationReaderTest.php b/tests/Profile/Shopware/Gateway/Local/MainVariantRelationReaderTest.php index 8dd6eda05..9198d5255 100644 --- a/tests/Profile/Shopware/Gateway/Local/MainVariantRelationReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/MainVariantRelationReaderTest.php @@ -32,10 +32,11 @@ protected function setUp(): void $this->reader = new MainVariantRelationReader(new ConnectionFactory()); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runId, + new Shopware55Profile(), + null, new MainVariantRelationDataSet(), + $this->runId, 0, 10 ); diff --git a/tests/Profile/Shopware/Gateway/Local/ManufacturerAttributeReaderTest.php b/tests/Profile/Shopware/Gateway/Local/ManufacturerAttributeReaderTest.php index 341a59339..9010f7804 100644 --- a/tests/Profile/Shopware/Gateway/Local/ManufacturerAttributeReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/ManufacturerAttributeReaderTest.php @@ -32,10 +32,11 @@ protected function setUp(): void $this->manufacturerAttributeReader = new ManufacturerAttributeReader(new ConnectionFactory()); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runId, + new Shopware55Profile(), + null, new ManufacturerAttributeDataSet(), + $this->runId, 0, 10 ); diff --git a/tests/Profile/Shopware/Gateway/Local/MediaAlbumReaderTest.php b/tests/Profile/Shopware/Gateway/Local/MediaAlbumReaderTest.php index 7f9125920..65fbb257e 100644 --- a/tests/Profile/Shopware/Gateway/Local/MediaAlbumReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/MediaAlbumReaderTest.php @@ -32,10 +32,11 @@ protected function setUp(): void $this->mediaAlbumReader = new MediaAlbumReader(new ConnectionFactory()); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runId, + new Shopware55Profile(), + null, new MediaFolderDataSet(), + $this->runId, 0, 10 ); diff --git a/tests/Profile/Shopware/Gateway/Local/MediaReaderTest.php b/tests/Profile/Shopware/Gateway/Local/MediaReaderTest.php index 1b5246de9..adb513504 100644 --- a/tests/Profile/Shopware/Gateway/Local/MediaReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/MediaReaderTest.php @@ -35,10 +35,11 @@ protected function setUp(): void $this->mediaReader = new MediaReader(new ConnectionFactory()); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runId, + new Shopware55Profile(), + null, new MediaDataSet(), + $this->runId, 0, 10 ); diff --git a/tests/Profile/Shopware/Gateway/Local/NewsletterRecipientReaderTest.php b/tests/Profile/Shopware/Gateway/Local/NewsletterRecipientReaderTest.php index 9d7daf502..8de05b77b 100644 --- a/tests/Profile/Shopware/Gateway/Local/NewsletterRecipientReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/NewsletterRecipientReaderTest.php @@ -32,10 +32,11 @@ protected function setUp(): void $this->newsletterRecipientReader = new NewsletterRecipientReader(new ConnectionFactory()); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runId, + new Shopware55Profile(), + null, new NewsletterRecipientDataSet(), + $this->runId, 0, 10 ); diff --git a/tests/Profile/Shopware/Gateway/Local/NumberRangeReaderTest.php b/tests/Profile/Shopware/Gateway/Local/NumberRangeReaderTest.php index 6d670d674..1c6f21118 100644 --- a/tests/Profile/Shopware/Gateway/Local/NumberRangeReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/NumberRangeReaderTest.php @@ -33,10 +33,11 @@ protected function setUp(): void $this->numberRangeReader = new NumberRangeReader(new ConnectionFactory()); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runId, + new Shopware55Profile(), + null, new NumberRangeDataSet(), + $this->runId, 0, 10 ); @@ -86,10 +87,11 @@ public function testReadReturnsLimitedBatchSize(): void static::assertGreaterThan(4, $totalStruct->getTotal()); $migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runId, + new Shopware55Profile(), + null, new NumberRangeDataSet(), + $this->runId, 0, 4 ); diff --git a/tests/Profile/Shopware/Gateway/Local/OrderAttributeReaderTest.php b/tests/Profile/Shopware/Gateway/Local/OrderAttributeReaderTest.php index 2487dafb2..8dd7145a9 100644 --- a/tests/Profile/Shopware/Gateway/Local/OrderAttributeReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/OrderAttributeReaderTest.php @@ -32,10 +32,11 @@ protected function setUp(): void $this->orderAttributeReader = new OrderAttributeReader(new ConnectionFactory()); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runId, + new Shopware55Profile(), + null, new OrderAttributeDataSet(), + $this->runId, 0, 10 ); diff --git a/tests/Profile/Shopware/Gateway/Local/OrderDocumentAttributeReaderTest.php b/tests/Profile/Shopware/Gateway/Local/OrderDocumentAttributeReaderTest.php index c0ea7bc9c..870575fe7 100644 --- a/tests/Profile/Shopware/Gateway/Local/OrderDocumentAttributeReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/OrderDocumentAttributeReaderTest.php @@ -32,10 +32,11 @@ protected function setUp(): void $this->orderDocumentAttributeReader = new OrderDocumentAttributeReader(new ConnectionFactory()); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runId, + new Shopware55Profile(), + null, new OrderDocumentAttributeDataSet(), + $this->runId, 0, 10 ); diff --git a/tests/Profile/Shopware/Gateway/Local/OrderDocumentReaderTest.php b/tests/Profile/Shopware/Gateway/Local/OrderDocumentReaderTest.php index 0da471419..20cc6a6eb 100644 --- a/tests/Profile/Shopware/Gateway/Local/OrderDocumentReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/OrderDocumentReaderTest.php @@ -32,10 +32,11 @@ protected function setUp(): void $this->orderDocumentReader = new OrderDocumentReader(new ConnectionFactory()); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runId, + new Shopware55Profile(), + null, new OrderDocumentDataSet(), + $this->runId, 0, 5 ); diff --git a/tests/Profile/Shopware/Gateway/Local/OrderReaderTest.php b/tests/Profile/Shopware/Gateway/Local/OrderReaderTest.php index 4e795ec47..368502ca5 100644 --- a/tests/Profile/Shopware/Gateway/Local/OrderReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/OrderReaderTest.php @@ -122,10 +122,11 @@ public function testReadTotal(): void private function createMigrationContext(int $offset, int $limit): void { $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runId, + new Shopware55Profile(), + null, new OrderDataSet(), + $this->runId, $offset, $limit ); diff --git a/tests/Profile/Shopware/Gateway/Local/ProductAttributeReaderTest.php b/tests/Profile/Shopware/Gateway/Local/ProductAttributeReaderTest.php index 13d25323a..a1797b32b 100644 --- a/tests/Profile/Shopware/Gateway/Local/ProductAttributeReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/ProductAttributeReaderTest.php @@ -32,10 +32,11 @@ protected function setUp(): void $this->productAttributeReader = new ProductAttributeReader(new ConnectionFactory()); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runId, + new Shopware55Profile(), + null, new ProductAttributeDataSet(), + $this->runId, 0, 10 ); diff --git a/tests/Profile/Shopware/Gateway/Local/ProductPriceAttributeReaderTest.php b/tests/Profile/Shopware/Gateway/Local/ProductPriceAttributeReaderTest.php index 2aa0e5fb0..9ad7d938c 100644 --- a/tests/Profile/Shopware/Gateway/Local/ProductPriceAttributeReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/ProductPriceAttributeReaderTest.php @@ -32,10 +32,11 @@ protected function setUp(): void $this->productPriceAttributeReader = new ProductPriceAttributeReader(new ConnectionFactory()); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runId, + new Shopware55Profile(), + null, new ProductPriceAttributeDataSet(), + $this->runId, 0, 10 ); diff --git a/tests/Profile/Shopware/Gateway/Local/ProductReviewReaderTest.php b/tests/Profile/Shopware/Gateway/Local/ProductReviewReaderTest.php index d229cb7cf..14dda6870 100644 --- a/tests/Profile/Shopware/Gateway/Local/ProductReviewReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/ProductReviewReaderTest.php @@ -32,10 +32,11 @@ protected function setUp(): void $this->productReviewReader = new ProductReviewReader(new ConnectionFactory()); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runId, + new Shopware55Profile(), + null, new ProductReviewDataSet(), + $this->runId, 0, 10 ); diff --git a/tests/Profile/Shopware/Gateway/Local/PropertyGroupOptionReaderTest.php b/tests/Profile/Shopware/Gateway/Local/PropertyGroupOptionReaderTest.php index a18ca9964..af8928695 100644 --- a/tests/Profile/Shopware/Gateway/Local/PropertyGroupOptionReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/PropertyGroupOptionReaderTest.php @@ -32,10 +32,11 @@ protected function setUp(): void $this->propertyGroupOptionReader = new PropertyGroupOptionReader(new ConnectionFactory()); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runId, + new Shopware55Profile(), + null, new PropertyGroupOptionDataSet(), + $this->runId, 0, 10 ); diff --git a/tests/Profile/Shopware/Gateway/Local/SalesChannelReaderTest.php b/tests/Profile/Shopware/Gateway/Local/SalesChannelReaderTest.php index e54ef7832..ce3fe03a0 100644 --- a/tests/Profile/Shopware/Gateway/Local/SalesChannelReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/SalesChannelReaderTest.php @@ -32,10 +32,11 @@ protected function setUp(): void $this->salesChannelReader = new SalesChannelReader(new ConnectionFactory()); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runId, + new Shopware55Profile(), + null, new SalesChannelDataSet(), + $this->runId, 0, 10 ); diff --git a/tests/Profile/Shopware/Gateway/Local/ShippingMethodReaderTest.php b/tests/Profile/Shopware/Gateway/Local/ShippingMethodReaderTest.php index 854f6a125..37e644baf 100644 --- a/tests/Profile/Shopware/Gateway/Local/ShippingMethodReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/ShippingMethodReaderTest.php @@ -32,10 +32,11 @@ protected function setUp(): void $this->shippingMethodReader = new ShippingMethodReader(new ConnectionFactory()); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runId, + new Shopware55Profile(), + null, new ShippingMethodDataSet(), + $this->runId, 0, 10 ); diff --git a/tests/Profile/Shopware/Gateway/Local/TableReaderTest.php b/tests/Profile/Shopware/Gateway/Local/TableReaderTest.php index 2d6edb115..de0afda8c 100644 --- a/tests/Profile/Shopware/Gateway/Local/TableReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/TableReaderTest.php @@ -32,10 +32,11 @@ protected function setUp(): void $this->tableReader = new TableReader(new ConnectionFactory()); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runId, + new Shopware55Profile(), + null, new ShippingMethodDataSet(), + $this->runId, 0, 10 ); diff --git a/tests/Profile/Shopware/Gateway/Local/TranslationReaderTest.php b/tests/Profile/Shopware/Gateway/Local/TranslationReaderTest.php index b89c2c52f..180fee8b2 100644 --- a/tests/Profile/Shopware/Gateway/Local/TranslationReaderTest.php +++ b/tests/Profile/Shopware/Gateway/Local/TranslationReaderTest.php @@ -32,10 +32,11 @@ protected function setUp(): void $this->translationReader = new TranslationReader(new ConnectionFactory()); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $this->runId, + new Shopware55Profile(), + null, new TranslationDataSet(), + $this->runId, 50, 10 ); diff --git a/tests/Profile/Shopware/Gateway/LocalGatewayTest.php b/tests/Profile/Shopware/Gateway/LocalGatewayTest.php index 3ff22ac3c..4e6e2d253 100644 --- a/tests/Profile/Shopware/Gateway/LocalGatewayTest.php +++ b/tests/Profile/Shopware/Gateway/LocalGatewayTest.php @@ -54,9 +54,9 @@ public function testReadFailedNoCredentials(string $profileName, ProfileInterfac ); $migrationContext = new MigrationContext( - $profile, $connection, - '', + $profile, + null, new ProductDataSet() ); @@ -105,10 +105,10 @@ public function testReadWithUnknownEntityThrowsException(string $profileName, Pr ); $migrationContext = new MigrationContext( - $profile, $connection, - '', - new FooDataSet() + $profile, + null, + new FooDataSet(), ); $connectionFactory = new ConnectionFactory(); @@ -156,8 +156,8 @@ public function testReadEnvironmentInformationHasEmptyResult(string $profileName $connection->setCredentialFields([]); $migrationContext = new MigrationContext( + $connection, $profile, - $connection ); $readerRegistry = $this->getContainer()->get(ReaderRegistry::class); diff --git a/tests/Profile/Shopware/Gateway/ShopwareApiGatewayTest.php b/tests/Profile/Shopware/Gateway/ShopwareApiGatewayTest.php index bc5f2314b..c4da62be4 100644 --- a/tests/Profile/Shopware/Gateway/ShopwareApiGatewayTest.php +++ b/tests/Profile/Shopware/Gateway/ShopwareApiGatewayTest.php @@ -36,10 +36,11 @@ class ShopwareApiGatewayTest extends TestCase public function testReadFailed(): void { $migrationContext = new MigrationContext( - new Shopware55Profile(), new SwagMigrationConnectionEntity(), - '', - new FooDataSet() + new Shopware55Profile(), + null, + new FooDataSet(), + '' ); $connectionFactory = new ConnectionFactory(); @@ -78,8 +79,8 @@ public function testReadEnvironmentInformationFailed(): void 'apiKey' => 'testing', ]); $migrationContext = new MigrationContext( + $connection, new Shopware55Profile(), - $connection ); $connectionFactory = new ConnectionFactory(); @@ -110,8 +111,8 @@ public function testReadEnvironmentInformation(): void $connection->setCredentialFields(['endpoint' => 'foo']); $migrationContext = new MigrationContext( + $connection, new Shopware55Profile(), - $connection ); $connectionFactory = new ConnectionFactory(); @@ -141,8 +142,8 @@ public function testReadEnvironmentInformationWithoutSourceDefaultLanguage(): vo $connection->setCredentialFields(['endpoint' => 'foo']); $migrationContext = new MigrationContext( + $connection, new Shopware55Profile(), - $connection ); $connectionFactory = new ConnectionFactory(); diff --git a/tests/Profile/Shopware/Premapping/DefaultShippingAvailabilityRuleReaderTest.php b/tests/Profile/Shopware/Premapping/DefaultShippingAvailabilityRuleReaderTest.php index d9d2c2426..2f2867aaa 100644 --- a/tests/Profile/Shopware/Premapping/DefaultShippingAvailabilityRuleReaderTest.php +++ b/tests/Profile/Shopware/Premapping/DefaultShippingAvailabilityRuleReaderTest.php @@ -46,15 +46,18 @@ class DefaultShippingAvailabilityRuleReaderTest extends TestCase protected function setUp(): void { - $this->context = Context::createDefaultContext(); - $this->migrationContext = new MigrationContext(new Shopware55Profile()); - $this->connection = new SwagMigrationConnectionEntity(); $this->connection->setId(Uuid::randomHex()); $this->connection->setProfileName(Shopware55Profile::PROFILE_NAME); $this->connection->setGatewayName(ShopwareLocalGateway::GATEWAY_NAME); $this->connection->setCredentialFields([]); + $this->context = Context::createDefaultContext(); + $this->migrationContext = new MigrationContext( + $this->connection, + new Shopware55Profile(), + ); + $this->ruleEntity = new RuleEntity(); $this->ruleEntity->setId(Uuid::randomHex()); $this->ruleEntity->setName('My default rule'); @@ -77,8 +80,9 @@ public function testGetValidPremapping(): void $mock->method('search')->willReturn(new EntitySearchResult(RuleDefinition::ENTITY_NAME, 2, new EntityCollection([$this->ruleEntity, $this->anotherRuleEntity]), null, new Criteria(), $this->context)); $this->migrationContext = new MigrationContext( + $this->connection, new Shopware55Profile(), - $this->connection + null ); $this->reader = new DefaultShippingAvailabilityRuleReader($mock); @@ -107,8 +111,9 @@ public function testGetInvalidPremapping(): void $mock->method('search')->willReturn(new EntitySearchResult(RuleDefinition::ENTITY_NAME, 2, new EntityCollection([$this->ruleEntity, $this->anotherRuleEntity]), null, new Criteria(), $this->context)); $this->migrationContext = new MigrationContext( + $this->connection, new Shopware55Profile(), - $this->connection + null ); $this->reader = new DefaultShippingAvailabilityRuleReader($mock); diff --git a/tests/Profile/Shopware/Premapping/DeliveryTimeReaderTest.php b/tests/Profile/Shopware/Premapping/DeliveryTimeReaderTest.php index 65a60fd4f..5f2c23220 100644 --- a/tests/Profile/Shopware/Premapping/DeliveryTimeReaderTest.php +++ b/tests/Profile/Shopware/Premapping/DeliveryTimeReaderTest.php @@ -71,8 +71,8 @@ protected function setUp(): void $this->deliveryTimeReader = new DeliveryTimeReader($mock); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), - $connection + $connection, + new Shopware55Profile() ); } @@ -104,8 +104,9 @@ public function testGetPremappingInvalidUuid(): void $connection->setPremapping($premapping); $this->migrationContext = new MigrationContext( + $connection, new Shopware55Profile(), - $connection + null ); $result = $this->deliveryTimeReader->getPremapping($this->context, $this->migrationContext); diff --git a/tests/Profile/Shopware/Premapping/NewsletterRecipientStatusReaderTest.php b/tests/Profile/Shopware/Premapping/NewsletterRecipientStatusReaderTest.php index 0a54729a7..f94985752 100644 --- a/tests/Profile/Shopware/Premapping/NewsletterRecipientStatusReaderTest.php +++ b/tests/Profile/Shopware/Premapping/NewsletterRecipientStatusReaderTest.php @@ -42,8 +42,8 @@ protected function setUp(): void $this->context = Context::createDefaultContext(); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), - $connection + $connection, + new Shopware55Profile() ); $this->reader = new NewsletterRecipientStatusReader(); diff --git a/tests/Profile/Shopware/Premapping/OrderDeliveryStateReaderTest.php b/tests/Profile/Shopware/Premapping/OrderDeliveryStateReaderTest.php index 9e18cc000..05e2e8ea3 100644 --- a/tests/Profile/Shopware/Premapping/OrderDeliveryStateReaderTest.php +++ b/tests/Profile/Shopware/Premapping/OrderDeliveryStateReaderTest.php @@ -83,8 +83,8 @@ protected function setUp(): void $connection->setPremapping($premapping); $this->migrationContext = new MigrationContext( + $connection, new Shopware55Profile(), - $connection ); $gatewayMock = $this->createMock(ShopwareLocalGateway::class); diff --git a/tests/Profile/Shopware/Premapping/OrderStateReaderTest.php b/tests/Profile/Shopware/Premapping/OrderStateReaderTest.php index 58cdd34d5..129543e9c 100644 --- a/tests/Profile/Shopware/Premapping/OrderStateReaderTest.php +++ b/tests/Profile/Shopware/Premapping/OrderStateReaderTest.php @@ -83,8 +83,8 @@ protected function setUp(): void $connection->setPremapping($premapping); $this->migrationContext = new MigrationContext( + $connection, new Shopware55Profile(), - $connection ); $gatewayMock = $this->createMock(ShopwareLocalGateway::class); diff --git a/tests/Profile/Shopware/Premapping/PaymentMethodReaderTest.php b/tests/Profile/Shopware/Premapping/PaymentMethodReaderTest.php index 78a2d5700..defe5117c 100644 --- a/tests/Profile/Shopware/Premapping/PaymentMethodReaderTest.php +++ b/tests/Profile/Shopware/Premapping/PaymentMethodReaderTest.php @@ -89,8 +89,8 @@ protected function setUp(): void $gatewayRegistryMock->method('getGateway')->willReturn($gatewayMock); $this->migrationContext = new MigrationContext( + $connection, new Shopware55Profile(), - $connection ); $this->reader = new PaymentMethodReader($mock, $gatewayRegistryMock); diff --git a/tests/Profile/Shopware/Premapping/SalutationReaderTest.php b/tests/Profile/Shopware/Premapping/SalutationReaderTest.php index b08463715..072080c85 100644 --- a/tests/Profile/Shopware/Premapping/SalutationReaderTest.php +++ b/tests/Profile/Shopware/Premapping/SalutationReaderTest.php @@ -84,8 +84,9 @@ protected function setUp(): void $gatewayRegistryMock->method('getGateway')->willReturn($gatewayMock); $this->migrationContext = new MigrationContext( + $connection, new Shopware55Profile(), - $connection + null ); $this->reader = new SalutationReader($mock, $gatewayRegistryMock); diff --git a/tests/Profile/Shopware/Premapping/TransactionStateReaderTest.php b/tests/Profile/Shopware/Premapping/TransactionStateReaderTest.php index 4834fa5e8..a0703709a 100644 --- a/tests/Profile/Shopware/Premapping/TransactionStateReaderTest.php +++ b/tests/Profile/Shopware/Premapping/TransactionStateReaderTest.php @@ -83,8 +83,9 @@ protected function setUp(): void $connection->setPremapping($premapping); $this->migrationContext = new MigrationContext( + $connection, new Shopware55Profile(), - $connection + null ); $gatewayMock = $this->createMock(ShopwareLocalGateway::class); diff --git a/tests/Profile/Shopware54/Converter/OrderDocumentConverterTest.php b/tests/Profile/Shopware54/Converter/OrderDocumentConverterTest.php index 9e0017e60..a7a69a0f2 100644 --- a/tests/Profile/Shopware54/Converter/OrderDocumentConverterTest.php +++ b/tests/Profile/Shopware54/Converter/OrderDocumentConverterTest.php @@ -74,10 +74,11 @@ protected function setUp(): void $this->connection->setGatewayName(ShopwareLocalGateway::GATEWAY_NAME); $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Shopware54Profile(), $this->connection, - $this->runId, + new Shopware54Profile(), + null, new OrderDocumentDataSet(), + $this->runId, 0, 250 ); diff --git a/tests/Profile/Shopware54/Converter/ProductConverterTest.php b/tests/Profile/Shopware54/Converter/ProductConverterTest.php index c8cda6693..c35586835 100644 --- a/tests/Profile/Shopware54/Converter/ProductConverterTest.php +++ b/tests/Profile/Shopware54/Converter/ProductConverterTest.php @@ -65,10 +65,11 @@ public function testConvertShouldConvertSeoMainCategories(): void $runId = Uuid::randomHex(); $migrationContext = new MigrationContext( - new Shopware54Profile(), $connection, - $runId, + new Shopware54Profile(), + null, new ProductDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware55/Converter/CategoryAttributeConverterTest.php b/tests/Profile/Shopware55/Converter/CategoryAttributeConverterTest.php index 9d65d131a..cb7646a3d 100644 --- a/tests/Profile/Shopware55/Converter/CategoryAttributeConverterTest.php +++ b/tests/Profile/Shopware55/Converter/CategoryAttributeConverterTest.php @@ -39,10 +39,11 @@ protected function setUp(): void $connection->setProfileName(Shopware55Profile::PROFILE_NAME); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $connection, - $runId, + new Shopware55Profile(), + null, new CategoryAttributeDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware55/Converter/CategoryConverterTest.php b/tests/Profile/Shopware55/Converter/CategoryConverterTest.php index f998c66c2..abdc073d2 100644 --- a/tests/Profile/Shopware55/Converter/CategoryConverterTest.php +++ b/tests/Profile/Shopware55/Converter/CategoryConverterTest.php @@ -62,10 +62,11 @@ protected function setUp(): void $connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $connection, - $runId, + new Shopware55Profile(), + null, new CategoryDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware55/Converter/CrossSellingConverterTest.php b/tests/Profile/Shopware55/Converter/CrossSellingConverterTest.php index 98f6872e7..8c5ae3140 100644 --- a/tests/Profile/Shopware55/Converter/CrossSellingConverterTest.php +++ b/tests/Profile/Shopware55/Converter/CrossSellingConverterTest.php @@ -80,10 +80,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $runId, + new Shopware55Profile(), + null, new CrossSellingDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware55/Converter/CurrencyConverterTest.php b/tests/Profile/Shopware55/Converter/CurrencyConverterTest.php index 47596da9f..66e4dc60f 100644 --- a/tests/Profile/Shopware55/Converter/CurrencyConverterTest.php +++ b/tests/Profile/Shopware55/Converter/CurrencyConverterTest.php @@ -57,10 +57,11 @@ protected function setUp(): void $connection->setProfileName(Shopware55Profile::PROFILE_NAME); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $connection, - $runId, + new Shopware55Profile(), + null, new CurrencyDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware55/Converter/CustomerAttributeConverterTest.php b/tests/Profile/Shopware55/Converter/CustomerAttributeConverterTest.php index 3c6cdb43c..dcb16e6eb 100644 --- a/tests/Profile/Shopware55/Converter/CustomerAttributeConverterTest.php +++ b/tests/Profile/Shopware55/Converter/CustomerAttributeConverterTest.php @@ -37,10 +37,11 @@ protected function setUp(): void $connection->setProfileName(Shopware55Profile::PROFILE_NAME); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $connection, - $runId, + new Shopware55Profile(), + null, new CustomerAttributeDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware55/Converter/CustomerConverterTest.php b/tests/Profile/Shopware55/Converter/CustomerConverterTest.php index 0011d904a..d8a76f604 100644 --- a/tests/Profile/Shopware55/Converter/CustomerConverterTest.php +++ b/tests/Profile/Shopware55/Converter/CustomerConverterTest.php @@ -75,10 +75,11 @@ protected function setUp(): void $connection->setGatewayName(ShopwareLocalGateway::GATEWAY_NAME); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $connection, - $runId, + new Shopware55Profile(), + null, new CustomerDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware55/Converter/CustomerGroupAttributeConverterTest.php b/tests/Profile/Shopware55/Converter/CustomerGroupAttributeConverterTest.php index 38cd9509c..54c2d51bf 100644 --- a/tests/Profile/Shopware55/Converter/CustomerGroupAttributeConverterTest.php +++ b/tests/Profile/Shopware55/Converter/CustomerGroupAttributeConverterTest.php @@ -37,10 +37,11 @@ protected function setUp(): void $connection->setProfileName(Shopware55Profile::PROFILE_NAME); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $connection, - $runId, + new Shopware55Profile(), + null, new CustomerGroupAttributeDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware55/Converter/CustomerGroupConverterTest.php b/tests/Profile/Shopware55/Converter/CustomerGroupConverterTest.php index 2b6567b2b..a766f6811 100644 --- a/tests/Profile/Shopware55/Converter/CustomerGroupConverterTest.php +++ b/tests/Profile/Shopware55/Converter/CustomerGroupConverterTest.php @@ -58,10 +58,11 @@ protected function setUp(): void $connection->setProfileName(Shopware55Profile::PROFILE_NAME); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $connection, - $runId, + new Shopware55Profile(), + null, new CustomerGroupDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware55/Converter/CustomerWishlistConverterTest.php b/tests/Profile/Shopware55/Converter/CustomerWishlistConverterTest.php index 03d4d87e0..a8b080157 100644 --- a/tests/Profile/Shopware55/Converter/CustomerWishlistConverterTest.php +++ b/tests/Profile/Shopware55/Converter/CustomerWishlistConverterTest.php @@ -43,10 +43,11 @@ protected function setUp(): void $connection->setProfileName(Shopware55Profile::PROFILE_NAME); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $connection, - $runId, + new Shopware55Profile(), + null, new CustomerWishlistDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware55/Converter/LanguageConverterTest.php b/tests/Profile/Shopware55/Converter/LanguageConverterTest.php index 45adc5d1e..bee77f357 100644 --- a/tests/Profile/Shopware55/Converter/LanguageConverterTest.php +++ b/tests/Profile/Shopware55/Converter/LanguageConverterTest.php @@ -50,10 +50,11 @@ protected function setUp(): void $connection->setProfileName(Shopware55Profile::PROFILE_NAME); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $connection, - $runId, + new Shopware55Profile(), + null, new LanguageDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware55/Converter/MainVariantRelationConverterTest.php b/tests/Profile/Shopware55/Converter/MainVariantRelationConverterTest.php index 60dac08d2..0f8b5c5bf 100644 --- a/tests/Profile/Shopware55/Converter/MainVariantRelationConverterTest.php +++ b/tests/Profile/Shopware55/Converter/MainVariantRelationConverterTest.php @@ -62,10 +62,11 @@ protected function setUp(): void $connection->setProfileName(Shopware55Profile::PROFILE_NAME); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $connection, - $runId, + new Shopware55Profile(), + null, new MainVariantRelationDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware55/Converter/ManufacturerAttributeConverterTest.php b/tests/Profile/Shopware55/Converter/ManufacturerAttributeConverterTest.php index 246f0875b..c30a30732 100644 --- a/tests/Profile/Shopware55/Converter/ManufacturerAttributeConverterTest.php +++ b/tests/Profile/Shopware55/Converter/ManufacturerAttributeConverterTest.php @@ -37,10 +37,11 @@ protected function setUp(): void $connection->setProfileName(Shopware55Profile::PROFILE_NAME); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $connection, - $runId, + new Shopware55Profile(), + null, new ManufacturerAttributeDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware55/Converter/MediaConverterTest.php b/tests/Profile/Shopware55/Converter/MediaConverterTest.php index b2868b60a..c756735da 100644 --- a/tests/Profile/Shopware55/Converter/MediaConverterTest.php +++ b/tests/Profile/Shopware55/Converter/MediaConverterTest.php @@ -48,10 +48,11 @@ protected function setUp(): void $connection->setProfileName(Shopware55Profile::PROFILE_NAME); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $connection, - $runId, + new Shopware55Profile(), + null, new MediaDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware55/Converter/MediaFolderConverterTest.php b/tests/Profile/Shopware55/Converter/MediaFolderConverterTest.php index 800b26309..2c8c294e4 100644 --- a/tests/Profile/Shopware55/Converter/MediaFolderConverterTest.php +++ b/tests/Profile/Shopware55/Converter/MediaFolderConverterTest.php @@ -47,10 +47,11 @@ protected function setUp(): void $connection->setProfileName(Shopware55Profile::PROFILE_NAME); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $connection, - $runId, + new Shopware55Profile(), + null, new MediaFolderDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware55/Converter/NewsletterRecipientConverterTest.php b/tests/Profile/Shopware55/Converter/NewsletterRecipientConverterTest.php index fcd63dd9f..f45d56585 100644 --- a/tests/Profile/Shopware55/Converter/NewsletterRecipientConverterTest.php +++ b/tests/Profile/Shopware55/Converter/NewsletterRecipientConverterTest.php @@ -53,10 +53,11 @@ protected function setUp(): void $connection->setGatewayName(ShopwareLocalGateway::GATEWAY_NAME); $this->context = new MigrationContext( - new Shopware55Profile(), $connection, - $runId, + new Shopware55Profile(), + null, new NewsletterRecipientDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware55/Converter/NumberRangeConverterTest.php b/tests/Profile/Shopware55/Converter/NumberRangeConverterTest.php index 66c65ffe1..1747507da 100644 --- a/tests/Profile/Shopware55/Converter/NumberRangeConverterTest.php +++ b/tests/Profile/Shopware55/Converter/NumberRangeConverterTest.php @@ -50,10 +50,11 @@ protected function setUp(): void $connection->setProfileName(Shopware55Profile::PROFILE_NAME); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $connection, - $runId, + new Shopware55Profile(), + null, new NumberRangeDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware55/Converter/OrderAttributeConverterTest.php b/tests/Profile/Shopware55/Converter/OrderAttributeConverterTest.php index c93506eee..c3e4c10f8 100644 --- a/tests/Profile/Shopware55/Converter/OrderAttributeConverterTest.php +++ b/tests/Profile/Shopware55/Converter/OrderAttributeConverterTest.php @@ -39,10 +39,11 @@ protected function setUp(): void $connection->setName('ConnectionName'); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $connection, - $runId, + new Shopware55Profile(), + null, new OrderAttributeDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware55/Converter/OrderConverterTest.php b/tests/Profile/Shopware55/Converter/OrderConverterTest.php index 1256004e9..c5eb150d9 100644 --- a/tests/Profile/Shopware55/Converter/OrderConverterTest.php +++ b/tests/Profile/Shopware55/Converter/OrderConverterTest.php @@ -110,19 +110,21 @@ protected function setUp(): void $connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $connection, - $runId, + new Shopware55Profile(), + null, new OrderDataSet(), + $runId, 0, 250 ); $this->customerMigrationContext = new MigrationContext( - new Shopware55Profile(), $connection, - $runId, + new Shopware55Profile(), + null, new CustomerDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware55/Converter/ProductAttributeConverterTest.php b/tests/Profile/Shopware55/Converter/ProductAttributeConverterTest.php index 9451d2c9e..da97a983c 100644 --- a/tests/Profile/Shopware55/Converter/ProductAttributeConverterTest.php +++ b/tests/Profile/Shopware55/Converter/ProductAttributeConverterTest.php @@ -39,10 +39,11 @@ protected function setUp(): void $connection->setProfileName(Shopware55Profile::PROFILE_NAME); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $connection, - $runId, + new Shopware55Profile(), + null, new ProductAttributeDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware55/Converter/ProductConverterTest.php b/tests/Profile/Shopware55/Converter/ProductConverterTest.php index f945ad0c2..6d28d0be1 100644 --- a/tests/Profile/Shopware55/Converter/ProductConverterTest.php +++ b/tests/Profile/Shopware55/Converter/ProductConverterTest.php @@ -69,10 +69,11 @@ protected function setUp(): void $connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $connection, - $runId, + new Shopware55Profile(), + null, new ProductDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware55/Converter/ProductOptionRelationConverterTest.php b/tests/Profile/Shopware55/Converter/ProductOptionRelationConverterTest.php index 5b5edc3ba..4f3635330 100644 --- a/tests/Profile/Shopware55/Converter/ProductOptionRelationConverterTest.php +++ b/tests/Profile/Shopware55/Converter/ProductOptionRelationConverterTest.php @@ -53,10 +53,11 @@ protected function setUp(): void $connection->setProfileName(Shopware55Profile::PROFILE_NAME); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $connection, - $runId, + new Shopware55Profile(), + null, new ProductOptionRelationDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware55/Converter/ProductPriceAttributeConverterTest.php b/tests/Profile/Shopware55/Converter/ProductPriceAttributeConverterTest.php index 1d6c8fda0..213e0d4cf 100644 --- a/tests/Profile/Shopware55/Converter/ProductPriceAttributeConverterTest.php +++ b/tests/Profile/Shopware55/Converter/ProductPriceAttributeConverterTest.php @@ -37,10 +37,11 @@ protected function setUp(): void $connection->setProfileName(Shopware55Profile::PROFILE_NAME); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $connection, - $runId, + new Shopware55Profile(), + null, new ProductPriceAttributeDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware55/Converter/ProductPropertyRelationConverterTest.php b/tests/Profile/Shopware55/Converter/ProductPropertyRelationConverterTest.php index aaac60b9a..5f3fae718 100644 --- a/tests/Profile/Shopware55/Converter/ProductPropertyRelationConverterTest.php +++ b/tests/Profile/Shopware55/Converter/ProductPropertyRelationConverterTest.php @@ -51,10 +51,11 @@ protected function setUp(): void $connection->setProfileName(Shopware55Profile::PROFILE_NAME); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $connection, - $runId, + new Shopware55Profile(), + null, new ProductPropertyRelationDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware55/Converter/ProductReviewConverterTest.php b/tests/Profile/Shopware55/Converter/ProductReviewConverterTest.php index 8b423f326..594a89dab 100644 --- a/tests/Profile/Shopware55/Converter/ProductReviewConverterTest.php +++ b/tests/Profile/Shopware55/Converter/ProductReviewConverterTest.php @@ -65,10 +65,11 @@ protected function setUp(): void $connection->setProfileName(Shopware55Profile::PROFILE_NAME); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $connection, - $runId, + new Shopware55Profile(), + null, new ProductReviewDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware55/Converter/PromotionConverterTest.php b/tests/Profile/Shopware55/Converter/PromotionConverterTest.php index c1e67cf0d..29c62c30d 100644 --- a/tests/Profile/Shopware55/Converter/PromotionConverterTest.php +++ b/tests/Profile/Shopware55/Converter/PromotionConverterTest.php @@ -67,10 +67,11 @@ protected function setUp(): void $connectionId = $connection->getId(); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $connection, - $runId, + new Shopware55Profile(), + null, new PromotionDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware55/Converter/PropertyGroupOptionConverterTest.php b/tests/Profile/Shopware55/Converter/PropertyGroupOptionConverterTest.php index 7c7896b3e..f5a27bc54 100644 --- a/tests/Profile/Shopware55/Converter/PropertyGroupOptionConverterTest.php +++ b/tests/Profile/Shopware55/Converter/PropertyGroupOptionConverterTest.php @@ -96,10 +96,11 @@ protected function setUp(): void $this->connection->setName('shopware'); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $runId, + new Shopware55Profile(), + null, new PropertyGroupOptionDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware55/Converter/SalesChannelConverterTest.php b/tests/Profile/Shopware55/Converter/SalesChannelConverterTest.php index 311ee05f7..cf710474f 100644 --- a/tests/Profile/Shopware55/Converter/SalesChannelConverterTest.php +++ b/tests/Profile/Shopware55/Converter/SalesChannelConverterTest.php @@ -69,10 +69,11 @@ protected function setUp(): void $connection->setProfileName(Shopware55Profile::PROFILE_NAME); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $connection, - $runId, + new Shopware55Profile(), + null, new SalesChannelDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware55/Converter/ShippingMethodConverterTest.php b/tests/Profile/Shopware55/Converter/ShippingMethodConverterTest.php index 6cf42e995..fe93cdfdd 100644 --- a/tests/Profile/Shopware55/Converter/ShippingMethodConverterTest.php +++ b/tests/Profile/Shopware55/Converter/ShippingMethodConverterTest.php @@ -77,10 +77,11 @@ protected function setUp(): void $this->context = Context::createDefaultContext(); $this->migrationContext = new MigrationContext( - new Shopware55Profile(), $this->connection, - $runId, + new Shopware55Profile(), + null, new ShippingMethodDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware55/Converter/TranslationConverterTest.php b/tests/Profile/Shopware55/Converter/TranslationConverterTest.php index eb5f20c32..1d452d25b 100644 --- a/tests/Profile/Shopware55/Converter/TranslationConverterTest.php +++ b/tests/Profile/Shopware55/Converter/TranslationConverterTest.php @@ -95,28 +95,31 @@ protected function setUp(): void $profile = new Shopware55Profile(); $this->migrationContext = new MigrationContext( - $profile, $connection, - $runId, + $profile, + null, new TranslationDataSet(), + $runId, 0, 250 ); $this->productMigrationContext = new MigrationContext( - $profile, $connection, - $runId, + $profile, + null, new ProductDataSet(), + $runId, 0, 250 ); $this->categoryMigrationContext = new MigrationContext( - $profile, $connection, - $runId, + $profile, + null, new CategoryDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware57/Converter/ProductAttributeConverterTest.php b/tests/Profile/Shopware57/Converter/ProductAttributeConverterTest.php index ee0fe2510..bf56b26d4 100644 --- a/tests/Profile/Shopware57/Converter/ProductAttributeConverterTest.php +++ b/tests/Profile/Shopware57/Converter/ProductAttributeConverterTest.php @@ -39,10 +39,11 @@ protected function setUp(): void $connection->setProfileName(Shopware57Profile::PROFILE_NAME); $this->migrationContext = new MigrationContext( - new Shopware57Profile(), $connection, - $runId, + new Shopware57Profile(), + null, new ProductAttributeDataSet(), + $runId, 0, 250 ); diff --git a/tests/Profile/Shopware6/Converter/LanguageConverterConvertDataTest.php b/tests/Profile/Shopware6/Converter/LanguageConverterConvertDataTest.php index a62cb2431..559e23a42 100644 --- a/tests/Profile/Shopware6/Converter/LanguageConverterConvertDataTest.php +++ b/tests/Profile/Shopware6/Converter/LanguageConverterConvertDataTest.php @@ -159,10 +159,11 @@ private function createMigrationContext(): MigrationContext $migrationConnectionEntity->setId(Uuid::randomHex()); return new MigrationContext( - new Shopware6MajorProfile('6.6.0.0'), $migrationConnectionEntity, - Uuid::randomHex(), + new Shopware6MajorProfile('6.6.0.0'), + null, new LanguageDataSet(), + Uuid::randomHex(), 0, 10 ); diff --git a/tests/Profile/Shopware6/Converter/SeoUrlConverterConvertDataTest.php b/tests/Profile/Shopware6/Converter/SeoUrlConverterConvertDataTest.php index b9fe08772..eca23847e 100644 --- a/tests/Profile/Shopware6/Converter/SeoUrlConverterConvertDataTest.php +++ b/tests/Profile/Shopware6/Converter/SeoUrlConverterConvertDataTest.php @@ -49,10 +49,11 @@ private function createMigrationContext(): MigrationContext $migrationConnectionEntity->setId(Uuid::randomHex()); return new MigrationContext( - new Shopware6MajorProfile('6.6.0.0'), $migrationConnectionEntity, - Uuid::randomHex(), + new Shopware6MajorProfile('6.6.0.0'), + null, new SeoUrlDataSet(), + Uuid::randomHex(), 0, 10 ); diff --git a/tests/Profile/Shopware6/Converter/ShopwareConverterTest.php b/tests/Profile/Shopware6/Converter/ShopwareConverterTest.php index 5a1a36a2c..fe76c80b5 100644 --- a/tests/Profile/Shopware6/Converter/ShopwareConverterTest.php +++ b/tests/Profile/Shopware6/Converter/ShopwareConverterTest.php @@ -52,10 +52,11 @@ protected function setUp(): void $connection->setId(Uuid::randomHex()); $connection->setProfileName($this->getProfileName()); $this->migrationContext = new MigrationContext( - $this->createProfile(), $connection, - $runId, + $this->createProfile(), + null, $this->createDataSet(), + $runId, 0, 250 ); @@ -166,13 +167,8 @@ protected function getProfileName(): string protected function loadMapping(array $mappingArray): void { - $connection = $this->migrationContext->getConnection(); - - if ($connection === null) { - return; - } + $connectionId = $this->migrationContext->getConnection()->getId(); - $connectionId = $connection->getId(); foreach ($mappingArray as $mapping) { $mappingConnection = null; if (isset($mapping['connectionId'])) { diff --git a/tests/Profile/Shopware6/Gateway/Api/Reader/EnvironmentReaderTest.php b/tests/Profile/Shopware6/Gateway/Api/Reader/EnvironmentReaderTest.php index c3dd5e2f8..0fba0a17e 100644 --- a/tests/Profile/Shopware6/Gateway/Api/Reader/EnvironmentReaderTest.php +++ b/tests/Profile/Shopware6/Gateway/Api/Reader/EnvironmentReaderTest.php @@ -19,6 +19,7 @@ use PHPUnit\Framework\TestCase; use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Exception\MigrationException; +use SwagMigrationAssistant\Migration\Connection\SwagMigrationConnectionEntity; use SwagMigrationAssistant\Migration\Gateway\HttpSimpleClient; use SwagMigrationAssistant\Migration\MigrationContext; use SwagMigrationAssistant\Migration\RequestStatusStruct; @@ -41,7 +42,8 @@ public function testEmptyClientReturnsRequestStatus(): void $environmentReader = new EnvironmentReader($connectionFactory); $migrationContext = new MigrationContext( - new Shopware6MajorProfile('6.6.0') + new SwagMigrationConnectionEntity(), + new Shopware6MajorProfile('6.6.0'), ); $response = $environmentReader->read($migrationContext); @@ -80,7 +82,8 @@ public function testResponseExceptions( $client = new HttpSimpleClient($options); $migrationContext = new MigrationContext( - new Shopware6MajorProfile('6.6.0') + new SwagMigrationConnectionEntity(), + new Shopware6MajorProfile('6.6.0'), ); $connectionFactory = $this->createMock(ConnectionFactoryInterface::class); @@ -219,7 +222,8 @@ public function testGetsEnvironmentInformation(): void $client = new HttpSimpleClient($options); $migrationContext = new MigrationContext( - new Shopware6MajorProfile('6.6.0') + new SwagMigrationConnectionEntity(), + new Shopware6MajorProfile('6.6.0'), ); $connectionFactory = $this->createMock(ConnectionFactoryInterface::class); diff --git a/tests/Profile/Shopware6/Gateway/Api/Shopware6ApiGatewayTest.php b/tests/Profile/Shopware6/Gateway/Api/Shopware6ApiGatewayTest.php index 5c892c32b..4cf0f9cda 100644 --- a/tests/Profile/Shopware6/Gateway/Api/Shopware6ApiGatewayTest.php +++ b/tests/Profile/Shopware6/Gateway/Api/Shopware6ApiGatewayTest.php @@ -354,10 +354,11 @@ protected function createMigrationContext(string $selfShopwareVersion): Migratio ]); return new MigrationContext( - $profile, $connection, - Uuid::randomHex(), + $profile, null, + null, + Uuid::randomHex(), 0, 100 ); diff --git a/tests/Profile/Shopware6/Gateway/Connection/ConnectionFactoryTests.php b/tests/Profile/Shopware6/Gateway/Connection/ConnectionFactoryTests.php index e98825dc1..56b7fbd29 100644 --- a/tests/Profile/Shopware6/Gateway/Connection/ConnectionFactoryTests.php +++ b/tests/Profile/Shopware6/Gateway/Connection/ConnectionFactoryTests.php @@ -29,8 +29,8 @@ public function testCreateApiClient(?array $credentials, bool $expectedToBeNull) } $migrationContext = new MigrationContext( - new Shopware6MajorProfile('6.5.6.1'), $connection, + new Shopware6MajorProfile('6.5.6.1'), ); /** @var StaticEntityRepository $connectionRepository */ diff --git a/tests/Profile/Shopware6/Premapping/UserReaderTest.php b/tests/Profile/Shopware6/Premapping/UserReaderTest.php index c2868ac3c..a53ba569a 100644 --- a/tests/Profile/Shopware6/Premapping/UserReaderTest.php +++ b/tests/Profile/Shopware6/Premapping/UserReaderTest.php @@ -103,8 +103,8 @@ protected function setUp(): void $gatewayRegistryMock->method('getGateway')->willReturn($gatewayMock); $this->migrationContext = new MigrationContext( + $connection, new Shopware6MajorProfile('6.6'), - $connection ); $this->reader = new UserReader($mock, $gatewayRegistryMock); From d077e380e0bfb50eb84391c26bec16e178d0c689 Mon Sep 17 00:00:00 2001 From: Lars Kemper Date: Wed, 27 Aug 2025 15:44:43 +0200 Subject: [PATCH 04/46] fix: phpstan log array types (#47) --- .../Builder/AbstractSwagMigrationLogEntry.php | 16 ++++++++-------- .../Log/Builder/SwagMigrationLogBuilder.php | 16 ++++++++-------- .../Log/Builder/SwagMigrationLogEntry.php | 8 ++++---- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/Migration/Logging/Log/Builder/AbstractSwagMigrationLogEntry.php b/src/Migration/Logging/Log/Builder/AbstractSwagMigrationLogEntry.php index ac1907c20..3d6b430c1 100644 --- a/src/Migration/Logging/Log/Builder/AbstractSwagMigrationLogEntry.php +++ b/src/Migration/Logging/Log/Builder/AbstractSwagMigrationLogEntry.php @@ -18,10 +18,10 @@ final public const LOG_LEVEL_DEBUG = 'debug'; /** - * @param array>|null $sourceData - * @param array>|null $convertedData - * @param array|null $usedMapping - * @param array>|null $exceptionTrace + * @param array|null $sourceData + * @param array|null $convertedData + * @param array|null $usedMapping + * @param array|null $exceptionTrace */ public function __construct( protected string $runId, @@ -69,7 +69,7 @@ public function getFieldSourcePath(): ?string } /** - * @return array>|null + * @return array|null */ public function getSourceData(): ?array { @@ -77,7 +77,7 @@ public function getSourceData(): ?array } /** - * @return array>|null + * @return array|null */ public function getConvertedData(): ?array { @@ -85,7 +85,7 @@ public function getConvertedData(): ?array } /** - * @return array|null + * @return array|null */ public function getUsedMapping(): ?array { @@ -98,7 +98,7 @@ public function getExceptionMessage(): ?string } /** - * @return array>|null + * @return array|null */ public function getExceptionTrace(): ?array { diff --git a/src/Migration/Logging/Log/Builder/SwagMigrationLogBuilder.php b/src/Migration/Logging/Log/Builder/SwagMigrationLogBuilder.php index f0cd7feb8..7083630f2 100644 --- a/src/Migration/Logging/Log/Builder/SwagMigrationLogBuilder.php +++ b/src/Migration/Logging/Log/Builder/SwagMigrationLogBuilder.php @@ -22,10 +22,10 @@ class SwagMigrationLogBuilder { /** - * @param array>|null $sourceData - * @param array>|null $convertedData - * @param array|null $usedMapping - * @param array>|null $exceptionTrace + * @param array|null $sourceData + * @param array|null $convertedData + * @param array|null $usedMapping + * @param array|null $exceptionTrace */ public function __construct( protected string $runId, @@ -73,7 +73,7 @@ public function withFieldSourcePath(string $fieldSourcePath): self } /** - * @param array> $sourceData + * @param array $sourceData */ public function withSourceData(array $sourceData): self { @@ -83,7 +83,7 @@ public function withSourceData(array $sourceData): self } /** - * @param array> $convertedData + * @param array $convertedData */ public function withConvertedData(array $convertedData): self { @@ -93,7 +93,7 @@ public function withConvertedData(array $convertedData): self } /** - * @param array $usedMapping + * @param array $usedMapping */ public function withUsedMapping(array $usedMapping): self { @@ -110,7 +110,7 @@ public function withExceptionMessage(string $exceptionMessage): self } /** - * @param array> $exceptionTrace + * @param array $exceptionTrace */ public function withExceptionTrace(array $exceptionTrace): self { diff --git a/src/Migration/Logging/Log/Builder/SwagMigrationLogEntry.php b/src/Migration/Logging/Log/Builder/SwagMigrationLogEntry.php index 864df72a2..9018af6a9 100644 --- a/src/Migration/Logging/Log/Builder/SwagMigrationLogEntry.php +++ b/src/Migration/Logging/Log/Builder/SwagMigrationLogEntry.php @@ -31,24 +31,24 @@ public function getFieldName(): ?string; public function getFieldSourcePath(): ?string; /** - * @return array>|null + * @return array|null */ public function getSourceData(): ?array; /** - * @return array>|null + * @return array|null */ public function getConvertedData(): ?array; /** - * @return array|null + * @return array|null */ public function getUsedMapping(): ?array; public function getExceptionMessage(): ?string; /** - * @return array>|null + * @return array|null */ public function getExceptionTrace(): ?array; } From 5d495b8094b010d00d7675a56449acff445480c6 Mon Sep 17 00:00:00 2001 From: Jozsef Damokos Date: Wed, 27 Aug 2025 17:02:51 +0300 Subject: [PATCH 05/46] feat: fill logs with meaningful data src/Migration (#46) --- .../Log/Builder/SwagMigrationLogBuilder.php | 12 ++++------ .../Processor/HttpDownloadServiceBase.php | 23 ++++++++++++------- .../Handler/ProcessMediaHandler.php | 11 ++++++--- src/Migration/Run/RunService.php | 10 +++++--- .../Service/MediaFileProcessorService.php | 18 +++++++++------ .../Service/MigrationDataConverter.php | 7 ++++-- .../Service/MigrationDataFetcher.php | 3 ++- src/Migration/Service/MigrationDataWriter.php | 14 ++++++++--- .../Subscriber/MessageQueueSubscriber.php | 4 ++-- .../Process/HttpDownloadServiceBaseTest.php | 3 ++- 10 files changed, 68 insertions(+), 37 deletions(-) diff --git a/src/Migration/Logging/Log/Builder/SwagMigrationLogBuilder.php b/src/Migration/Logging/Log/Builder/SwagMigrationLogBuilder.php index 7083630f2..021913b65 100644 --- a/src/Migration/Logging/Log/Builder/SwagMigrationLogBuilder.php +++ b/src/Migration/Logging/Log/Builder/SwagMigrationLogBuilder.php @@ -128,7 +128,11 @@ public function withExceptionTrace(array $exceptionTrace): self */ public function build(string $logClass): AbstractSwagMigrationLogEntry { - $log = new $logClass( + if (!class_exists($logClass) || !is_subclass_of($logClass, AbstractSwagMigrationLogEntry::class)) { + throw MigrationException::failedToCreateMigrationLog($logClass); + } + + return new $logClass( $this->runId, $this->profileName, $this->gatewayName, @@ -141,11 +145,5 @@ public function build(string $logClass): AbstractSwagMigrationLogEntry $this->exceptionMessage, $this->exceptionTrace, ); - - if ($log instanceof AbstractSwagMigrationLogEntry) { - return $log; - } - - throw MigrationException::failedToCreateMigrationLog($logClass); } } diff --git a/src/Migration/Media/Processor/HttpDownloadServiceBase.php b/src/Migration/Media/Processor/HttpDownloadServiceBase.php index fd6dcd973..92f7fbfe6 100644 --- a/src/Migration/Media/Processor/HttpDownloadServiceBase.php +++ b/src/Migration/Media/Processor/HttpDownloadServiceBase.php @@ -9,12 +9,12 @@ use Doctrine\DBAL\Connection; use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Promise; use GuzzleHttp\Promise\PromiseInterface; use GuzzleHttp\Promise\Utils; use Psr\Http\Message\ResponseInterface; use Shopware\Core\Content\Media\File\FileSaver; use Shopware\Core\Content\Media\File\MediaFile; +use Shopware\Core\Content\Media\MediaDefinition; use Shopware\Core\Content\Media\MediaException; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; @@ -77,10 +77,11 @@ public function process(MigrationContextInterface $migrationContext, Context $co if ($client === null) { $exception = new \Exception('Http download client can not be constructed.'); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) ->withExceptionMessage($exception->getMessage()) ->withExceptionTrace($exception->getTrace()) + ->withEntityName(MediaDefinition::ENTITY_NAME) ->build(ExceptionRunLog::class) ); $this->loggingService->saveLogging($context); @@ -122,8 +123,9 @@ function (MediaProcessWorkloadStruct $work) use ($uuid) { $failureUuids[] = $uuid; $work->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) ->build(CannotGetFileRunLog::class) ); } @@ -141,8 +143,9 @@ function (MediaProcessWorkloadStruct $work) use ($uuid) { $failureUuids[] = $uuid; $work->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) ->build(TemporaryFileErrorLog::class) ); @@ -181,10 +184,11 @@ function (MediaProcessWorkloadStruct $work) use ($uuid) { } catch (\Exception $e) { $failureUuids[] = $uuid; $work->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) ->withExceptionMessage($e->getMessage()) ->withExceptionTrace($e->getTrace()) + ->withEntityName(MediaDefinition::ENTITY_NAME) ->build(ExceptionRunLog::class) ); } finally { @@ -279,10 +283,11 @@ private function doNormalDownloadRequest(MigrationContextInterface $migrationCon $workload->setState(MediaProcessWorkloadStruct::FINISH_STATE); } catch (\Throwable $exception) { // this should never happen because of Promises, but just in case something is wrong with request construction - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) ->withExceptionMessage($exception->getMessage()) ->withExceptionTrace($exception->getTrace()) + ->withEntityName(MediaDefinition::ENTITY_NAME) ->build(ExceptionRunLog::class) ); @@ -302,10 +307,11 @@ private function persistFileToMedia(string $filePath, string $uuid, string $name if ($fileSize === false || $fileSize === 0 || $mimeType === false) { $exception = new \Exception('Downloaded file is empty or could not determine mime type.'); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) ->withExceptionMessage($exception->getMessage()) ->withExceptionTrace($exception->getTrace()) + ->withEntityName(MediaDefinition::ENTITY_NAME) ->build(ExceptionRunLog::class) ); @@ -337,10 +343,11 @@ private function persistFileToMedia(string $filePath, string $uuid, string $name } elseif (\in_array($mediaException->getErrorCode(), [MediaException::MEDIA_ILLEGAL_FILE_NAME, MediaException::MEDIA_EMPTY_FILE_NAME], true)) { $this->fileSaver->persistFileToMedia($mediaFile, Uuid::randomHex(), $uuid, $context); } else { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) ->withExceptionMessage($mediaException->getMessage()) ->withExceptionTrace($mediaException->getTrace()) + ->withEntityName(MediaDefinition::ENTITY_NAME) ->build(ExceptionRunLog::class) ); } diff --git a/src/Migration/MessageQueue/Handler/ProcessMediaHandler.php b/src/Migration/MessageQueue/Handler/ProcessMediaHandler.php index 98e82551d..d6d96533d 100644 --- a/src/Migration/MessageQueue/Handler/ProcessMediaHandler.php +++ b/src/Migration/MessageQueue/Handler/ProcessMediaHandler.php @@ -7,6 +7,7 @@ namespace SwagMigrationAssistant\Migration\MessageQueue\Handler; +use Shopware\Core\Content\Media\MediaDefinition; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; @@ -84,18 +85,22 @@ public function __invoke(ProcessMediaMessage $message): void $processor = $this->mediaFileProcessorRegistry->getProcessor($migrationContext); $workload = $processor->process($migrationContext, $context, $workload); $this->processFailures($context, $migrationContext, $processor, $workload); - } catch (NoConnectionFoundException) { - $this->loggingService->addLogEntry( // TODO: add optional fields + } catch (NoConnectionFoundException $exception) { + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withExceptionMessage($exception->getMessage()) + ->withExceptionTrace($exception->getTrace()) + ->withEntityName(MediaDefinition::ENTITY_NAME) ->build(ProcessorNotFoundLog::class) ); $this->loggingService->saveLogging($context); } catch (\Exception $e) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) ->withExceptionMessage($e->getMessage()) ->withExceptionTrace($e->getTrace()) + ->withEntityName(MediaDefinition::ENTITY_NAME) ->build(ExceptionRunLog::class) ); diff --git a/src/Migration/Run/RunService.php b/src/Migration/Run/RunService.php index e98526fcd..bff24908e 100644 --- a/src/Migration/Run/RunService.php +++ b/src/Migration/Run/RunService.php @@ -254,13 +254,17 @@ public function assignThemeToSalesChannel(string $runUuid, Context $context): vo foreach ($salesChannels as $salesChannel) { try { $this->themeService->assignTheme($defaultTheme, $salesChannel, $context); - } catch (\Throwable) { - $this->loggingService->addLogEntry( // TODO: add optional fields + } catch (\Throwable $exception) { + $this->loggingService->addLogEntry( (new SwagMigrationLogBuilder( $runUuid, $connection->getProfileName(), $connection->getGatewayName(), - ))->build(ThemeCompilingErrorRunLog::class) + )) + ->withExceptionMessage($exception->getMessage()) + ->withExceptionTrace($exception->getTrace()) + ->withEntityName(SalesChannelDefinition::ENTITY_NAME) + ->build(ThemeCompilingErrorRunLog::class) ); } } diff --git a/src/Migration/Service/MediaFileProcessorService.php b/src/Migration/Service/MediaFileProcessorService.php index 21fc5a23a..837c7319b 100644 --- a/src/Migration/Service/MediaFileProcessorService.php +++ b/src/Migration/Service/MediaFileProcessorService.php @@ -45,8 +45,8 @@ public function processMediaFiles(MigrationContextInterface $migrationContext, C if ($currentDataSet === null) { try { $currentDataSet = $this->dataSetRegistry->getDataSet($migrationContext, $mediaFile['entity']); - } catch (DataSetNotFoundException) { - $this->logDataSetNotFoundException($migrationContext); + } catch (DataSetNotFoundException $exception) { + $this->logDataSetNotFoundException($migrationContext, $exception); continue; } @@ -59,8 +59,8 @@ public function processMediaFiles(MigrationContextInterface $migrationContext, C $messageMediaUuids = []; $currentCount = 0; $currentDataSet = $this->dataSetRegistry->getDataSet($migrationContext, $mediaFile['entity']); - } catch (DataSetNotFoundException) { - $this->logDataSetNotFoundException($migrationContext); + } catch (DataSetNotFoundException $exception) { + $this->logDataSetNotFoundException($migrationContext, $exception); continue; } @@ -129,10 +129,14 @@ private function addMessageToBus(string $runUuid, Context $context, DataSet $dat $this->messageBus->dispatch($message); } - private function logDataSetNotFoundException(MigrationContextInterface $migrationContext): void - { - $this->loggingService->addLogEntry( // TODO: add optional fields + private function logDataSetNotFoundException( + MigrationContextInterface $migrationContext, + \Throwable $exception + ): void { + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withExceptionMessage($exception->getMessage()) + ->withExceptionTrace($exception->getTrace()) ->build(DataSetNotFoundLog::class) ); } diff --git a/src/Migration/Service/MigrationDataConverter.php b/src/Migration/Service/MigrationDataConverter.php index 12383cd2b..a436de805 100644 --- a/src/Migration/Service/MigrationDataConverter.php +++ b/src/Migration/Service/MigrationDataConverter.php @@ -68,10 +68,11 @@ public function convert(array $data, MigrationContextInterface $migrationContext $this->mediaFileService->writeMediaFile($context); } } catch (\Throwable $exception) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) ->withExceptionMessage($exception->getMessage()) ->withExceptionTrace($exception->getTrace()) + ->withEntityName($dataSet::getEntity()) ->build(ExceptionRunLog::class) ); @@ -104,10 +105,12 @@ private function convertData( 'convertFailure' => $convertFailureFlag, ]; } catch (\Throwable $exception) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) ->withExceptionMessage($exception->getMessage()) ->withExceptionTrace($exception->getTrace()) + ->withEntityName($dataSet::getEntity()) + ->withSourceData($item) ->build(ExceptionRunLog::class) ); diff --git a/src/Migration/Service/MigrationDataFetcher.php b/src/Migration/Service/MigrationDataFetcher.php index 8cd178e9d..c145525d8 100644 --- a/src/Migration/Service/MigrationDataFetcher.php +++ b/src/Migration/Service/MigrationDataFetcher.php @@ -35,10 +35,11 @@ public function fetchData(MigrationContextInterface $migrationContext, Context $ try { return $this->gatewayRegistry->getGateway($migrationContext)->read($migrationContext); } catch (\Throwable $exception) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) ->withExceptionMessage($exception->getMessage()) ->withExceptionTrace($exception->getTrace()) + ->withEntityName($dataSet::getEntity()) ->build(ExceptionRunLog::class) ); $this->loggingService->saveLogging($context); diff --git a/src/Migration/Service/MigrationDataWriter.php b/src/Migration/Service/MigrationDataWriter.php index a0f003e96..24878e403 100644 --- a/src/Migration/Service/MigrationDataWriter.php +++ b/src/Migration/Service/MigrationDataWriter.php @@ -105,10 +105,12 @@ public function writeData(MigrationContextInterface $migrationContext, Context $ $currentWriter = $this->writerRegistry->getWriter($dataSet::getEntity()); $currentWriter->writeData(\array_values($converted), $this->writeContext); } catch (WriterNotFoundException $writerNotFoundException) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) ->withExceptionMessage($writerNotFoundException->getMessage()) ->withExceptionTrace($writerNotFoundException->getTrace()) + ->withConvertedData([$converted]) + ->withEntityName($dataSet::getEntity()) ->build(ExceptionRunLog::class) ); $this->loggingService->saveLogging($context); @@ -181,8 +183,12 @@ private function handleWriteException( $updateWrittenData[$dataId]['written'] = false; $updateWrittenData[$dataId]['writeFailure'] = true; - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withExceptionMessage($exception->getMessage()) + ->withExceptionTrace($exception->getTrace()) + ->withEntityName($entityName) + ->withConvertedData($entity) ->build(WriteExceptionRunLog::class) ); @@ -234,10 +240,12 @@ private function writePerEntity( $currentWriter = $this->writerRegistry->getWriter($entityName); $currentWriter->writeData([$entity], $this->writeContext); } catch (\Throwable $exception) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) ->withExceptionMessage($exception->getMessage()) ->withExceptionTrace($exception->getTrace()) + ->withEntityName($entityName) + ->withConvertedData([$entity]) ->build(ExceptionRunLog::class) ); diff --git a/src/Migration/Subscriber/MessageQueueSubscriber.php b/src/Migration/Subscriber/MessageQueueSubscriber.php index 7cb8fe09f..78333fabe 100644 --- a/src/Migration/Subscriber/MessageQueueSubscriber.php +++ b/src/Migration/Subscriber/MessageQueueSubscriber.php @@ -89,7 +89,7 @@ public function onWorkerMessageFailed(WorkerMessageFailedEvent $event): void * Raise exception counter and log the exception */ $progress->raiseExceptionCount(); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( (new SwagMigrationLogBuilder( $run->getId(), $connection?->getProfileName() ?? 'unknown', @@ -108,7 +108,7 @@ public function onWorkerMessageFailed(WorkerMessageFailedEvent $event): void $progress->setIsAborted(true); $this->updateRun($run->getId(), $progress, $message->getContext()); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( (new SwagMigrationLogBuilder( $run->getId(), $connection?->getProfileName() ?? 'unknown', diff --git a/tests/Migration/Media/Process/HttpDownloadServiceBaseTest.php b/tests/Migration/Media/Process/HttpDownloadServiceBaseTest.php index 06ed484a0..330892031 100644 --- a/tests/Migration/Media/Process/HttpDownloadServiceBaseTest.php +++ b/tests/Migration/Media/Process/HttpDownloadServiceBaseTest.php @@ -17,6 +17,7 @@ use Psr\Http\Message\StreamInterface; use Shopware\Core\Content\Media\File\FileSaver; use Shopware\Core\Content\Media\File\MediaFile; +use Shopware\Core\Content\Media\MediaDefinition; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\Dbal\QueryBuilder; use Shopware\Core\Framework\Log\Package; @@ -203,7 +204,7 @@ public function testProcessWithRequestFailure(): void 'profileName' => '', 'gatewayName' => '', 'userFixable' => false, - 'entityName' => null, + 'entityName' => MediaDefinition::ENTITY_NAME, 'fieldName' => null, 'fieldSourcePath' => null, 'sourceData' => null, From 4a5b659e0b5aea0d7713466e03c47f688fd3b017 Mon Sep 17 00:00:00 2001 From: Lars Kemper Date: Thu, 28 Aug 2025 09:55:58 +0200 Subject: [PATCH 06/46] feat: add iterative log building helper (#48) --- src/Migration/Logging/LoggingService.php | 15 +++++++++++++++ src/Migration/Logging/LoggingServiceInterface.php | 6 ++++++ .../Service/MediaFileProcessorService.php | 2 +- .../Converter/NewsletterRecipientConverter.php | 9 +++++++-- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/Migration/Logging/LoggingService.php b/src/Migration/Logging/LoggingService.php index 7f522ca5e..69716fbf6 100644 --- a/src/Migration/Logging/LoggingService.php +++ b/src/Migration/Logging/LoggingService.php @@ -71,6 +71,21 @@ public function addLogEntry(SwagMigrationLogEntry $logEntry): void ]; } + /** + * @param array $keys + * @param callable(array-key $key, mixed|null $value): SwagMigrationLogEntry $callback + */ + public function addLogForEach(array $keys, callable $callback): void + { + foreach ($keys as $key => $value) { + if (\array_is_list($keys)) { + $this->addLogEntry($callback($value, null)); + } else { + $this->addLogEntry($callback($key, $value)); + } + } + } + private function writePerEntry(Context $context): void { foreach ($this->logging as $log) { diff --git a/src/Migration/Logging/LoggingServiceInterface.php b/src/Migration/Logging/LoggingServiceInterface.php index f194b567f..34d9a7f23 100644 --- a/src/Migration/Logging/LoggingServiceInterface.php +++ b/src/Migration/Logging/LoggingServiceInterface.php @@ -16,5 +16,11 @@ interface LoggingServiceInterface { public function addLogEntry(SwagMigrationLogEntry $logEntry): void; + /** + * @param array $keys + * @param callable(array-key $key, mixed|null $value): SwagMigrationLogEntry $callback + */ + public function addLogForEach(array $keys, callable $callback): void; + public function saveLogging(Context $context): void; } diff --git a/src/Migration/Service/MediaFileProcessorService.php b/src/Migration/Service/MediaFileProcessorService.php index 837c7319b..ad63fb136 100644 --- a/src/Migration/Service/MediaFileProcessorService.php +++ b/src/Migration/Service/MediaFileProcessorService.php @@ -131,7 +131,7 @@ private function addMessageToBus(string $runUuid, Context $context, DataSet $dat private function logDataSetNotFoundException( MigrationContextInterface $migrationContext, - \Throwable $exception + \Throwable $exception, ): void { $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) diff --git a/src/Profile/Shopware/Converter/NewsletterRecipientConverter.php b/src/Profile/Shopware/Converter/NewsletterRecipientConverter.php index 32fc233fe..aa6641c3d 100644 --- a/src/Profile/Shopware/Converter/NewsletterRecipientConverter.php +++ b/src/Profile/Shopware/Converter/NewsletterRecipientConverter.php @@ -7,6 +7,7 @@ namespace SwagMigrationAssistant\Profile\Shopware\Converter; +use Shopware\Core\Content\Newsletter\Aggregate\NewsletterRecipient\NewsletterRecipientDefinition; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Log\Package; use Shopware\Core\Framework\Uuid\Uuid; @@ -63,13 +64,17 @@ public function convert( $fields = $this->checkForEmptyRequiredDataFields($data, $this->requiredDataFieldKeys); if (!empty($fields)) { - $this->loggingService->addLogEntry( // TODO: add optional fields - SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + $this->loggingService->addLogForEach( + $fields, + fn (string $key) => SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(NewsletterRecipientDefinition::ENTITY_NAME) + ->withFieldName($key) ->build(EmptyNecessaryFieldRunLog::class) ); return new ConvertStruct(null, $data); } + $oldData = $data; $this->generateChecksum($data); $this->context = $context; From b50abbff52373de65238e6ce3f3cd12476988603 Mon Sep 17 00:00:00 2001 From: Lars Kemper Date: Fri, 29 Aug 2025 13:23:28 +0200 Subject: [PATCH 07/46] feat: fill logs with meaningful data (#49) --- .../Shopware/Converter/CategoryConverter.php | 5 +- .../Converter/CrossSellingConverter.php | 15 ++- .../Shopware/Converter/CustomerConverter.php | 102 +++++++++++++++--- .../Shopware/Converter/LanguageConverter.php | 6 +- .../MainVariantRelationConverter.php | 5 +- .../NewsletterRecipientConverter.php | 16 ++- .../Converter/NumberRangeConverter.php | 13 ++- .../Shopware/Converter/OrderConverter.php | 92 +++++++++++++--- .../Converter/OrderDocumentConverter.php | 27 ++++- .../Shopware/Converter/ProductConverter.php | 58 ++++++++-- .../Converter/ProductReviewConverter.php | 30 +++++- .../Shopware/Converter/PromotionConverter.php | 29 ++++- .../PropertyGroupOptionConverter.php | 13 ++- .../Converter/SalesChannelConverter.php | 29 ++++- .../Shopware/Converter/SeoUrlConverter.php | 33 +++++- .../Converter/ShippingMethodConverter.php | 53 ++++++--- .../Converter/TranslationConverter.php | 88 ++++++++++++--- .../Gateway/Api/Reader/TableCountReader.php | 2 +- .../Shopware/Media/LocalMediaProcessor.php | 41 ++++++- .../Media/LocalOrderDocumentProcessor.php | 18 +++- .../Media/LocalProductDownloadProcessor.php | 17 ++- .../Converter/DocumentBaseConfigConverter.php | 8 +- .../Shopware6/Converter/DocumentConverter.php | 8 +- .../Converter/MailTemplateConverter.php | 6 +- .../Converter/MediaFolderConverter.php | 8 +- .../Converter/NumberRangeConverter.php | 7 +- .../Shopware6/Converter/ShopwareConverter.php | 4 +- .../HttpOrderDocumentGenerationService.php | 6 +- .../Services/MigrationDataProcessingTest.php | 2 +- .../Converter/OrderDocumentConverterTest.php | 11 +- .../Converter/CustomerConverterTest.php | 3 +- 31 files changed, 622 insertions(+), 133 deletions(-) diff --git a/src/Profile/Shopware/Converter/CategoryConverter.php b/src/Profile/Shopware/Converter/CategoryConverter.php index 6ce10089c..b1797092b 100644 --- a/src/Profile/Shopware/Converter/CategoryConverter.php +++ b/src/Profile/Shopware/Converter/CategoryConverter.php @@ -85,8 +85,11 @@ public function convert( $this->connectionName = $connection->getName(); if (!isset($data['_locale'])) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(CategoryDefinition::ENTITY_NAME) + ->withFieldSourcePath('_locale') + ->withSourceData($data) ->build(EmptyNecessaryFieldRunLog::class) ); diff --git a/src/Profile/Shopware/Converter/CrossSellingConverter.php b/src/Profile/Shopware/Converter/CrossSellingConverter.php index a66276898..715254e91 100644 --- a/src/Profile/Shopware/Converter/CrossSellingConverter.php +++ b/src/Profile/Shopware/Converter/CrossSellingConverter.php @@ -7,6 +7,7 @@ namespace SwagMigrationAssistant\Profile\Shopware\Converter; +use Shopware\Core\Content\Product\Aggregate\ProductCrossSelling\ProductCrossSellingDefinition; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; @@ -59,8 +60,13 @@ public function convert(array $data, Context $context, MigrationContextInterface $sourceProductMapping = $this->getProductMapping($data['articleID']); if ($sourceProductMapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ProductCrossSellingDefinition::ENTITY_NAME) + ->withFieldName('id') + ->withFieldSourcePath('articleID') + ->withSourceData($data) + ->withConvertedData($converted) ->build(AssociationRequiredMissingLog::class) ); @@ -70,8 +76,13 @@ public function convert(array $data, Context $context, MigrationContextInterface $relatedProductMapping = $this->getProductMapping($data['relatedarticle']); if ($relatedProductMapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ProductCrossSellingDefinition::ENTITY_NAME) + ->withFieldName('id') + ->withFieldSourcePath('relatedarticle') + ->withSourceData($data) + ->withConvertedData($converted) ->build(AssociationRequiredMissingLog::class) ); diff --git a/src/Profile/Shopware/Converter/CustomerConverter.php b/src/Profile/Shopware/Converter/CustomerConverter.php index 4663eac34..88c4bbf91 100644 --- a/src/Profile/Shopware/Converter/CustomerConverter.php +++ b/src/Profile/Shopware/Converter/CustomerConverter.php @@ -7,6 +7,8 @@ namespace SwagMigrationAssistant\Profile\Shopware\Converter; +use Shopware\Core\Checkout\Customer\Aggregate\CustomerAddress\CustomerAddressDefinition; +use Shopware\Core\Checkout\Customer\CustomerDefinition; use Shopware\Core\Defaults; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; @@ -107,8 +109,12 @@ public function convert( $fields = $this->checkForEmptyRequiredDataFields($data, $this->requiredDataFieldKeys); if (!empty($fields)) { - $this->loggingService->addLogEntry( // TODO: add optional fields - SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + $this->loggingService->addLogForEach( + $fields, + fn (string $key) => SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldSourcePath($key) + ->withSourceData($data) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -116,8 +122,12 @@ public function convert( } if (!$this->checkEmailValidity($data['email'])) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldName('email') + ->withFieldSourcePath('email') + ->withSourceData($data) ->build(InvalidEmailAddressLog::class) ); @@ -227,8 +237,13 @@ public function convert( ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldName('defaultPaymentMethodId') + ->withFieldSourcePath('default_payment_method') + ->withSourceData($data) + ->withConvertedData($converted) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -284,11 +299,30 @@ public function convert( $returnData = null; } - if (!isset($converted['defaultBillingAddressId'], $converted['defaultShippingAddressId'])) { + if (!isset($converted['defaultBillingAddressId'])) { $this->mappingService->deleteMapping($converted['id'], $this->connectionId, $this->context); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldName('defaultBillingAddressId') + ->withFieldSourcePath('default_billing_address_id') + ->withSourceData($data) + ->build(EmptyNecessaryFieldRunLog::class) + ); + + return new ConvertStruct(null, $oldData); + } + + if (!isset($converted['defaultShippingAddressId'])) { + $this->mappingService->deleteMapping($converted['id'], $this->connectionId, $this->context); + + $this->loggingService->addLogEntry( + SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldName('defaultShippingAddressId') + ->withFieldSourcePath('default_shipping_address_id') + ->withSourceData($data) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -332,8 +366,12 @@ protected function getDefaultPaymentMethod(array $originalData): ?string ); if ($paymentMethodMapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldName('defaultPaymentMethodId') + ->withFieldSourcePath('default_payment_method') + ->withSourceData($originalData) ->build(UnknownEntityLog::class) ); @@ -357,8 +395,12 @@ protected function applyAddresses(array &$originalData, array &$converted, strin $fields = $this->checkForEmptyRequiredDataFields($address, $this->requiredAddressDataFieldKeys); if (!empty($fields)) { - $this->loggingService->addLogEntry( // TODO: add optional fields - SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + $this->loggingService->addLogForEach( + $fields, + fn (string $key) => SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerAddressDefinition::ENTITY_NAME) + ->withFieldSourcePath($key) + ->withSourceData($address) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -539,8 +581,12 @@ protected function getCountryState(array $oldAddressData, string $newCountryId): $state = ['countryId' => $newCountryId]; if (!isset($oldAddressData['state_id'], $oldAddressData['country']['countryiso'], $oldAddressData['state']['shortcode'])) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerAddressDefinition::ENTITY_NAME) + ->withFieldName('stateId') + ->withFieldSourcePath('state_id') + ->withSourceData($oldAddressData) ->build(UnknownEntityLog::class) ); @@ -572,8 +618,12 @@ protected function getCountryState(array $oldAddressData, string $newCountryId): $oldAddressData['state']['position'], $oldAddressData['state']['active'] )) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerAddressDefinition::ENTITY_NAME) + ->withFieldName('stateId') + ->withFieldSourcePath('state.name') + ->withSourceData($oldAddressData['state']) ->build(UnknownEntityLog::class) ); @@ -643,8 +693,16 @@ protected function checkUnsetDefaultShippingAndDefaultBillingAddress(array &$ori $converted['defaultShippingAddressId'] = $addresses[0]['id']; unset($originalData['default_billing_address_id'], $originalData['default_shipping_address_id']); - $this->loggingService->addLogEntry( // TODO: add optional fields - SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + $this->loggingService->addLogForEach( + [ + 'defaultBillingAddressId' => 'default_billing_address_id', + 'defaultShippingAddressId' => 'default_shipping_address_id', + ], + fn (string $key, string $value) => SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerAddressDefinition::ENTITY_NAME) + ->withFieldName($key) + ->withFieldSourcePath($value) + ->withSourceData($originalData) ->build(FieldReassignedRunLog::class) ); } @@ -660,8 +718,12 @@ protected function checkUnsetDefaultShippingAddress(array &$originalData, array $converted['defaultShippingAddressId'] = $converted['defaultBillingAddressId']; unset($originalData['default_shipping_address_id']); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerAddressDefinition::ENTITY_NAME) + ->withFieldName('defaultShippingAddressId') + ->withFieldSourcePath('default_shipping_address_id') + ->withSourceData($originalData) ->build(FieldReassignedRunLog::class) ); } @@ -677,8 +739,12 @@ protected function checkUnsetDefaultBillingAddress(array &$originalData, array & $converted['defaultBillingAddressId'] = $converted['defaultShippingAddressId']; unset($originalData['default_billing_address_id']); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerAddressDefinition::ENTITY_NAME) + ->withFieldName('defaultBillingAddressId') + ->withFieldSourcePath('default_billing_address_id') + ->withSourceData($originalData) ->build(FieldReassignedRunLog::class) ); } @@ -694,8 +760,12 @@ protected function getSalutation(string $salutation): ?string ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CustomerDefinition::ENTITY_NAME) + ->withFieldName('salutationId') + ->withFieldSourcePath('salutation') + ->withSourceData(['salutation' => $salutation]) ->build(UnknownEntityLog::class) ); diff --git a/src/Profile/Shopware/Converter/LanguageConverter.php b/src/Profile/Shopware/Converter/LanguageConverter.php index 04822064e..954c1b6b7 100644 --- a/src/Profile/Shopware/Converter/LanguageConverter.php +++ b/src/Profile/Shopware/Converter/LanguageConverter.php @@ -9,6 +9,7 @@ use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Log\Package; +use Shopware\Core\System\Language\LanguageDefinition; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; @@ -50,8 +51,11 @@ public function convert(array $data, Context $context, MigrationContextInterface $languageUuid = $this->languageLookup->get($data['locale'], $context); if ($languageUuid !== null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(LanguageDefinition::ENTITY_NAME) + ->withFieldSourcePath('locale') + ->withSourceData($data) ->build(EntityAlreadyExistsRunLog::class) ); diff --git a/src/Profile/Shopware/Converter/MainVariantRelationConverter.php b/src/Profile/Shopware/Converter/MainVariantRelationConverter.php index f76cd714a..c8ad2b43a 100644 --- a/src/Profile/Shopware/Converter/MainVariantRelationConverter.php +++ b/src/Profile/Shopware/Converter/MainVariantRelationConverter.php @@ -109,12 +109,11 @@ public function convert(array $data, Context $context, MigrationContextInterface */ private function addAssociationRequiredLog(MigrationContextInterface $migrationContext, string $field, string $entity, array $data): void { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) ->withEntityName($entity) - ->withFieldName($field) ->withFieldSourcePath($field) - ->withSourceData([$data]) + ->withSourceData($data) ->build(AssociationRequiredMissingLog::class) ); } diff --git a/src/Profile/Shopware/Converter/NewsletterRecipientConverter.php b/src/Profile/Shopware/Converter/NewsletterRecipientConverter.php index aa6641c3d..2c9ba19ac 100644 --- a/src/Profile/Shopware/Converter/NewsletterRecipientConverter.php +++ b/src/Profile/Shopware/Converter/NewsletterRecipientConverter.php @@ -161,8 +161,11 @@ protected function getSalutation(string $salutation, MigrationContextInterface $ ); if ($salutationMapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(NewsletterRecipientDefinition::ENTITY_NAME) + ->withFieldName('salutationId') + ->withSourceData(['salutation' => $salutation]) ->build(UnknownEntityLog::class) ); @@ -188,8 +191,12 @@ protected function getSalesChannel(array $data): ?string } if (!isset($salesChannelMapping)) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(NewsletterRecipientDefinition::ENTITY_NAME) + ->withFieldName('salesChannelId') + ->withFieldSourcePath('shopId') + ->withSourceData($data) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -210,8 +217,11 @@ protected function getStatus(MigrationContextInterface $migrationContext): ?stri ); if ($status === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(NewsletterRecipientDefinition::ENTITY_NAME) + ->withFieldName('status') + ->withSourceData(['status' => NewsletterRecipientStatusReader::SOURCE_ID]) ->build(EmptyNecessaryFieldRunLog::class) ); } diff --git a/src/Profile/Shopware/Converter/NumberRangeConverter.php b/src/Profile/Shopware/Converter/NumberRangeConverter.php index 48e3e4119..93fc5e4a4 100644 --- a/src/Profile/Shopware/Converter/NumberRangeConverter.php +++ b/src/Profile/Shopware/Converter/NumberRangeConverter.php @@ -14,6 +14,7 @@ use Shopware\Core\Framework\Log\Package; use Shopware\Core\Framework\Uuid\Uuid; use Shopware\Core\System\NumberRange\NumberRangeCollection; +use Shopware\Core\System\NumberRange\NumberRangeDefinition; use Shopware\Core\System\NumberRange\NumberRangeEntity; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; @@ -72,8 +73,12 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->connectionId = $connection->getId(); if (!\array_key_exists($data['name'], self::TYPE_MAPPING)) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(NumberRangeDefinition::ENTITY_NAME) + ->withFieldName('typeId') + ->withFieldSourcePath('name') + ->withSourceData($data) ->build(UnsupportedNumberRangeTypeLog::class) ); @@ -85,8 +90,12 @@ public function convert(array $data, Context $context, MigrationContextInterface $converted['typeId'] = $this->getProductNumberRangeTypeUuid($data['name']); if (empty($converted['typeId'])) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(NumberRangeDefinition::ENTITY_NAME) + ->withFieldName('typeId') + ->withFieldSourcePath('name') + ->withSourceData($data) ->build(EmptyNecessaryFieldRunLog::class) ); diff --git a/src/Profile/Shopware/Converter/OrderConverter.php b/src/Profile/Shopware/Converter/OrderConverter.php index 3a852bcad..9f961cd25 100644 --- a/src/Profile/Shopware/Converter/OrderConverter.php +++ b/src/Profile/Shopware/Converter/OrderConverter.php @@ -17,6 +17,11 @@ use Shopware\Core\Checkout\Cart\Tax\Struct\TaxRule; use Shopware\Core\Checkout\Cart\Tax\Struct\TaxRuleCollection; use Shopware\Core\Checkout\Cart\Tax\TaxCalculator; +use Shopware\Core\Checkout\Order\Aggregate\OrderAddress\OrderAddressDefinition; +use Shopware\Core\Checkout\Order\Aggregate\OrderDelivery\OrderDeliveryDefinition; +use Shopware\Core\Checkout\Order\Aggregate\OrderLineItem\OrderLineItemDefinition; +use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionDefinition; +use Shopware\Core\Checkout\Order\OrderDefinition; use Shopware\Core\Defaults; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; @@ -132,8 +137,12 @@ public function convert( } if (!empty($fields)) { - $this->loggingService->addLogEntry( // TODO: add optional fields - SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + $this->loggingService->addLogForEach( + $fields, + fn (string $key) => SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(OrderDefinition::ENTITY_NAME) + ->withFieldSourcePath($key) + ->withSourceData($data) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -211,8 +220,13 @@ public function convert( $currencyUuid = $this->currencyLookup->get($data['currency'], $context); } if ($currencyUuid === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(OrderDefinition::ENTITY_NAME) + ->withFieldName('currencyId') + ->withFieldSourcePath('currency') + ->withSourceData($data) + ->withConvertedData($converted) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -238,8 +252,13 @@ public function convert( ); if ($stateMapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(OrderDefinition::ENTITY_NAME) + ->withFieldName('stateId') + ->withFieldSourcePath('status') + ->withSourceData($data) + ->withConvertedData($converted) ->build(UnknownEntityLog::class) ); @@ -313,8 +332,13 @@ public function convert( $billingAddress = $this->getAddress($data['billingaddress']); if (empty($billingAddress)) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(OrderDefinition::ENTITY_NAME) + ->withFieldName('billingAddressId') + ->withFieldSourcePath('billingaddress') + ->withSourceData($data) + ->withConvertedData($converted) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -417,8 +441,13 @@ protected function applyTransactions(array $data, array &$converted): void ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderTransactionDefinition::ENTITY_NAME) + ->withFieldName('stateId') + ->withFieldSourcePath('cleared') + ->withSourceData($data) + ->withConvertedData($converted) ->build(UnknownEntityLog::class) ); @@ -472,8 +501,12 @@ protected function getPaymentMethod(array $originalData): ?string ); if ($paymentMethodMapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderTransactionDefinition::ENTITY_NAME) + ->withFieldName('paymentMethodId') + ->withFieldSourcePath('payment.id') + ->withSourceData($originalData) ->build(UnknownEntityLog::class) ); @@ -495,8 +528,12 @@ protected function getAddress(array $originalData, string $type = self::BILLING_ $fields = $this->checkForEmptyRequiredDataFields($originalData, $this->requiredAddressDataFieldKeys); if (!empty($fields)) { - $this->loggingService->addLogEntry( // TODO: add optional fields - SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + $this->loggingService->addLogForEach( + $fields, + fn (string $key) => SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderDefinition::ENTITY_NAME) + ->withFieldSourcePath($key) + ->withSourceData($originalData) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -638,8 +675,12 @@ protected function getCountryState(array $oldAddressData, string $newCountryId): $state = ['countryId' => $newCountryId]; if (!isset($oldAddressData['stateID'], $oldAddressData['country']['countryiso'], $oldAddressData['state']['shortcode'])) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderAddressDefinition::ENTITY_NAME) + ->withFieldName('countryStateId') + ->withFieldSourcePath('stateID') + ->withSourceData($oldAddressData) ->build(UnknownEntityLog::class) ); @@ -671,8 +712,12 @@ protected function getCountryState(array $oldAddressData, string $newCountryId): $oldAddressData['state']['position'], $oldAddressData['state']['active'] )) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderAddressDefinition::ENTITY_NAME) + ->withFieldName('countryStateId') + ->withFieldSourcePath('name') + ->withSourceData($oldAddressData['state']) ->build(UnknownEntityLog::class) ); @@ -747,8 +792,13 @@ protected function getDeliveries(array $data, array $converted, CalculatedPrice ); if ($deliveryStateMapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderDeliveryDefinition::ENTITY_NAME) + ->withFieldName('stateId') + ->withFieldSourcePath('status') + ->withSourceData($data) + ->withConvertedData($converted) ->build(UnknownEntityLog::class) ); @@ -827,8 +877,12 @@ protected function getShippingMethod(string $shippingMethodId): ?string ); if ($shippingMethodMapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderDeliveryDefinition::ENTITY_NAME) + ->withFieldName('shippingMethodId') + ->withFieldSourcePath('dispatchID') + ->withSourceData(['dispatchID' => $shippingMethodId]) ->build(UnknownEntityLog::class) ); @@ -991,8 +1045,12 @@ protected function getSalutation(string $salutation): ?string ); if ($salutationMapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderAddressDefinition::ENTITY_NAME) + ->withFieldName('salutationId') + ->withFieldSourcePath('salutation') + ->withSourceData(['salutation' => $salutation]) ->build(UnknownEntityLog::class) ); @@ -1019,8 +1077,12 @@ private function getOrderLineItemDownload(array $originalEsdItem): ?array ); if (!\is_array($mediaMapping)) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(OrderLineItemDefinition::ENTITY_NAME) + ->withFieldName('coverId') + ->withFieldSourcePath('esd.esdID') + ->withSourceData($originalEsdItem) ->build(UnknownEntityLog::class) ); diff --git a/src/Profile/Shopware/Converter/OrderDocumentConverter.php b/src/Profile/Shopware/Converter/OrderDocumentConverter.php index 7f1cdc686..810957ce5 100644 --- a/src/Profile/Shopware/Converter/OrderDocumentConverter.php +++ b/src/Profile/Shopware/Converter/OrderDocumentConverter.php @@ -80,8 +80,12 @@ public function convert(array $data, Context $context, MigrationContextInterface $converted = []; if (empty($data['hash'])) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(DocumentDefinition::ENTITY_NAME) + ->withFieldSourcePath('hash') + ->withSourceData($data) + ->withConvertedData($converted) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -89,8 +93,13 @@ public function convert(array $data, Context $context, MigrationContextInterface } if (!isset($data['documenttype'])) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(DocumentDefinition::ENTITY_NAME) + ->withFieldName('documentType') + ->withFieldSourcePath('documenttype') + ->withSourceData($data) + ->withConvertedData($converted) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -105,8 +114,13 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($orderMapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(DocumentDefinition::ENTITY_NAME) + ->withFieldName('orderId') + ->withFieldSourcePath('orderID') + ->withSourceData($data) + ->withConvertedData($converted) ->build(AssociationRequiredMissingLog::class) ); @@ -187,8 +201,13 @@ protected function getDocumentType(array $data): array return $documentType; } - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(DocumentDefinition::ENTITY_NAME) + ->withFieldName('documentType') + ->withFieldSourcePath('key') + ->withSourceData($data) + ->withConvertedData($documentType) ->build(DocumentTypeNotSupportedLog::class) ); diff --git a/src/Profile/Shopware/Converter/ProductConverter.php b/src/Profile/Shopware/Converter/ProductConverter.php index f361f85e2..208af37d5 100644 --- a/src/Profile/Shopware/Converter/ProductConverter.php +++ b/src/Profile/Shopware/Converter/ProductConverter.php @@ -7,8 +7,12 @@ namespace SwagMigrationAssistant\Profile\Shopware\Converter; +use Shopware\Core\Content\Media\MediaDefinition; use Shopware\Core\Content\Product\Aggregate\ProductDownload\ProductDownloadDefinition; +use Shopware\Core\Content\Product\Aggregate\ProductMedia\ProductMediaDefinition; +use Shopware\Core\Content\Product\Aggregate\ProductPrice\ProductPriceDefinition; use Shopware\Core\Content\Product\Aggregate\ProductVisibility\ProductVisibilityDefinition; +use Shopware\Core\Content\Product\ProductDefinition; use Shopware\Core\Defaults; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Log\Package; @@ -143,8 +147,12 @@ public function convert( $fields = $this->checkForEmptyRequiredDataFields($data, $this->requiredDataFieldKeys); if (!empty($fields)) { - $this->loggingService->addLogEntry( // TODO: add optional fields - SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + $this->loggingService->addLogForEach( + $fields, + fn (string $key) => SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ProductDefinition::ENTITY_NAME) + ->withFieldSourcePath($key) + ->withSourceData($data) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -382,8 +390,13 @@ private function getProductData(array &$data, array $converted): array $converted['price'] = $this->getPrice($data['prices'][0], $converted['tax']['taxRate']); if (empty($converted['price'])) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(ProductDefinition::ENTITY_NAME) + ->withFieldName('price') + ->withFieldSourcePath('prices') + ->withSourceData($data) + ->withConvertedData($converted) ->build(EmptyNecessaryFieldRunLog::class) ); } @@ -886,8 +899,13 @@ private function getEsdFiles(array $esdFiles, string $oldVariantId, array $conve $this->mappingIds[] = $mapping['id']; if (empty($esdFile['name'])) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) + ->withFieldName('name') + ->withFieldSourcePath('name') + ->withSourceData($esdFile) + ->withConvertedData($newMedia) ->build(CannotConvertChildEntityLog::class) ); @@ -896,9 +914,15 @@ private function getEsdFiles(array $esdFiles, string $oldVariantId, array $conve try { $path = \unserialize($esdFile['path'], ['allowed_classes' => false]); - } catch (\Throwable) { - $this->loggingService->addLogEntry( // TODO: add optional fields + } catch (\Throwable $e) { + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) + ->withFieldName('path') + ->withFieldSourcePath('path') + ->withSourceData($esdFile) + ->withExceptionMessage($e->getMessage()) + ->withExceptionTrace($e->getTrace()) ->build(CannotConvertChildEntityLog::class) ); @@ -928,8 +952,15 @@ private function getEsdFiles(array $esdFiles, string $oldVariantId, array $conve $albumId = $this->mediaFolderLookup->get(ProductDownloadDefinition::ENTITY_NAME, $this->context); if ($albumId === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) + ->withFieldName('mediaFolderId') + ->withSourceData([ + 'file_name' => $fileName, + 'source_data' => $sourceData, + 'media_folder' => ProductDownloadDefinition::ENTITY_NAME, + ]) ->build(CannotConvertChildEntityLog::class) ); @@ -960,8 +991,12 @@ private function getMedia(array $media, string $oldVariantId, array $converted): $mediaObjects = []; foreach ($media as $mediaData) { if (!isset($mediaData['media']['id'])) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(ProductMediaDefinition::ENTITY_NAME) + ->withFieldName('mediaId') + ->withFieldSourcePath('media.id') + ->withSourceData($mediaData) ->build(CannotConvertChildEntityLog::class) ); @@ -1348,8 +1383,13 @@ private function getPrices(array $priceData, array $converted): array $priceArray = $this->getPrice($price, $converted['tax']['taxRate']); if (empty($priceArray)) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(ProductPriceDefinition::ENTITY_NAME) + ->withFieldName('price') + ->withFieldSourcePath('price') + ->withSourceData($price) + ->withConvertedData($converted) ->build(EmptyNecessaryFieldRunLog::class) ); diff --git a/src/Profile/Shopware/Converter/ProductReviewConverter.php b/src/Profile/Shopware/Converter/ProductReviewConverter.php index 34f3afa33..3941b71ba 100644 --- a/src/Profile/Shopware/Converter/ProductReviewConverter.php +++ b/src/Profile/Shopware/Converter/ProductReviewConverter.php @@ -7,6 +7,7 @@ namespace SwagMigrationAssistant\Profile\Shopware\Converter; +use Shopware\Core\Content\Product\Aggregate\ProductReview\ProductReviewDefinition; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; @@ -46,8 +47,12 @@ public function convert(array $data, Context $context, MigrationContextInterface $connectionId = $connection->getId(); if (!empty($fields)) { - $this->loggingService->addLogEntry( // TODO: add optional fields - SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + $this->loggingService->addLogForEach( + $fields, + fn (string $key) => SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ProductReviewDefinition::ENTITY_NAME) + ->withFieldSourcePath($key) + ->withSourceData($data) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -85,8 +90,13 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ProductReviewDefinition::ENTITY_NAME) + ->withFieldName('productId') + ->withFieldSourcePath('articleID') + ->withSourceData($data) + ->withConvertedData($converted) ->build(AssociationRequiredMissingLog::class) ); @@ -122,8 +132,13 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ProductReviewDefinition::ENTITY_NAME) + ->withFieldName('salesChannelId') + ->withFieldSourcePath('shop_id') + ->withSourceData($data) + ->withConvertedData($converted) ->build(AssociationRequiredMissingLog::class) ); @@ -135,8 +150,13 @@ public function convert(array $data, Context $context, MigrationContextInterface $converted['languageId'] = $this->languageLookup->get($mainLocale, $context); if ($converted['languageId'] === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ProductReviewDefinition::ENTITY_NAME) + ->withFieldName('languageId') + ->withFieldSourcePath('_locale') + ->withSourceData($data) + ->withConvertedData($converted) ->build(AssociationRequiredMissingLog::class) ); diff --git a/src/Profile/Shopware/Converter/PromotionConverter.php b/src/Profile/Shopware/Converter/PromotionConverter.php index 6e68c4b33..5681ec178 100644 --- a/src/Profile/Shopware/Converter/PromotionConverter.php +++ b/src/Profile/Shopware/Converter/PromotionConverter.php @@ -7,7 +7,10 @@ namespace SwagMigrationAssistant\Profile\Shopware\Converter; +use Shopware\Core\Checkout\Promotion\Aggregate\PromotionCartRule\PromotionCartRuleDefinition; use Shopware\Core\Checkout\Promotion\Aggregate\PromotionDiscount\PromotionDiscountEntity; +use Shopware\Core\Checkout\Promotion\Aggregate\PromotionPersonaRule\PromotionPersonaRuleDefinition; +use Shopware\Core\Checkout\Promotion\PromotionDefinition; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; @@ -364,8 +367,12 @@ private function setProductNumbers(array &$data, MigrationContextInterface $migr ); if ($productMapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(PromotionDefinition::ENTITY_NAME) + ->withFieldName('productId') + ->withFieldSourcePath('restrictarticles') + ->withSourceData($data) ->build(AssociationRequiredMissingLog::class) ); @@ -495,8 +502,12 @@ private function setCartRule(array &$data, array &$converted, MigrationContextIn unset($data['bindtosupplier']); $oneRuleAdded = true; } else { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(PromotionCartRuleDefinition::ENTITY_NAME) + ->withFieldName('rule.value.manufacturerId') + ->withFieldSourcePath('bindtosupplier') + ->withSourceData($data) ->build(AssociationRequiredMissingLog::class) ); } @@ -546,8 +557,13 @@ private function setSalesChannel(array &$data, array &$converted, MigrationConte ); if ($salesChannelMapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(PromotionDefinition::ENTITY_NAME) + ->withFieldName('salesChannelId') + ->withFieldSourcePath('subshopID') + ->withSourceData($data) + ->withConvertedData($converted) ->build(AssociationRequiredMissingLog::class) ); @@ -614,8 +630,13 @@ private function setCustomerRule(array &$data, array &$converted, MigrationConte ); if ($customerGroupMapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(PromotionPersonaRuleDefinition::ENTITY_NAME) + ->withFieldName('rule.value.customerGroupId') + ->withFieldSourcePath('customergroup') + ->withSourceData($data) + ->withConvertedData($converted) ->build(AssociationRequiredMissingLog::class) ); diff --git a/src/Profile/Shopware/Converter/PropertyGroupOptionConverter.php b/src/Profile/Shopware/Converter/PropertyGroupOptionConverter.php index f1f121031..5537e503e 100644 --- a/src/Profile/Shopware/Converter/PropertyGroupOptionConverter.php +++ b/src/Profile/Shopware/Converter/PropertyGroupOptionConverter.php @@ -7,6 +7,7 @@ namespace SwagMigrationAssistant\Profile\Shopware\Converter; +use Shopware\Core\Content\Property\PropertyGroupDefinition; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; @@ -76,8 +77,12 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->connectionId = $connection->getId(); if (!isset($data['group']['name'])) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(PropertyGroupDefinition::ENTITY_NAME) + ->withFieldName('id') + ->withFieldSourcePath('group.name') + ->withSourceData($data) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -128,8 +133,12 @@ public function convert(array $data, Context $context, MigrationContextInterface protected function setMedia(array &$converted, array $data): void { if (!isset($data['media']['id'])) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(PropertyGroupDefinition::ENTITY_NAME) + ->withFieldName('media.id') + ->withFieldSourcePath('media.id') + ->withSourceData($data) ->build(CannotConvertChildEntityLog::class) ); diff --git a/src/Profile/Shopware/Converter/SalesChannelConverter.php b/src/Profile/Shopware/Converter/SalesChannelConverter.php index 1e911f66e..634269d8f 100644 --- a/src/Profile/Shopware/Converter/SalesChannelConverter.php +++ b/src/Profile/Shopware/Converter/SalesChannelConverter.php @@ -20,6 +20,7 @@ use Shopware\Core\Framework\Log\Package; use Shopware\Core\System\Country\CountryCollection; use Shopware\Core\System\SalesChannel\SalesChannelCollection; +use Shopware\Core\System\SalesChannel\SalesChannelDefinition; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; use SwagMigrationAssistant\Migration\Logging\Log\AssociationRequiredMissingLog; @@ -96,8 +97,12 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($customerGroupMapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(SalesChannelDefinition::ENTITY_NAME) + ->withFieldName('customerGroupId') + ->withFieldSourcePath('customer_group_id') + ->withSourceData($data) ->build(AssociationRequiredMissingLog::class) ); @@ -109,8 +114,12 @@ public function convert(array $data, Context $context, MigrationContextInterface $languageUuid = $this->languageLookup->get($data['locale'], $context); if ($languageUuid === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(SalesChannelDefinition::ENTITY_NAME) + ->withFieldName('languageId') + ->withFieldSourcePath('locale') + ->withSourceData($data) ->build(AssociationRequiredMissingLog::class) ); @@ -129,8 +138,12 @@ public function convert(array $data, Context $context, MigrationContextInterface $currencyUuid = $this->currencyLookup->get($data['currency'], $context); if ($currencyUuid === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(SalesChannelDefinition::ENTITY_NAME) + ->withFieldName('currencyId') + ->withFieldSourcePath('currency') + ->withSourceData($data) ->build(AssociationRequiredMissingLog::class) ); @@ -152,8 +165,12 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($categoryMapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(SalesChannelDefinition::ENTITY_NAME) + ->withFieldName('navigationCategoryId') + ->withFieldSourcePath('category_id') + ->withSourceData($data) ->build(AssociationRequiredMissingLog::class) ); @@ -372,8 +389,10 @@ protected function filterDisabledPackLanguages(array &$converted): void $converted['languageId'] = Defaults::LANGUAGE_SYSTEM; } - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(SalesChannelDefinition::ENTITY_NAME) + ->withFieldName('languageId') ->build(DeactivatedPackLanguageLog::class) ); } diff --git a/src/Profile/Shopware/Converter/SeoUrlConverter.php b/src/Profile/Shopware/Converter/SeoUrlConverter.php index 565a5c662..88c887ecf 100644 --- a/src/Profile/Shopware/Converter/SeoUrlConverter.php +++ b/src/Profile/Shopware/Converter/SeoUrlConverter.php @@ -7,6 +7,7 @@ namespace SwagMigrationAssistant\Profile\Shopware\Converter; +use Shopware\Core\Content\Seo\SeoUrl\SeoUrlDefinition; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; @@ -65,8 +66,13 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(SeoUrlDefinition::ENTITY_NAME) + ->withFieldName('salesChannelId') + ->withFieldSourcePath('subshopID') + ->withSourceData($data) + ->withConvertedData($converted) ->build(AssociationRequiredMissingLog::class) ); @@ -78,8 +84,13 @@ public function convert(array $data, Context $context, MigrationContextInterface $converted['languageId'] = $this->languageLookup->get($data['_locale'], $context); if ($converted['languageId'] === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(SeoUrlDefinition::ENTITY_NAME) + ->withFieldName('languageId') + ->withFieldSourcePath('_locale') + ->withSourceData($data) + ->withConvertedData($converted) ->build(AssociationRequiredMissingLog::class) ); @@ -105,8 +116,12 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(SeoUrlDefinition::ENTITY_NAME) + ->withFieldName('foreignKey') + ->withFieldSourcePath('type') + ->withSourceData($data) ->build(AssociationRequiredMissingLog::class) ); @@ -127,8 +142,12 @@ public function convert(array $data, Context $context, MigrationContextInterface ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(SeoUrlDefinition::ENTITY_NAME) + ->withFieldName('foreignKey') + ->withFieldSourcePath('type') + ->withSourceData($data) ->build(AssociationRequiredMissingLog::class) ); @@ -139,8 +158,12 @@ public function convert(array $data, Context $context, MigrationContextInterface $converted['pathInfo'] = '/navigation/' . $mapping['entityUuid']; $this->mappingIds[] = $mapping['id']; } else { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(SeoUrlDefinition::ENTITY_NAME) + ->withFieldName('foreignKey') + ->withFieldSourcePath('type') + ->withSourceData($data) ->build(UnsupportedSeoUrlTypeLog::class) ); diff --git a/src/Profile/Shopware/Converter/ShippingMethodConverter.php b/src/Profile/Shopware/Converter/ShippingMethodConverter.php index 0c71b8c60..3c0ed66d1 100644 --- a/src/Profile/Shopware/Converter/ShippingMethodConverter.php +++ b/src/Profile/Shopware/Converter/ShippingMethodConverter.php @@ -7,6 +7,8 @@ namespace SwagMigrationAssistant\Profile\Shopware\Converter; +use Shopware\Core\Checkout\Shipping\Aggregate\ShippingMethodPrice\ShippingMethodPriceDefinition; +use Shopware\Core\Checkout\Shipping\ShippingMethodDefinition; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Log\Package; use Shopware\Core\Framework\Rule\Container\AndRule; @@ -93,8 +95,12 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->connectionId = $connection->getId(); if (empty($data['id'])) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ShippingMethodDefinition::ENTITY_NAME) + ->withFieldName('id') + ->withFieldSourcePath('id') + ->withSourceData($data) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -143,12 +149,14 @@ public function convert(array $data, Context $context, MigrationContextInterface $fields = $this->checkForEmptyRequiredConvertedFields($converted, $this->requiredDataFields); if (!empty($fields)) { - foreach ($fields as $field) { - $this->loggingService->addLogEntry( // TODO: add optional fields - SwagMigrationLogBuilder::fromMigrationContext($migrationContext) - ->build(EmptyNecessaryFieldRunLog::class) - ); - } + $this->loggingService->addLogForEach( + $fields, + fn (string $key) => SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withFieldName(ShippingMethodDefinition::ENTITY_NAME) + ->withFieldSourcePath($key) + ->withSourceData($data) + ->build(EmptyNecessaryFieldRunLog::class) + ); return new ConvertStruct(null, $data); } @@ -178,8 +186,13 @@ public function convert(array $data, Context $context, MigrationContextInterface if (!isset($data['calculation']) || !\array_key_exists($data['calculation'], self::CALCULATION_TYPE_MAPPING) ) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ShippingMethodDefinition::ENTITY_NAME) + ->withFieldName('prices') + ->withFieldSourcePath('calculation') + ->withSourceData($data) + ->withConvertedData($converted) ->build(UnsupportedShippingCalculationTypeLog::class) ); } else { @@ -233,8 +246,12 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->updateMainMapping($migrationContext, $context); if (!\is_array($this->mainMapping) || !\array_key_exists('id', $this->mainMapping)) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ShippingMethodDefinition::ENTITY_NAME) + ->withFieldName('id') + ->withSourceData($data) + ->withConvertedData($converted) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -634,8 +651,12 @@ protected function getShippingCosts(MigrationContextInterface $migrationContext, $convertedCosts = []; foreach ($shippingCosts as $key => $shippingCost) { if (empty($shippingCost['id'])) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ShippingMethodPriceDefinition::ENTITY_NAME) + ->withFieldName('id') + ->withFieldSourcePath('id') + ->withSourceData($data) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -667,8 +688,12 @@ protected function getShippingCosts(MigrationContextInterface $migrationContext, } if (!isset($currencyMapping)) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ShippingMethodPriceDefinition::ENTITY_NAME) + ->withFieldName('currencyId') + ->withFieldSourcePath('currencyShortName') + ->withSourceData($data) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -682,8 +707,12 @@ protected function getShippingCosts(MigrationContextInterface $migrationContext, } if (isset($shippingCost['factor']) && $shippingCost['factor'] > 0) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(ShippingMethodPriceDefinition::ENTITY_NAME) + ->withFieldSourcePath('factor') + ->withSourceData($shippingCost) + ->withConvertedData($cost) ->build(UnsupportedShippingPriceLog::class) ); diff --git a/src/Profile/Shopware/Converter/TranslationConverter.php b/src/Profile/Shopware/Converter/TranslationConverter.php index abe5d81e6..7a9da3d1c 100644 --- a/src/Profile/Shopware/Converter/TranslationConverter.php +++ b/src/Profile/Shopware/Converter/TranslationConverter.php @@ -7,14 +7,21 @@ namespace SwagMigrationAssistant\Profile\Shopware\Converter; +use Shopware\Core\Content\Category\Aggregate\CategoryTranslation\CategoryTranslationDefinition; use Shopware\Core\Content\Category\CategoryDefinition; +use Shopware\Core\Content\Media\Aggregate\MediaTranslation\MediaTranslationDefinition; use Shopware\Core\Content\Media\MediaDefinition; use Shopware\Core\Content\Product\Aggregate\ProductManufacturer\ProductManufacturerDefinition; +use Shopware\Core\Content\Product\Aggregate\ProductManufacturerTranslation\ProductManufacturerTranslationDefinition; +use Shopware\Core\Content\Product\Aggregate\ProductTranslation\ProductTranslationDefinition; use Shopware\Core\Content\Product\ProductDefinition; use Shopware\Core\Content\Property\Aggregate\PropertyGroupOption\PropertyGroupOptionDefinition; +use Shopware\Core\Content\Property\Aggregate\PropertyGroupOptionTranslation\PropertyGroupOptionTranslationDefinition; +use Shopware\Core\Content\Property\Aggregate\PropertyGroupTranslation\PropertyGroupTranslationDefinition; use Shopware\Core\Content\Property\PropertyGroupDefinition; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\Log\Package; +use Shopware\Core\System\Unit\Aggregate\UnitTranslation\UnitTranslationDefinition; use Shopware\Core\System\Unit\UnitDefinition; use SwagMigrationAssistant\Migration\Connection\Helper\ConnectionNameSanitizer; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; @@ -60,8 +67,12 @@ public function convert( $this->connectionId = $connection->getId(); if (!isset($data['locale'])) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName('unknown_translation') + ->withFieldName('languageId') + ->withFieldSourcePath('locale') + ->withSourceData($data) ->build(EmptyNecessaryFieldRunLog::class) ); @@ -92,8 +103,11 @@ public function convert( return $this->createProductMediaTranslation($data); } - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName('unknown_translation') + ->withFieldSourcePath('objecttype') + ->withSourceData($data) ->build(UnsupportedTranslationTypeLog::class) ); @@ -124,8 +138,12 @@ protected function createProductTranslation(array &$data): ConvertStruct } if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(ProductTranslationDefinition::ENTITY_NAME) + ->withFieldName('productId') + ->withFieldSourcePath('objectkey') + ->withSourceData($sourceData) ->build(AssociationRequiredMissingLog::class) ); @@ -231,8 +249,12 @@ protected function createProductVariantTranslation(array &$data): ConvertStruct unset($data['ordernumber']); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(ProductTranslationDefinition::ENTITY_NAME) + ->withFieldName('productId') + ->withFieldSourcePath('ordernumber') + ->withSourceData($sourceData) ->build(AssociationRequiredMissingLog::class) ); @@ -303,8 +325,12 @@ protected function createManufacturerProductTranslation(array $data): ConvertStr ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(ProductManufacturerTranslationDefinition::ENTITY_NAME) + ->withFieldName('productManufacturerId') + ->withFieldSourcePath('objectkey') + ->withSourceData($sourceData) ->build(AssociationRequiredMissingLog::class) ); @@ -381,8 +407,12 @@ protected function createUnitTranslation(array $data): ConvertStruct ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(UnitTranslationDefinition::ENTITY_NAME) + ->withFieldName('unitId') + ->withFieldSourcePath('objectkey') + ->withSourceData($sourceData) ->build(AssociationRequiredMissingLog::class) ); @@ -464,8 +494,12 @@ protected function createCategoryTranslation(array $data): ConvertStruct ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(CategoryTranslationDefinition::ENTITY_NAME) + ->withFieldName('categoryId') + ->withFieldSourcePath('objectkey') + ->withSourceData($sourceData) ->build(AssociationRequiredMissingLog::class) ); @@ -557,8 +591,12 @@ protected function createConfiguratorOptionTranslation(array $data): ConvertStru ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(PropertyGroupOptionTranslationDefinition::ENTITY_NAME) + ->withFieldName('propertyGroupOptionId') + ->withFieldSourcePath('objectkey') + ->withSourceData($sourceData) ->build(AssociationRequiredMissingLog::class) ); @@ -632,8 +670,12 @@ protected function createConfiguratorOptionGroupTranslation(array $data): Conver ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(PropertyGroupTranslationDefinition::ENTITY_NAME) + ->withFieldName('propertyGroupId') + ->withFieldSourcePath('objectkey') + ->withSourceData($sourceData) ->build(AssociationRequiredMissingLog::class) ); @@ -710,8 +752,12 @@ protected function createPropertyValueTranslation(array $data): ConvertStruct ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(PropertyGroupOptionTranslationDefinition::ENTITY_NAME) + ->withFieldName('propertyGroupOptionId') + ->withFieldSourcePath('objectkey') + ->withSourceData($sourceData) ->build(AssociationRequiredMissingLog::class) ); @@ -783,8 +829,12 @@ protected function createPropertyOptionTranslation(array $data): ConvertStruct ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(PropertyGroupTranslationDefinition::ENTITY_NAME) + ->withFieldName('propertyGroupId') + ->withFieldSourcePath('objectkey') + ->withSourceData($sourceData) ->build(AssociationRequiredMissingLog::class) ); @@ -902,17 +952,23 @@ protected function addAttribute(string $entityName, string $key, string $value, protected function unserializeTranslation(array $data, string $entity): ?array { $objectDataSerialized = $data['objectdata']; + $exception = null; try { $objectData = \unserialize($objectDataSerialized, ['allowed_classes' => false]); - } catch (\Throwable) { + } catch (\Throwable $e) { $objectData = null; + $exception = $e; } if (!\is_array($objectData)) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) ->withEntityName($entity) + ->withFieldSourcePath('objectdata') + ->withSourceData($data) + ->withExceptionMessage($exception?->getMessage() ?? 'Unserialization failed') + ->withExceptionTrace($exception?->getTrace() ?? []) ->build(InvalidUnserializedDataLog::class) ); @@ -941,8 +997,12 @@ protected function createProductMediaTranslation(array $data): ConvertStruct ); if ($mapping === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(MediaTranslationDefinition::ENTITY_NAME) + ->withFieldName('mediaId') + ->withFieldSourcePath('mediaId') + ->withSourceData($sourceData) ->build(AssociationRequiredMissingLog::class) ); diff --git a/src/Profile/Shopware/Gateway/Api/Reader/TableCountReader.php b/src/Profile/Shopware/Gateway/Api/Reader/TableCountReader.php index 92807550d..169ccf6cd 100644 --- a/src/Profile/Shopware/Gateway/Api/Reader/TableCountReader.php +++ b/src/Profile/Shopware/Gateway/Api/Reader/TableCountReader.php @@ -69,7 +69,7 @@ private function prepareTotals(array $result): array private function logExceptions(array $exceptionArray, MigrationContextInterface $migrationContext, Context $context): void { foreach ($exceptionArray as $exception) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) ->withExceptionMessage($exception['message']) ->build(CannotReadEntityCountLog::class) diff --git a/src/Profile/Shopware/Media/LocalMediaProcessor.php b/src/Profile/Shopware/Media/LocalMediaProcessor.php index 85bae475a..abdb1025f 100644 --- a/src/Profile/Shopware/Media/LocalMediaProcessor.php +++ b/src/Profile/Shopware/Media/LocalMediaProcessor.php @@ -10,6 +10,7 @@ use Doctrine\DBAL\Connection; use Shopware\Core\Content\Media\File\FileSaver; use Shopware\Core\Content\Media\File\MediaFile; +use Shopware\Core\Content\Media\MediaDefinition; use Shopware\Core\Content\Media\MediaException; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; @@ -129,8 +130,14 @@ private function copyMediaFiles( if ($resolver === null) { $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) + ->withSourceData([ + 'media_id' => $mediaId, + 'source_path' => $sourcePath, + 'media' => $mediaFile, + ]) ->build(CannotGetFileRunLog::class) ); $processedMedia[] = $mediaId; @@ -146,8 +153,14 @@ private function copyMediaFiles( $failedMedia[] = $mediaId; $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) + ->withSourceData([ + 'media_id' => $mediaId, + 'source_path' => $sourcePath, + 'media' => $mediaFile, + ]) ->build(TemporaryFileErrorLog::class) ); @@ -175,8 +188,14 @@ private function copyMediaFiles( $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); $failedMedia[] = $mediaId; - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) + ->withSourceData([ + 'media_id' => $mediaId, + 'source_path' => $sourcePath, + 'media' => $mediaFile, + ]) ->withExceptionMessage($e->getMessage()) ->withExceptionTrace($e->getTrace()) ->build(ExceptionRunLog::class) @@ -185,8 +204,14 @@ private function copyMediaFiles( \unlink($filePath); } else { $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) + ->withSourceData([ + 'media_id' => $mediaId, + 'source_path' => $sourcePath, + 'media' => $mediaFile, + ]) ->build(CannotGetFileRunLog::class) ); $failedMedia[] = $mediaId; @@ -221,8 +246,14 @@ private function persistFileToMedia( $failedMedia[] = $mediaId; $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) + ->withSourceData([ + 'media_id' => $mediaId, + 'file_path' => $filePath, + 'media' => $media, + ]) ->build(MimeTypeErrorLog::class) ); diff --git a/src/Profile/Shopware/Media/LocalOrderDocumentProcessor.php b/src/Profile/Shopware/Media/LocalOrderDocumentProcessor.php index e4d52ec39..1c32d479c 100644 --- a/src/Profile/Shopware/Media/LocalOrderDocumentProcessor.php +++ b/src/Profile/Shopware/Media/LocalOrderDocumentProcessor.php @@ -8,6 +8,7 @@ namespace SwagMigrationAssistant\Profile\Shopware\Media; use Doctrine\DBAL\Connection; +use Shopware\Core\Content\Media\MediaDefinition; use Shopware\Core\Content\Media\MediaException; use Shopware\Core\Content\Media\MediaService; use Shopware\Core\Framework\Context; @@ -96,10 +97,18 @@ private function copyMediaFiles( if (!\is_file($sourcePath)) { $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry( // TODO: add optional fields + + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) + ->withSourceData([ + 'media_id' => $mediaId, + 'source_path' => $sourcePath, + 'media' => $mappedWorkload[$mediaId], + ]) ->build(CannotGetFileRunLog::class) ); + $processedMedia[] = $mediaId; $failedMedia[] = $mediaId; @@ -117,10 +126,15 @@ private function copyMediaFiles( $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) ->withExceptionMessage($e->getMessage()) ->withExceptionTrace($e->getTrace()) + ->withSourceData([ + 'media_id' => $mediaId, + 'source_path' => $sourcePath, + 'media' => $mappedWorkload[$mediaId], + ]) ->build(ExceptionRunLog::class) ); } diff --git a/src/Profile/Shopware/Media/LocalProductDownloadProcessor.php b/src/Profile/Shopware/Media/LocalProductDownloadProcessor.php index 97f68097b..034b0b946 100644 --- a/src/Profile/Shopware/Media/LocalProductDownloadProcessor.php +++ b/src/Profile/Shopware/Media/LocalProductDownloadProcessor.php @@ -8,6 +8,7 @@ namespace SwagMigrationAssistant\Profile\Shopware\Media; use Doctrine\DBAL\Connection; +use Shopware\Core\Content\Media\MediaDefinition; use Shopware\Core\Content\Media\MediaException; use Shopware\Core\Content\Media\MediaService; use Shopware\Core\Framework\Context; @@ -101,8 +102,14 @@ private function copyMediaFiles( if (!\is_file($sourcePath)) { $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) + ->withSourceData([ + 'media_id' => $mediaId, + 'source_path' => $sourcePath, + 'media' => $mappedWorkload[$mediaId], + ]) ->build(CannotGetFileRunLog::class) ); $processedMedia[] = $mediaId; @@ -122,8 +129,14 @@ private function copyMediaFiles( $mappedWorkload[$mediaId]->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) + ->withEntityName(MediaDefinition::ENTITY_NAME) + ->withSourceData([ + 'media_id' => $mediaId, + 'source_path' => $sourcePath, + 'media' => $mappedWorkload[$mediaId], + ]) ->withExceptionMessage($e->getMessage()) ->withExceptionTrace($e->getTrace()) ->build(ExceptionRunLog::class) diff --git a/src/Profile/Shopware6/Converter/DocumentBaseConfigConverter.php b/src/Profile/Shopware6/Converter/DocumentBaseConfigConverter.php index 72fcb88d0..f2cb61489 100644 --- a/src/Profile/Shopware6/Converter/DocumentBaseConfigConverter.php +++ b/src/Profile/Shopware6/Converter/DocumentBaseConfigConverter.php @@ -7,6 +7,7 @@ namespace SwagMigrationAssistant\Profile\Shopware6\Converter; +use Shopware\Core\Checkout\Document\Aggregate\DocumentBaseConfig\DocumentBaseConfigDefinition; use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; @@ -58,8 +59,13 @@ protected function convertData(array $data): ConvertStruct $converted['documentTypeId'] = $this->documentTypeLookup->get($converted['documentType']['technicalName'], $this->context); if ($converted['documentTypeId'] === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(DocumentBaseConfigDefinition::ENTITY_NAME) + ->withFieldName('documentTypeId') + ->withFieldSourcePath('id') + ->withSourceData($data) + ->withConvertedData($converted) ->build(UnsupportedDocumentTypeLog::class) ); diff --git a/src/Profile/Shopware6/Converter/DocumentConverter.php b/src/Profile/Shopware6/Converter/DocumentConverter.php index 75ad9ca16..f74e5d845 100644 --- a/src/Profile/Shopware6/Converter/DocumentConverter.php +++ b/src/Profile/Shopware6/Converter/DocumentConverter.php @@ -7,6 +7,7 @@ namespace SwagMigrationAssistant\Profile\Shopware6\Converter; +use Shopware\Core\Checkout\Document\DocumentDefinition; use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; @@ -64,8 +65,13 @@ protected function convertData(array $data): ConvertStruct $converted['documentTypeId'] = $this->documentTypeLookup->get($converted['documentType']['technicalName'], $this->context); if ($converted['documentTypeId'] === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(DocumentDefinition::ENTITY_NAME) + ->withFieldName('documentTypeId') + ->withFieldSourcePath('id') + ->withSourceData($data) + ->withConvertedData($converted) ->build(UnsupportedDocumentTypeLog::class) ); diff --git a/src/Profile/Shopware6/Converter/MailTemplateConverter.php b/src/Profile/Shopware6/Converter/MailTemplateConverter.php index d079a2702..dd8c6b1b0 100644 --- a/src/Profile/Shopware6/Converter/MailTemplateConverter.php +++ b/src/Profile/Shopware6/Converter/MailTemplateConverter.php @@ -7,6 +7,7 @@ namespace SwagMigrationAssistant\Profile\Shopware6\Converter; +use Shopware\Core\Content\MailTemplate\MailTemplateDefinition; use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; @@ -65,8 +66,11 @@ protected function convertData(array $data): ConvertStruct } else { $typeUuid = $this->mailTemplateTypeLookup->get($converted['mailTemplateType']['technicalName'], $this->context); if ($typeUuid === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(MailTemplateDefinition::ENTITY_NAME) + ->withFieldName('mailTemplateTypeId') + ->withFieldSourcePath('mailTemplateType.technicalName') ->build(UnsupportedMailTemplateTypeLog::class) ); diff --git a/src/Profile/Shopware6/Converter/MediaFolderConverter.php b/src/Profile/Shopware6/Converter/MediaFolderConverter.php index 3453c1c18..2fadd4426 100644 --- a/src/Profile/Shopware6/Converter/MediaFolderConverter.php +++ b/src/Profile/Shopware6/Converter/MediaFolderConverter.php @@ -7,6 +7,7 @@ namespace SwagMigrationAssistant\Profile\Shopware6\Converter; +use Shopware\Core\Content\Media\Aggregate\MediaFolder\MediaFolderDefinition; use Shopware\Core\Framework\Log\Package; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; @@ -59,8 +60,13 @@ protected function convertData(array $data): ConvertStruct $converted['parentId'] = $this->mediaFolderLookup->get($data['defaultFolder']['entity'], $this->context); if ($converted['parentId'] === null) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(MediaFolderDefinition::ENTITY_NAME) + ->withFieldName('parentId') + ->withFieldSourcePath('defaultFolder.entity') + ->withSourceData($data) + ->withConvertedData($converted) ->build(UnsupportedMediaDefaultFolderLog::class) ); } diff --git a/src/Profile/Shopware6/Converter/NumberRangeConverter.php b/src/Profile/Shopware6/Converter/NumberRangeConverter.php index b905eab80..6d4125a2a 100644 --- a/src/Profile/Shopware6/Converter/NumberRangeConverter.php +++ b/src/Profile/Shopware6/Converter/NumberRangeConverter.php @@ -12,6 +12,7 @@ use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter; use Shopware\Core\Framework\Log\Package; use Shopware\Core\System\NumberRange\Aggregate\NumberRangeState\NumberRangeStateCollection; +use Shopware\Core\System\NumberRange\NumberRangeDefinition; use SwagMigrationAssistant\Migration\Converter\ConvertStruct; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; @@ -63,8 +64,12 @@ protected function convertData(array $data): ConvertStruct $data['id'] ); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName(NumberRangeDefinition::ENTITY_NAME) + ->withFieldName('typeId') + ->withFieldSourcePath('id') + ->withSourceData($data) ->build(UnsupportedNumberRangeTypeLog::class) ); diff --git a/src/Profile/Shopware6/Converter/ShopwareConverter.php b/src/Profile/Shopware6/Converter/ShopwareConverter.php index d2dcb8d2e..054364ea0 100644 --- a/src/Profile/Shopware6/Converter/ShopwareConverter.php +++ b/src/Profile/Shopware6/Converter/ShopwareConverter.php @@ -145,8 +145,10 @@ protected function updateAssociationIds(array &$associationArray, string $entity if (empty($newAssociationId)) { if ($logMissing) { - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($this->migrationContext) + ->withEntityName($entity) + ->withConvertedData($association) ->build(AssociationRequiredMissingLog::class) ); } diff --git a/src/Profile/Shopware6/Media/HttpOrderDocumentGenerationService.php b/src/Profile/Shopware6/Media/HttpOrderDocumentGenerationService.php index dae35f759..6dd31d313 100644 --- a/src/Profile/Shopware6/Media/HttpOrderDocumentGenerationService.php +++ b/src/Profile/Shopware6/Media/HttpOrderDocumentGenerationService.php @@ -86,7 +86,7 @@ public function process( if ($client === null) { $exception = new \Exception('Connection to the source system could not be established'); - $this->loggingService->addLogEntry( // TODO: add optional fields + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) ->withExceptionMessage($exception->getMessage()) ->withExceptionTrace($exception->getTrace()) @@ -287,10 +287,12 @@ private function handleFailedRequest( if ($mappedWorkload->getErrorCount() > ProcessMediaHandler::MEDIA_ERROR_THRESHOLD) { $failureUuids[] = $uuid; $mappedWorkload->setState(MediaProcessWorkloadStruct::ERROR_STATE); - $this->loggingService->addLogEntry( // TODO: add optional fields + + $this->loggingService->addLogEntry( SwagMigrationLogBuilder::fromMigrationContext($migrationContext) ->withExceptionMessage($clientException?->getMessage() ?? 'Unknown error occurred') ->withExceptionTrace($clientException?->getTrace() ?? []) + ->withSourceData($additionalData) ->build(CannotGetFileRunLog::class) ); } diff --git a/tests/Migration/Services/MigrationDataProcessingTest.php b/tests/Migration/Services/MigrationDataProcessingTest.php index 061ac313b..bac2ffcc1 100644 --- a/tests/Migration/Services/MigrationDataProcessingTest.php +++ b/tests/Migration/Services/MigrationDataProcessingTest.php @@ -365,7 +365,7 @@ public function testFetchInvalidCustomerData(): void ++$countInvalidLogging; } - static::assertSame(5, $countValidLogging); + static::assertSame(8, $countValidLogging); static::assertSame(0, $countInvalidLogging); $failureConvertCriteria = new Criteria(); diff --git a/tests/Profile/Shopware54/Converter/OrderDocumentConverterTest.php b/tests/Profile/Shopware54/Converter/OrderDocumentConverterTest.php index a7a69a0f2..d4c67c91f 100644 --- a/tests/Profile/Shopware54/Converter/OrderDocumentConverterTest.php +++ b/tests/Profile/Shopware54/Converter/OrderDocumentConverterTest.php @@ -15,8 +15,6 @@ use Shopware\Core\Framework\Uuid\Uuid; use SwagMigrationAssistant\Migration\Connection\SwagMigrationConnectionEntity; use SwagMigrationAssistant\Migration\DataSelection\DefaultEntities; -use SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder; -use SwagMigrationAssistant\Migration\Logging\Log\DocumentTypeNotSupportedLog; use SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface; use SwagMigrationAssistant\Migration\Mapping\Lookup\DocumentTypeLookup; use SwagMigrationAssistant\Migration\Mapping\Lookup\MediaDefaultFolderLookup; @@ -176,14 +174,7 @@ public function testConvertShouldLogUnknownType(): void foreach ($orderDocumentConverterClasses as $orderDocumentConverterClass => $expected) { $loggerMock = $this->createMock(LoggingServiceInterface::class); - $loggerMock->expects(static::exactly(1))->method('addLogEntry')->with( - (new SwagMigrationLogBuilder( - $this->runId, - Shopware54Profile::PROFILE_NAME, - ShopwareLocalGateway::GATEWAY_NAME - ))->build(DocumentTypeNotSupportedLog::class) - ); - + $loggerMock->expects(static::exactly(1))->method('addLogEntry'); $orderDocumentConverter = $this->createDocumentConverter($orderDocumentConverterClass, $mappingServiceMock, $loggerMock); $convertResult = $orderDocumentConverter->convert( $document, diff --git a/tests/Profile/Shopware55/Converter/CustomerConverterTest.php b/tests/Profile/Shopware55/Converter/CustomerConverterTest.php index d8a76f604..69657b940 100644 --- a/tests/Profile/Shopware55/Converter/CustomerConverterTest.php +++ b/tests/Profile/Shopware55/Converter/CustomerConverterTest.php @@ -429,11 +429,12 @@ public function testConvertWithoutRequiredAddressPropertiesForDefaultBillingAndS static::assertSame($converted['addresses'][0]['id'], $converted['defaultShippingAddressId']); $logs = $this->loggingService->getLoggingArray(); - static::assertCount(3, $logs); + static::assertCount(4, $logs); static::assertSame($logs[0]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); static::assertSame($logs[1]['code'], 'SWAG_MIGRATION_EMPTY_NECESSARY_FIELD'); static::assertSame($logs[2]['code'], 'SWAG_MIGRATION_ENTITY_FIELD_REASSIGNED'); + static::assertSame($logs[2]['code'], 'SWAG_MIGRATION_ENTITY_FIELD_REASSIGNED'); } public function testGetCustomerWithShopScope(): void From cb0f6b17e3fd631b780e326f53cd7d8436b54e0c Mon Sep 17 00:00:00 2001 From: Lars Kemper Date: Mon, 1 Sep 2025 10:03:42 +0200 Subject: [PATCH 08/46] docs: update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index deae4c9e9..89629b15c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ - [BREAKING] [#38](https://github.com/shopware/SwagMigrationAssistant/pull/38) feat!: add migration logging required fields - [BREAKING] [#40](https://github.com/shopware/SwagMigrationAssistant/pull/40) refactor!: add migration logging optional fields - [BREAKING] [#43](https://github.com/shopware/SwagMigrationAssistant/pull/43) refactor!: migration connection usage +- [#46](https://github.com/shopware/SwagMigrationAssistant/pull/46) feat: fill logs with meaningful data src/Migration +- [#47](https://github.com/shopware/SwagMigrationAssistant/pull/47) fix: phpstan log array types +- [#48](https://github.com/shopware/SwagMigrationAssistant/pull/48) feat: add iterative log building helper +- [#49](https://github.com/shopware/SwagMigrationAssistant/pull/49) feat: fill logs with meaningful data # 15.0.3 - Fixed translations of error groups missing details like the entity From 8646a891b7a9ad89a179aa7daa0dfbd99a21e0af Mon Sep 17 00:00:00 2001 From: Jozsef Damokos Date: Tue, 2 Sep 2025 10:59:17 +0300 Subject: [PATCH 09/46] feat: refactor connection credentials page (#42) --- .../src/module/swag-migration/index.js | 7 -- .../swag-migration/page/wizard/index.js | 1 - .../index.js | 30 --------- ...-wizard-page-profile-information.html.twig | 9 --- .../wizard/swag-migration-wizard/index.js | 46 ------------- .../swag-migration-wizard.html.twig | 12 ---- .../swag-migration-wizard.scss | 25 ++++--- .../index.js | 18 +++++ ...ile-shopware-api-credential-form.html.twig | 39 ++++++++--- .../index.js | 35 ---------- ...le-shopware-api-page-information.html.twig | 42 ------------ ...le-shopware6-api-credential-form.html.twig | 39 ++++++++--- .../index.js | 12 ---- ...e-shopware6-api-page-information.html.twig | 65 ------------------- ...rofile-shopware6-api-page-information.scss | 31 --------- .../module/swag-migration/snippet/de-DE.json | 52 +++++++-------- .../module/swag-migration/snippet/en-GB.json | 52 +++++++-------- 17 files changed, 144 insertions(+), 371 deletions(-) delete mode 100644 src/Resources/app/administration/src/module/swag-migration/page/wizard/swag-migration-wizard-page-profile-information/index.js delete mode 100644 src/Resources/app/administration/src/module/swag-migration/page/wizard/swag-migration-wizard-page-profile-information/swag-migration-wizard-page-profile-information.html.twig delete mode 100644 src/Resources/app/administration/src/module/swag-migration/profile/shopware/api/swag-migration-profile-shopware-api-page-information/index.js delete mode 100644 src/Resources/app/administration/src/module/swag-migration/profile/shopware/api/swag-migration-profile-shopware-api-page-information/swag-migration-profile-shopware-api-page-information.html.twig delete mode 100644 src/Resources/app/administration/src/module/swag-migration/profile/shopware6/api/swag-migration-profile-shopware6-api-page-information/index.js delete mode 100644 src/Resources/app/administration/src/module/swag-migration/profile/shopware6/api/swag-migration-profile-shopware6-api-page-information/swag-migration-profile-shopware6-api-page-information.html.twig delete mode 100644 src/Resources/app/administration/src/module/swag-migration/profile/shopware6/api/swag-migration-profile-shopware6-api-page-information/swag-migration-profile-shopware6-api-page-information.scss diff --git a/src/Resources/app/administration/src/module/swag-migration/index.js b/src/Resources/app/administration/src/module/swag-migration/index.js index f14aaf350..0931161ee 100644 --- a/src/Resources/app/administration/src/module/swag-migration/index.js +++ b/src/Resources/app/administration/src/module/swag-migration/index.js @@ -119,13 +119,6 @@ Module.register('swag-migration', { privilege: 'admin', }, }, - profileInformation: { - path: 'profile/information', - component: 'swag-migration-wizard-page-profile-information', - meta: { - privilege: 'admin', - }, - }, credentials: { path: 'credentials', component: 'swag-migration-wizard-page-credentials', diff --git a/src/Resources/app/administration/src/module/swag-migration/page/wizard/index.js b/src/Resources/app/administration/src/module/swag-migration/page/wizard/index.js index 6d0a1bed8..cb0167964 100644 --- a/src/Resources/app/administration/src/module/swag-migration/page/wizard/index.js +++ b/src/Resources/app/administration/src/module/swag-migration/page/wizard/index.js @@ -8,7 +8,6 @@ import './swag-migration-wizard-page-introduction'; import './swag-migration-wizard-page-profile-installation'; import './swag-migration-wizard-page-connection-select'; import './swag-migration-wizard-page-connection-create'; -import './swag-migration-wizard-page-profile-information'; import './swag-migration-wizard-page-credentials'; import './swag-migration-wizard-page-credentials-success'; import './swag-migration-wizard-page-credentials-error'; diff --git a/src/Resources/app/administration/src/module/swag-migration/page/wizard/swag-migration-wizard-page-profile-information/index.js b/src/Resources/app/administration/src/module/swag-migration/page/wizard/swag-migration-wizard-page-profile-information/index.js deleted file mode 100644 index 7452c5517..000000000 --- a/src/Resources/app/administration/src/module/swag-migration/page/wizard/swag-migration-wizard-page-profile-information/index.js +++ /dev/null @@ -1,30 +0,0 @@ -import template from './swag-migration-wizard-page-profile-information.html.twig'; - -const { Component } = Shopware; - -/** - * @private - * @sw-package fundamentals@after-sales - */ -Component.register('swag-migration-wizard-page-profile-information', { - template, - - props: { - profileInformationComponent: { - type: String, - default: '', - }, - }, - - metaInfo() { - return { - title: this.$createTitle(), - }; - }, - - computed: { - componentIsLoaded() { - return Component.getComponentRegistry().has(this.profileInformationComponent); - }, - }, -}); diff --git a/src/Resources/app/administration/src/module/swag-migration/page/wizard/swag-migration-wizard-page-profile-information/swag-migration-wizard-page-profile-information.html.twig b/src/Resources/app/administration/src/module/swag-migration/page/wizard/swag-migration-wizard-page-profile-information/swag-migration-wizard-page-profile-information.html.twig deleted file mode 100644 index 757ce720b..000000000 --- a/src/Resources/app/administration/src/module/swag-migration/page/wizard/swag-migration-wizard-page-profile-information/swag-migration-wizard-page-profile-information.html.twig +++ /dev/null @@ -1,9 +0,0 @@ -{% block swag_migration_wizard_page_profile_information %} -
- - {% block swag_migration_wizard_page_profile_information_component %} - - {% endblock %} -
-{% endblock %} \ No newline at end of file diff --git a/src/Resources/app/administration/src/module/swag-migration/page/wizard/swag-migration-wizard/index.js b/src/Resources/app/administration/src/module/swag-migration/page/wizard/swag-migration-wizard/index.js index 2913b0bf1..3b90573ad 100644 --- a/src/Resources/app/administration/src/module/swag-migration/page/wizard/swag-migration-wizard/index.js +++ b/src/Resources/app/administration/src/module/swag-migration/page/wizard/swag-migration-wizard/index.js @@ -88,18 +88,6 @@ Component.register('swag-migration-wizard', { return this.currentRoute.titleSnippet; }, - buttonBackSnippet() { - return 'swag-migration.wizard.buttonToProfileInformation'; - }, - - buttonBackVisible() { - return ( - !this.isLoading && - this.currentRoute === this.routes.credentials && - this.profileInformationComponentIsLoaded - ); - }, - buttonSecondarySnippet() { if (this.currentRoute === this.routes.credentialsError) { return 'swag-migration.wizard.buttonLater'; @@ -156,19 +144,6 @@ Component.register('swag-migration-wizard', { return this.isLoading; }, - profileInformationComponent() { - if (!this.connection || !this.connection.profileName || !this.connection.gatewayName) { - return ''; - } - - return `swag-migration-profile-${this.connection.profileName}-` + - `${this.connection.gatewayName}-page-information`; - }, - - profileInformationComponentIsLoaded() { - return Component.getComponentRegistry().has(this.profileInformationComponent); - }, - credentialsComponent() { if (!this.connection || !this.connection.profileName || !this.connection.gatewayName) { return ''; @@ -250,11 +225,6 @@ Component.register('swag-migration-wizard', { index: 0.3, // not available through nextRoute (child from profile) titleSnippet: 'swag-migration.wizard.pages.connectionSelect.title', }, - profileInformation: { - name: 'swag.migration.wizard.profileInformation', - index: 1, - titleSnippet: 'swag-migration.wizard.pages.profileInformation.title', - }, credentials: { name: 'swag.migration.wizard.credentials', index: 2, @@ -401,24 +371,9 @@ Component.register('swag-migration-wizard', { if (!Object.keys(this.connection).length) { // there is no connection selected. redirect to the selection this.onNoConnectionSelected(); - return; - } - - if (!this.profileInformationComponentIsLoaded) { - if (this.currentRoute === this.routes.profileInformation) { - this.navigateToRoute(this.routes.credentials); - } - - // make the profileInformation route a child if there is no component - // so navigation to this route is not possible for the user - this.routes.profileInformation.index = 0.1; } }, - onButtonBackClick() { - this.navigateToRoute(this.routes.profileInformation); - }, - onButtonSecondaryClick() { // Abort / Later this.onCloseModal(); @@ -537,7 +492,6 @@ Component.register('swag-migration-wizard', { onNoConnectionSelected() { if ([ this.routes.chooseAction, - this.routes.profileInformation, this.routes.credentials, this.routes.credentialsSuccess, this.routes.credentialsError, diff --git a/src/Resources/app/administration/src/module/swag-migration/page/wizard/swag-migration-wizard/swag-migration-wizard.html.twig b/src/Resources/app/administration/src/module/swag-migration/page/wizard/swag-migration-wizard/swag-migration-wizard.html.twig index 242294935..19983efe4 100644 --- a/src/Resources/app/administration/src/module/swag-migration/page/wizard/swag-migration-wizard/swag-migration-wizard.html.twig +++ b/src/Resources/app/administration/src/module/swag-migration/page/wizard/swag-migration-wizard/swag-migration-wizard.html.twig @@ -38,18 +38,6 @@ class="swag-migration-wizard__placeholder">