UsersController final readonly class
Minn\Rest\UsersController · public/minn/src/Minn/Rest/UsersController.php · 379 lines
wp/v2 users: me, list, single, and the create/update/delete-with-reassign the Users view drives.
Uses 35 (show)
Constants and properties
| private | readonly Minn\Db $db | Promoted from the constructor. |
| private | readonly Minn\Content\Users $users | Promoted from the constructor. |
| private | readonly Minn\Content\Site $site | Promoted from the constructor. |
| private | readonly Minn\Rest\UserObject $object | Promoted from the constructor. |
| private | readonly Minn\Rest\RestUrl $url | Promoted from the constructor. |
| private | readonly Minn\Rest\Caller $caller | Promoted from the constructor. |
| private | readonly Minn\Auth\Roles $roles | Promoted from the constructor. |
| private | readonly Minn\Rest\Schema $schema | Promoted from the constructor. |
Public
| new | __construct(Minn\Db $db, Minn\Content\Users $users, Minn\Content\Site $site, Minn\Rest\UserObject $object, Minn\Rest\RestUrl $url, Minn\Rest\Caller $caller, Minn\Auth\Roles $roles, Minn\Rest\Schema $schema)# | |
| method | me(Minn\Http\Request $request): Minn\Http\ResponseGET /wp/v2/users/me (public)# | The signed-in user. |
| method | updateMe(Minn\Http\Request $request): Minn\Http\ResponsePOST /wp/v2/users/me (signed in)PUT /wp/v2/users/me (signed in)PATCH /wp/v2/users/me (signed in)# | Updates the signed-in user; signed out there is no such user (404), and the Allow header leaves the writes out. |
| method | deleteMe(Minn\Http\Request $request): Minn\Http\ResponseDELETE /wp/v2/users/me (cap delete_users)# | Deletes the signed-in user as users/{id} deletes any; signed out there is no such user (404). |
| method | list(Minn\Http\Request $request): Minn\Http\ResponseGET /wp/v2/users (public)# | The users list as the reference serves it: the request's WP_User_Query through rest_user_collection_params and rest_user_query (a reader who may not list users sees published authors only), its totals (counted again without the page when it found none), and the users it found. |
| method | single(Minn\Http\Request $request, string $id): Minn\Http\ResponseGET /wp/v2/users/{id:[\d]+} (public; user {id} must exist)# | One user. |
| method | create(Minn\Http\Request $request): Minn\Http\ResponsePOST /wp/v2/users (cap create_users)# | Engine-created users carry real scheme hashes and the full default meta set. |
| method | update(Minn\Http\Request $request, string $id): Minn\Http\ResponsePOST /wp/v2/users/{id:[\d]+} (cap edit_user on {id}; user {id} must exist)PUT /wp/v2/users/{id:[\d]+} (cap edit_user on {id}; user {id} must exist)PATCH /wp/v2/users/{id:[\d]+} (cap edit_user on {id}; user {id} must exist)# | Updates a user. |
| method | delete(Minn\Http\Request $request, string $id): Minn\Http\ResponseDELETE /wp/v2/users/{id:[\d]+} (cap delete_users; user {id} must exist)# | reassign is REQUIRED (checked before the user lookup), and so is force. |
Internals 8
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | listAllowed(Minn\Objects\RestRequest $wp, Minn\Rest\Context $context): void# | What a reader who may not list users may not ask the list for: the edit context, an email or registration order, roles, capabilities; the authors shorthand is for those who may edit posts. | |||
| private | totals(Minn\Objects\UsersQuery $query, array $args): array# | The total and the page count: the query's own, or, when it found none, a count without the page; pages by the query's own number.
@return array{0: int, 1: int} | |||
| private | hasPublishedContent(int $userId): bool# | ||||
| private | validRole(string $role): string# | A role must be registered, as the reference insists. | |||
| private | validLocale(array $body): void# | A locale asked for is one the site can show: none, en_US, or an installed language, as the reference's schema lists them (audit Low: any string was stored, and pasted into the reset link).
| |||
| private | assignableRole(string $role): string# | A role asked for: registered, and one editable_roles lets this caller give (audit Low). | |||
| private | validEmail(string $email): bool# | ||||
| private | loginRefusal(string $login): ?string# | Why a new login is refused, in the reference's words, or null: it must come through strict sanitizing unchanged (validate_username, with plugins loaded), and no illegal_user_logins entry may name it. |
Nothing matches.