Skip to content

Commit

Permalink
docs: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Sep 8, 2024
1 parent a2c36f1 commit 9bf9e7d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions docs/customization/user_provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,16 @@ class UserModel extends ShieldUserModel
}
```

## Using a Custom User Entity
## Creating a Custom User Entity

If you have set a custom `$returnType` in your custom `UserModel`, you may
retrieve the return type using the `UserModel::getReturnType()` method and
easily create a new User Entity using it:
Starting from v1.2.0, `UserModel` in Shield has the `createNewUser()` method to
create a new User Entity.

```php
$userEntityClass = $userModel->getReturnType();
$newUser = new $userEntityClass();
$user = $userModel->createNewUser($data);
```

It takes an optional user data array as the first argument, and passes it to the
constructor of the `$returnType` class.

If your custom User entity cannot be instantiated in this way, override this method.

0 comments on commit 9bf9e7d

Please sign in to comment.