@@ -401,20 +401,22 @@ public function createAttribute(string $collection, Attribute $attribute): bool
401401 $ document = $ attribute ->toDocument ();
402402
403403 foreach ($ this ->writeFilters as $ filter ) {
404- $ filtered = $ filter ->beforeCreateAttribute (
404+ $ document = $ filter ->beforeCreateAttribute (
405405 source: $ this ->source ,
406406 destination: $ this ->destination ,
407407 collectionId: $ collection ,
408408 attributeId: $ attribute ->key ,
409409 attribute: $ document ,
410410 );
411- if ($ filtered ! == null ) {
412- $ document = $ filtered ;
411+ if ($ document = == null ) {
412+ break ;
413413 }
414414 }
415415
416- $ filteredAttribute = Attribute::fromDocument ($ document );
417- $ result = $ this ->destination ->createAttribute ($ collection , $ filteredAttribute );
416+ if ($ document !== null ) {
417+ $ filteredAttribute = Attribute::fromDocument ($ document );
418+ $ result = $ this ->destination ->createAttribute ($ collection , $ filteredAttribute );
419+ }
418420 } catch (Throwable $ err ) {
419421 $ this ->logError ('createAttribute ' , $ err );
420422 }
@@ -441,25 +443,29 @@ public function createAttributes(string $collection, array $attributes): bool
441443 $ document = $ attribute ->toDocument ();
442444
443445 foreach ($ this ->writeFilters as $ filter ) {
444- $ filtered = $ filter ->beforeCreateAttribute (
446+ $ document = $ filter ->beforeCreateAttribute (
445447 source: $ this ->source ,
446448 destination: $ this ->destination ,
447449 collectionId: $ collection ,
448450 attributeId: $ attribute ->key ,
449451 attribute: $ document ,
450452 );
451- if ($ filtered ! == null ) {
452- $ document = $ filtered ;
453+ if ($ document = == null ) {
454+ break ;
453455 }
454456 }
455457
456- $ filteredAttributes [] = Attribute::fromDocument ($ document );
458+ if ($ document !== null ) {
459+ $ filteredAttributes [] = Attribute::fromDocument ($ document );
460+ }
457461 }
458462
459- $ result = $ this ->destination ->createAttributes (
460- $ collection ,
461- $ filteredAttributes ,
462- );
463+ if ($ filteredAttributes !== []) {
464+ $ result = $ this ->destination ->createAttributes (
465+ $ collection ,
466+ $ filteredAttributes ,
467+ );
468+ }
463469 } catch (Throwable $ err ) {
464470 $ this ->logError ('createAttributes ' , $ err );
465471 }
0 commit comments