Skip to content

Commit 638b84d

Browse files
authored
refactor!: migration connection usage (#43)
1 parent d2468fd commit 638b84d

File tree

156 files changed

+649
-634
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+649
-634
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 16.0.0
2+
- [BREAKING] [#38](https://github.com/shopware/SwagMigrationAssistant/pull/38) feat!: add migration logging required fields
3+
- [BREAKING] [#40](https://github.com/shopware/SwagMigrationAssistant/pull/40) refactor!: add migration logging optional fields
4+
- [BREAKING] [#43](https://github.com/shopware/SwagMigrationAssistant/pull/43) refactor!: migration connection usage
5+
16
# 15.0.3
27
- Fixed translations of error groups missing details like the entity
38
- Fixed handling of customers without default payment method in SW6.7 migrations

CHANGELOG_de-DE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 16.0.0
2+
- [BREAKING] [#38](https://github.com/shopware/SwagMigrationAssistant/pull/38) feat!: Erforderliche Felder für Migrationsprotokollierung hinzufügen
3+
- [BREAKING] [#40](https://github.com/shopware/SwagMigrationAssistant/pull/40) refactor!: Optionale Felder für Migrationsprotokollierung hinzufügen
4+
- [BREAKING] [#43](https://github.com/shopware/SwagMigrationAssistant/pull/43) refactor!: Nutzung der Migrationsverbindung
5+
16
# 15.0.3
27
- Übersetzungen von Fehlergruppen behoben, welche Details wie den Entitätsnamen nicht darstellten
38
- Fehler bei Kunden ohne Standardzahlungsmethode in SW6.7 Migrationen behoben

UPGRADE.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,72 @@
1+
# 16.0.0
2+
3+
- [BREAKING] [#38](https://github.com/shopware/SwagMigrationAssistant/pull/38) - feat!: add migration logging required fields
4+
- [BREAKING] Truncated database entries of `swag_migration_logging` with `SwagMigrationAssistant\Core\Migration\Migration1754896654TruncateMigrationLogs`
5+
- [BREAKING] Deleted columns `title`, `description`, `paramenters`, `title_snippet`, `description_snippet`, `entity` and `source_id` from `swag_migration_logging` with `SwagMigrationAssistant\Core\Migration\Migration1754897550AddRequiredFieldsToMigrationLogs`
6+
- [BREAKING] Removed fields `title`, `description`, `parameters`, `title_snippet`, `description_snippet`, `entity` and `source_id` from log definition `SwagMigrationAssistant\Migration\Logging\SwagMigrationLoggingDefinition`
7+
- [BREAKING] Removed properties `title`, `description`, `parameters`, `titleSnippet`, `descriptionSnippet`, `entity` and `sourceId` from log entity `SwagMigrationAssistant\Migration\Logging\SwagMigrationLoggingEntity`
8+
- [BREAKING] Removed aggregations of `titleSnippet`, `entity` and `level` in `SwagMigrationAssistant\Migration\History\HistoryService`
9+
- [BREAKING] Updated all log implementations in `SwagMigrationAssistant\Migration\Logging\Log\*` and `SwagMigrationAssistant\Profile\**\Logging\*`:
10+
- deleted methods `getTitle()`, `getTitleSnippet()`, `getDescription()`, `getDescriptionSnippet()`, `getParameters()`, `getSourceId()`
11+
- add method `isUserFixable()`
12+
- Added columns `profile_name`, `gateway_name` and `user_fixable` to `swag_migration_logging` with `SwagMigrationAssistant\Core\Migration\Migration1754897550AddRequiredFieldsToMigrationLogs`
13+
- Added fields `profile_name`, `gateway_name` and `user_fixable` to log definition `SwagMigrationAssistant\Migration\Logging\SwagMigrationLoggingDefinition`
14+
- Added properties `profileName`, `gatewayName` and `userFixable` to log entity `SwagMigrationAssistant\Migration\Logging\SwagMigrationLoggingEntity`
15+
16+
- [BREAKING] [#40](https://github.com/shopware/SwagMigrationAssistant/pull/40) - refactor!: add migration logging optional fields
17+
- [BREAKING] Replaced `SwagMigrationAssistant\Migration\Logging\Log\BaseRunLogEntity` with `SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry`
18+
- [BREAKING] Replaced `SwagMigrationAssistant\Migration\Logging\Log\LogEntryInterface` with `SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogEntry`
19+
- [BREAKING] Updated all log implementations in `SwagMigrationAssistant\Migration\Logging\Log\*` and `SwagMigrationAssistant\Profile\**\Logging\*`:
20+
- extend `SwagMigrationAssistant\Migration\Logging\Log\Builder\AbstractSwagMigrationLogEntry` instead of `SwagMigrationAssistant\Migration\Logging\Log\BaseRunLogEntity`
21+
- implement `SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogEntry` instead of `SwagMigrationAssistant\Migration\Logging\Log\LogEntryInterface`
22+
- mark class readonly
23+
- [BREAKING] Renamed log classes to include `Log` suffix
24+
- `SwagMigrationAssistant\Migration\Logging\LogCannotConvertChildEntity`,
25+
- `SwagMigrationAssistant\Migration\Logging\LogCannotConvertEntity`,
26+
- `SwagMigrationAssistant\Migration\Logging\LogDocumentTypeNotSupported`,
27+
- `SwagMigrationAssistant\Migration\Logging\LogInvalidUnserializedData`,
28+
- `SwagMigrationAssistant\Migration\Logging\LogInvalidUnserializedData`,
29+
- `SwagMigrationAssistant\Migration\Logging\LogRunAbortedAutomatically`
30+
- `SwagMigrationAssistant\Migration\Logging\LogUnsupportedObjectType`
31+
- [BREAKING] Change method `addLogEntry()` of `SwagMigrationAssistant\Migration\Logging\LoggingServiceInterface` and implementation `LoggingService` to require `SwagMigrationLogEntry` as parameter instead of `LogEntryInterface`
32+
- Created `SwagMigrationAssistant\Migration\Logging\Log\Builder\SwagMigrationLogBuilder` to build log entries of type `SwagMigrationLogEntry`
33+
- Added columns to `swag_migration_logging` with `SwagMigrationAssistant\Core\Migration\Migration1754897550AddRequiredFieldsToMigrationLogs`:
34+
- `entity_name`
35+
- `field_name`
36+
- `field_source_path`
37+
- `source_data`
38+
- `converted_data`
39+
- `used_mapping`
40+
- `exception_message`
41+
- `exception_trace`
42+
- Added fields to `swag_migration_logging` to log definition `SwagMigrationAssistant\Migration\Logging\SwagMigrationLoggingDefinition`:
43+
- `entity_name`
44+
- `field_name`
45+
- `field_source_path`
46+
- `source_data`
47+
- `converted_data`
48+
- `used_mapping`
49+
- `exception_message`
50+
- `exception_trace`
51+
- Added properties and methods to log entity `SwagMigrationAssistant\Migration\Logging\SwagMigrationLoggingEntity`:
52+
- `entityName` and `getEntityName()`
53+
- `fieldName` and `getFieldName()`
54+
- `fieldSourcePath` and `getFieldSourcePath()`
55+
- `sourceData` and `getSourceData()`
56+
- `convertedData` and `getConvertedData()`
57+
- `usedMapping` and `getUsedMapping()`
58+
- `exceptionMessage` and `getExceptionMessage()`
59+
- `exceptionTrace` and `getExceptionTrace()`
60+
61+
- [BREAKING] [#43](https://github.com/shopware/SwagMigrationAssistant/pull/43) refactor!: migration connection usage
62+
- Changed signature of method `supports()` in `SwagMigrationAssistant\Migration\Gateway\GatewayInterface` to require `ProfileInterface` as parameter instead of `MigrationContextInterface`
63+
- Changed signature of method `getGateways()` in `SwagMigrationAssistant\Migration\Gateway\GatewayRegistryInterface` to require `ProfileInterface` as parameter instead of `MigrationContextInterface`
64+
- Changed signature of method `getGateways()` in `SwagMigrationAssistant\Migration\Gateway\GatewayRegistry` to require `ProfileInterface` as parameter instead of `MigrationContextInterface`
65+
- Changed signature of constructor method of `SwagMigrationAssistant\Migration\MigrationContext` to require `SwagMigrationConnectionEntity` and additional optional parameter of `ProfileInterface` with default value `null`
66+
- Added methods `setProfile()`, `getGateway()`, `setGateway()` and `setConnection()` to `SwagMigrationAssistant\Migration\MigrationContextInterface`
67+
- Added methods `setProfile()`, `getGateway()`, `setGateway()` and `setConnection()` to `SwagMigrationAssistant\Migration\MigrationContext`
68+
- Added null checks to methods `getProfile()` and `getGateway()` in `SwagMigrationAssistant\Migration\MigrationContext` to ensure that a profile and gateway is set before usage
69+
170
# 14.0.0
271
- [BREAKING] MIG-1053 - Removed ability to set the `verify` flag for the guzzle API client. This is now always true by default.
372
- [BREAKING] MIG-1053 - Refactored both Shopware 5 and Shopware 6 EnvironmentReader classes to provide more information about exceptions.

phpstan.neon.dist

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,6 @@ parameters:
5454
paths:
5555
- tests/**/*Test.php
5656

57-
- # TODO remove with #11883
58-
message: '#Strict comparison using === between SwagMigrationAssistant\\Migration\\Connection\\SwagMigrationConnectionEntity and null will always evaluate to false\.#'
59-
paths:
60-
- **/*.php
61-
62-
- # TODO remove with #11883
63-
message: '#Strict comparison using !== between SwagMigrationAssistant\\Migration\\Connection\\SwagMigrationConnectionEntity and null will always evaluate to true\.#'
64-
paths:
65-
- **/*.php
66-
6757
rules:
6858
# Shopware core rules
6959
- Shopware\Core\DevOps\StaticAnalyze\PHPStan\Rules\Deprecation\DeprecatedMethodsThrowDeprecationRule

src/Controller/StatusController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ public function getProfileInformation(Request $request): Response
8787
return new Response();
8888
}
8989

90-
$migrationContext = $this->migrationContextFactory->createByProfileName($profileName);
91-
$gateways = $this->gatewayRegistry->getGateways($migrationContext);
90+
$profile = $this->profileRegistry->getProfile($profileName);
91+
$gateways = $this->gatewayRegistry->getGateways($profile);
9292

9393
$currentGateway = null;
9494
foreach ($gateways as $gateway) {
@@ -151,8 +151,8 @@ public function getGateways(Request $request): JsonResponse
151151
throw RoutingException::missingRequestParameter('profileName');
152152
}
153153

154-
$migrationContext = $this->migrationContextFactory->createByProfileName($profileName);
155-
$gateways = $this->gatewayRegistry->getGateways($migrationContext);
154+
$profile = $this->profileRegistry->getProfile($profileName);
155+
$gateways = $this->gatewayRegistry->getGateways($profile);
156156

157157
$gatewayNames = [];
158158
foreach ($gateways as $gateway) {

src/Migration/Converter/Converter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ protected function updateMainMapping(MigrationContextInterface $migrationContext
7676

7777
$dataSet = $migrationContext->getDataSet();
7878
$connection = $migrationContext->getConnection();
79-
if ($dataSet === null || $connection === null) {
79+
80+
if ($dataSet === null) {
8081
return;
8182
}
8283

src/Migration/Converter/ConverterRegistry.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ public function getConverter(MigrationContextInterface $migrationContext): Conve
3333
}
3434
}
3535

36-
$connection = $migrationContext->getConnection();
37-
if ($connection === null) {
38-
throw MigrationException::migrationContextPropertyMissing('Connection');
39-
}
40-
41-
throw MigrationException::converterNotFound($connection->getProfileName());
36+
throw MigrationException::converterNotFound($migrationContext->getProfile()->getName());
4237
}
4338
}

src/Migration/Gateway/GatewayInterface.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Shopware\Core\Framework\Log\Package;
1212
use SwagMigrationAssistant\Migration\EnvironmentInformation;
1313
use SwagMigrationAssistant\Migration\MigrationContextInterface;
14+
use SwagMigrationAssistant\Migration\Profile\ProfileInterface;
1415
use SwagMigrationAssistant\Migration\TotalStruct;
1516

1617
#[Package('fundamentals@after-sales')]
@@ -23,7 +24,7 @@ public function getSnippetName(): string;
2324
/**
2425
* Identifier for a gateway registry
2526
*/
26-
public function supports(MigrationContextInterface $migrationContext): bool;
27+
public function supports(ProfileInterface $profile): bool;
2728

2829
/**
2930
* Reads the given entity type from via context from its connection and returns the data

src/Migration/Gateway/GatewayRegistry.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Shopware\Core\Framework\Log\Package;
1111
use SwagMigrationAssistant\Exception\MigrationException;
1212
use SwagMigrationAssistant\Migration\MigrationContextInterface;
13+
use SwagMigrationAssistant\Migration\Profile\ProfileInterface;
1314

1415
#[Package('fundamentals@after-sales')]
1516
class GatewayRegistry implements GatewayRegistryInterface
@@ -24,11 +25,11 @@ public function __construct(private readonly iterable $gateways)
2425
/**
2526
* @return GatewayInterface[]
2627
*/
27-
public function getGateways(MigrationContextInterface $migrationContext): array
28+
public function getGateways(ProfileInterface $profile): array
2829
{
2930
$gateways = [];
3031
foreach ($this->gateways as $gateway) {
31-
if ($gateway->supports($migrationContext)) {
32+
if ($gateway->supports($profile)) {
3233
$gateways[] = $gateway;
3334
}
3435
}
@@ -39,15 +40,11 @@ public function getGateways(MigrationContextInterface $migrationContext): array
3940
public function getGateway(MigrationContextInterface $migrationContext): GatewayInterface
4041
{
4142
$connection = $migrationContext->getConnection();
42-
if ($connection === null) {
43-
throw MigrationException::migrationContextPropertyMissing('Connection');
44-
}
45-
4643
$profileName = $connection->getProfileName();
4744
$gatewayName = $connection->getGatewayName();
4845

4946
foreach ($this->gateways as $gateway) {
50-
if ($gateway->supports($migrationContext) && $gateway->getName() === $gatewayName) {
47+
if ($gateway->supports($migrationContext->getProfile()) && $gateway->getName() === $gatewayName) {
5148
return $gateway;
5249
}
5350
}

src/Migration/Gateway/GatewayRegistryInterface.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99

1010
use Shopware\Core\Framework\Log\Package;
1111
use SwagMigrationAssistant\Migration\MigrationContextInterface;
12+
use SwagMigrationAssistant\Migration\Profile\ProfileInterface;
1213

1314
#[Package('fundamentals@after-sales')]
1415
interface GatewayRegistryInterface
1516
{
1617
/**
1718
* @return GatewayInterface[]
1819
*/
19-
public function getGateways(MigrationContextInterface $migrationContext): array;
20+
public function getGateways(ProfileInterface $profile): array;
2021

2122
/**
2223
* Selects the correct gateway by the given migration context

0 commit comments

Comments
 (0)