Skip to content

Commit

Permalink
Fix Author & Modifier to not hard dep to UserService
Browse files Browse the repository at this point in the history
  • Loading branch information
asika32764 committed Oct 1, 2023
1 parent 42c4294 commit ee5f33f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Attributes/Author.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
6 changes: 5 additions & 1 deletion src/Attributes/Modifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit ee5f33f

Please sign in to comment.