FIX Use $owns instead of onBeforeWrite hook to publish profile image

This commit is contained in:
James Cocker 2024-03-19 10:13:00 +00:00 committed by Michal Kleiner
parent 95a2808c04
commit 9fae326927

View File

@ -35,6 +35,10 @@ class BlogMemberExtension extends DataExtension
'BlogProfileImage' => Image::class
];
private static array $owns = [
'BlogProfileImage',
];
/**
* @var array
*/
@ -59,11 +63,6 @@ class BlogMemberExtension extends DataExtension
$this->owner->URLSegment = preg_replace('/-[0-9]+$/', '', $this->owner->URLSegment ?? '') . '-' . $count;
$count++;
}
// Auto publish profile images
if ($this->owner->BlogProfileImage() && $this->owner->BlogProfileImage()->exists()) {
$this->owner->BlogProfileImage()->publishSingle();
}
}
/**