99
1010use Doctrine \DBAL \Connection ;
1111use GuzzleHttp \Exception \RequestException ;
12- use GuzzleHttp \Promise ;
1312use GuzzleHttp \Promise \PromiseInterface ;
1413use GuzzleHttp \Promise \Utils ;
1514use Psr \Http \Message \ResponseInterface ;
1615use Shopware \Core \Content \Media \File \FileSaver ;
1716use Shopware \Core \Content \Media \File \MediaFile ;
17+ use Shopware \Core \Content \Media \MediaDefinition ;
1818use Shopware \Core \Content \Media \MediaException ;
1919use Shopware \Core \Framework \Context ;
2020use Shopware \Core \Framework \DataAbstractionLayer \EntityRepository ;
@@ -77,10 +77,11 @@ public function process(MigrationContextInterface $migrationContext, Context $co
7777 if ($ client === null ) {
7878 $ exception = new \Exception ('Http download client can not be constructed. ' );
7979
80- $ this ->loggingService ->addLogEntry ( // TODO: add optional fields
80+ $ this ->loggingService ->addLogEntry (
8181 SwagMigrationLogBuilder::fromMigrationContext ($ migrationContext )
8282 ->withExceptionMessage ($ exception ->getMessage ())
8383 ->withExceptionTrace ($ exception ->getTrace ())
84+ ->withEntityName (MediaDefinition::ENTITY_NAME )
8485 ->build (ExceptionRunLog::class)
8586 );
8687 $ this ->loggingService ->saveLogging ($ context );
@@ -122,8 +123,9 @@ function (MediaProcessWorkloadStruct $work) use ($uuid) {
122123 $ failureUuids [] = $ uuid ;
123124 $ work ->setState (MediaProcessWorkloadStruct::ERROR_STATE );
124125
125- $ this ->loggingService ->addLogEntry ( // TODO: add optional fields
126+ $ this ->loggingService ->addLogEntry (
126127 SwagMigrationLogBuilder::fromMigrationContext ($ migrationContext )
128+ ->withEntityName (MediaDefinition::ENTITY_NAME )
127129 ->build (CannotGetFileRunLog::class)
128130 );
129131 }
@@ -141,8 +143,9 @@ function (MediaProcessWorkloadStruct $work) use ($uuid) {
141143 $ failureUuids [] = $ uuid ;
142144 $ work ->setState (MediaProcessWorkloadStruct::ERROR_STATE );
143145
144- $ this ->loggingService ->addLogEntry ( // TODO: add optional fields
146+ $ this ->loggingService ->addLogEntry (
145147 SwagMigrationLogBuilder::fromMigrationContext ($ migrationContext )
148+ ->withEntityName (MediaDefinition::ENTITY_NAME )
146149 ->build (TemporaryFileErrorLog::class)
147150 );
148151
@@ -181,10 +184,11 @@ function (MediaProcessWorkloadStruct $work) use ($uuid) {
181184 } catch (\Exception $ e ) {
182185 $ failureUuids [] = $ uuid ;
183186 $ work ->setState (MediaProcessWorkloadStruct::ERROR_STATE );
184- $ this ->loggingService ->addLogEntry ( // TODO: add optional fields
187+ $ this ->loggingService ->addLogEntry (
185188 SwagMigrationLogBuilder::fromMigrationContext ($ migrationContext )
186189 ->withExceptionMessage ($ e ->getMessage ())
187190 ->withExceptionTrace ($ e ->getTrace ())
191+ ->withEntityName (MediaDefinition::ENTITY_NAME )
188192 ->build (ExceptionRunLog::class)
189193 );
190194 } finally {
@@ -279,10 +283,11 @@ private function doNormalDownloadRequest(MigrationContextInterface $migrationCon
279283 $ workload ->setState (MediaProcessWorkloadStruct::FINISH_STATE );
280284 } catch (\Throwable $ exception ) {
281285 // this should never happen because of Promises, but just in case something is wrong with request construction
282- $ this ->loggingService ->addLogEntry ( // TODO: add optional fields
286+ $ this ->loggingService ->addLogEntry (
283287 SwagMigrationLogBuilder::fromMigrationContext ($ migrationContext )
284288 ->withExceptionMessage ($ exception ->getMessage ())
285289 ->withExceptionTrace ($ exception ->getTrace ())
290+ ->withEntityName (MediaDefinition::ENTITY_NAME )
286291 ->build (ExceptionRunLog::class)
287292 );
288293
@@ -302,10 +307,11 @@ private function persistFileToMedia(string $filePath, string $uuid, string $name
302307 if ($ fileSize === false || $ fileSize === 0 || $ mimeType === false ) {
303308 $ exception = new \Exception ('Downloaded file is empty or could not determine mime type. ' );
304309
305- $ this ->loggingService ->addLogEntry ( // TODO: add optional fields
310+ $ this ->loggingService ->addLogEntry (
306311 SwagMigrationLogBuilder::fromMigrationContext ($ migrationContext )
307312 ->withExceptionMessage ($ exception ->getMessage ())
308313 ->withExceptionTrace ($ exception ->getTrace ())
314+ ->withEntityName (MediaDefinition::ENTITY_NAME )
309315 ->build (ExceptionRunLog::class)
310316 );
311317
@@ -337,10 +343,11 @@ private function persistFileToMedia(string $filePath, string $uuid, string $name
337343 } elseif (\in_array ($ mediaException ->getErrorCode (), [MediaException::MEDIA_ILLEGAL_FILE_NAME , MediaException::MEDIA_EMPTY_FILE_NAME ], true )) {
338344 $ this ->fileSaver ->persistFileToMedia ($ mediaFile , Uuid::randomHex (), $ uuid , $ context );
339345 } else {
340- $ this ->loggingService ->addLogEntry ( // TODO: add optional fields
346+ $ this ->loggingService ->addLogEntry (
341347 SwagMigrationLogBuilder::fromMigrationContext ($ migrationContext )
342348 ->withExceptionMessage ($ mediaException ->getMessage ())
343349 ->withExceptionTrace ($ mediaException ->getTrace ())
350+ ->withEntityName (MediaDefinition::ENTITY_NAME )
344351 ->build (ExceptionRunLog::class)
345352 );
346353 }
0 commit comments