ProfileApiHandler
in package
implements
ApiRoutableInterface
uses
ApiRoutableTrait
The signed-in user's own profile and preferences.
Routes:
- GET /api/v1/profile - Username, email, verification state
- PUT /api/v1/profile - Update username and email
- PUT /api/v1/profile/password - Change password (needs the current one)
- GET /api/v1/profile/preferences - The user-scoped settings map
- PUT /api/v1/profile/preferences - Save that map
Tags
Table of Contents
Interfaces
- ApiRoutableInterface
- Interface for API handlers that participate in route dispatch.
Properties
Methods
- __construct() : mixed
- changePassword() : array{success: bool, error?: string}
- Change the caller's password.
- getPreferences() : array<string, mixed>
- Read the caller's preferences.
- getProfile() : array<string, mixed>
- Read the caller's profile.
- routeDelete() : JsonResponse
- routeGet() : JsonResponse
- Handle a GET request for this resource.
- routePost() : JsonResponse
- routePut() : JsonResponse
- Handle a PUT request for this resource.
- savePreferences() : array{success: bool}
- Save the caller's preferences.
- updateProfile() : array{success: bool, emailChanged?: bool, error?: string}
- Update the caller's username and email.
- frag() : string
- Extract a fragment from the fragments array.
Properties
$userFacade
private
UserFacade
$userFacade
Methods
__construct()
public
__construct(UserFacade $userFacade) : mixed
Parameters
- $userFacade : UserFacade
changePassword()
Change the caller's password.
public
changePassword(array<string, mixed> $data) : array{success: bool, error?: string}
The current password is required and checked by the facade, so knowing a session is open is not enough to replace it.
Parameters
- $data : array<string, mixed>
-
Payload
Return values
array{success: bool, error?: string}getPreferences()
Read the caller's preferences.
public
getPreferences() : array<string, mixed>
Return values
array<string, mixed> —The settings map
getProfile()
Read the caller's profile.
public
getProfile() : array<string, mixed>
Return values
array<string, mixed> —Profile fields, or an error
routeDelete()
public
routeDelete(array<string|int, mixed> $fragments, array<string|int, mixed> $params) : JsonResponse
Parameters
- $fragments : array<string|int, mixed>
- $params : array<string|int, mixed>
Return values
JsonResponserouteGet()
Handle a GET request for this resource.
public
routeGet(array<int, string> $fragments, array<string, mixed> $params) : JsonResponse
Parameters
- $fragments : array<int, string>
-
URL path fragments
- $params : array<string, mixed>
-
Query parameters
Return values
JsonResponseroutePost()
public
routePost(array<string|int, mixed> $fragments, array<string|int, mixed> $params) : JsonResponse
Parameters
- $fragments : array<string|int, mixed>
- $params : array<string|int, mixed>
Return values
JsonResponseroutePut()
Handle a PUT request for this resource.
public
routePut(array<int, string> $fragments, array<string, mixed> $params) : JsonResponse
Parameters
- $fragments : array<int, string>
-
URL path fragments
- $params : array<string, mixed>
-
Request body
Return values
JsonResponsesavePreferences()
Save the caller's preferences.
public
savePreferences(array<string, mixed> $data) : array{success: bool}
Parameters
- $data : array<string, mixed>
-
Settings map
Return values
array{success: bool}updateProfile()
Update the caller's username and email.
public
updateProfile(array<string, mixed> $data) : array{success: bool, emailChanged?: bool, error?: string}
Parameters
- $data : array<string, mixed>
-
Payload
Return values
array{success: bool, emailChanged?: bool, error?: string}frag()
Extract a fragment from the fragments array.
protected
frag(array<int, string> $fragments, int $index) : string
Parameters
- $fragments : array<int, string>
-
The URL path fragments
- $index : int
-
The index to extract
Return values
string —The fragment at the index, or empty string if not present