@@ -349,28 +349,31 @@ public function processElementTransformations(
349349
350350 protected function cleanupElement (string $ configName , string $ identifier , Resolver $ resolver , array $ cleanupConfig )
351351 {
352- if ($ cleanupConfig ['doCleanup ' ] ?? false ) {
353- $ element = null ;
354-
355- try {
356- $ element = $ resolver ->loadElementByIdentifier ($ identifier );
357- if ($ element ) {
358- $ cleanupStrategy = $ this ->cleanupStrategyFactory ->loadCleanupStrategy ($ cleanupConfig ['strategy ' ]);
359- $ cleanupStrategy ->doCleanup ($ element );
360-
361- $ message = "Element {$ identifier } cleaned up ( {$ cleanupConfig ['strategy ' ]}) successfully. " ;
362- $ this ->logInfo ($ configName , $ message , [
363- 'component ' => PimcoreDataImporterBundle::LOGGER_COMPONENT_PREFIX . $ configName ,
364- 'relatedObject ' => $ element
365- ]);
366- }
367- } catch (\Exception $ e ) {
368- $ message = 'Error cleaning up element: ' ;
369- $ this ->logError ($ configName , $ message . $ e ->getMessage (), [
370- 'component ' => PimcoreDataImporterBundle::LOGGER_COMPONENT_PREFIX . $ configName ,
371- 'relatedObject ' => $ element ,
372- ]);
352+ if (!($ cleanupConfig ['doCleanup ' ] ?? false )) {
353+ return ;
354+ }
355+ try {
356+ $ element = $ resolver ->loadElementByIdentifier ($ identifier );
357+ if ($ element === null ) {
358+ return ;
373359 }
360+ $ cleanupStrategy = $ this ->cleanupStrategyFactory ->loadCleanupStrategy ($ cleanupConfig ['strategy ' ]);
361+ if ($ cleanupStrategy ->doCleanup ($ element ) === false ) {
362+ return ;
363+ }
364+ $ message = "Element {$ identifier } cleaned up ( {$ cleanupConfig ['strategy ' ]}) successfully. " ;
365+ $ this ->logger ->info ($ message );
366+ $ this ->applicationLogger ->info ($ message , [
367+ 'component ' => PimcoreDataImporterBundle::LOGGER_COMPONENT_PREFIX . $ configName ,
368+ 'relatedObject ' => $ element
369+ ]);
370+ } catch (\Exception $ e ) {
371+ $ message = 'Error cleaning up element: ' ;
372+ $ this ->logger ->error ($ message . $ e );
373+ $ this ->applicationLogger ->error ($ message . $ e ->getMessage (), [
374+ 'component ' => PimcoreDataImporterBundle::LOGGER_COMPONENT_PREFIX . $ configName ,
375+ 'relatedObject ' => $ element ,
376+ ]);
374377 }
375378 }
376379
0 commit comments