ProfileController
class ProfileController extends Controller
Supports ability to use user profile features and render relevant views.
Traits
A trait that support operations related to APIs and their associated JSON responses.
Properties
| protected string | $_action | The name of the current action. |
from Controller |
| protected string | $_controller | The name of the current controller. |
from Controller |
| Input | $request | Instance of Input class that performs much of our request tasks. |
from Controller |
| View | $view | Instance of view class. |
from Controller |
| static string|null | $rawInputOverride | Raw JSON override for tests |
from JsonResponse |
| static bool | $testing | When true, do not send headers or exit; just echo JSON and return. |
from JsonResponse |
| static int | $lastStatus | Captured status for tests (optional convenience). |
from JsonResponse |
| static array | $lastHeaders | Captured headers for tests (optional convenience). |
from JsonResponse |
Methods
Constructor for the parent Controller class. This constructor gets called when an instance of the child class is instantiated.
Initializes ErrorHandler and SessionManager and starts execution of the app.
Manages the displaying of error messages and other reporting for this application.
Captures the current View instance during testing so that test assertions (e.g., assertViewContains) can access view-bound variables.
Internal version of this controller uses internal layout.
Supports operations related to handling POST and GET requests.
Makes JSON Response for error payloads.
Returns json response success = true and sets path for redirect.
Sends a JSON response with headers and status code.
Inject JSON body by providing payload parameter. Also performs cleanup to avoid leaking into other tests.
Deletes an image associated with a user's profile.
Renders edit profile page and handles database updates.
Renders profile view for current logged in user.
Renders change password page for current logged in user.
Details
in
Controller at line 47
__construct(string $controller, string $action)
Constructor for the parent Controller class. This constructor gets called when an instance of the child class is instantiated.
in
Application at line 26
static void
appStart()
Initializes ErrorHandler and SessionManager and starts execution of the app.
in
Application at line 51
private void
_set_reporting()
Manages the displaying of error messages and other reporting for this application.
in
Controller at line 67
protected void
logViewForTesting(View $view)
Captures the current View instance during testing so that test assertions (e.g., assertViewContains) can access view-bound variables.
This method should be called in controller actions before rendering a view. It stores the View object in ApplicationTestCase::$controllerOutput['view'] when the application is running in the 'testing' environment.
at line 78
void
onConstruct()
Internal version of this controller uses internal layout.
in
JsonResponse at line 47
bool
apiCsrfCheck()
Checks if CSRF token has been tampered with.
in
JsonResponse at line 62
array|string
get(string|null $input = null)
Supports operations related to handling POST and GET requests.
Similar in behavior to the get function from the Input class but for JSON related operations.
in
JsonResponse at line 97
void
jsonError(string $message, int $status = 400, array $errors = [])
Makes JSON Response for error payloads.
in
JsonResponse at line 110
void
jsonRedirect(string $url)
Returns json response success = true and sets path for redirect.
in
JsonResponse at line 125
void
jsonResponse(mixed $data, int $status = 200, array $extraHeaders = [])
Sends a JSON response with headers and status code.
in
JsonResponse at line 174
void
preflight()
Respond to CORS preflight.
in
JsonResponse at line 190
static void
setRawInputOverride(mixed $payload = null)
Inject JSON body by providing payload parameter. Also performs cleanup to avoid leaking into other tests.
at line 23
void
deleteImageAction()
Deletes an image associated with a user's profile.
at line 36
void
editAction()
Renders edit profile page and handles database updates.
at line 63
void
indexAction()
Renders profile view for current logged in user.
at line 87
void
updatePasswordAction()
Renders change password page for current logged in user.