diff --git a/src/Attributes/Author.php b/src/Attributes/Author.php index a671c455..096773fa 100644 --- a/src/Attributes/Author.php +++ b/src/Attributes/Author.php @@ -24,8 +24,8 @@ class Author extends CastForSave { protected function getDefaultCaster(): callable { - return function (mixed $value, ORM $orm, object $entity, UserService $userService) { - if (!$value) { + return function (mixed $value, ORM $orm, object $entity, UserService $userService = null) { + if (!$value && $userService) { $mapper = $orm->mapper($entity::class); if ($mapper->canCheckIsNew()) { diff --git a/src/Attributes/Modifier.php b/src/Attributes/Modifier.php index dcd0a273..49dc7c11 100644 --- a/src/Attributes/Modifier.php +++ b/src/Attributes/Modifier.php @@ -24,7 +24,11 @@ class Modifier extends CastForSave { protected function getDefaultCaster(): callable { - return function (mixed $value, ORM $orm, object $entity, UserService $userService) { + return function (mixed $value, ORM $orm, object $entity, UserService $userService = null) { + if (!$userService) { + return $value; + } + $mapper = $orm->mapper($entity::class); if ($mapper->canCheckIsNew()) {