dashboard_controller
class dashboard_controller extends controller
Traits
Trait handling authentication and authorization logic for controllers.
Trait handling Moodle Form interactions within controllers.
Trait handling Moodle $PAGE, Context, Output and Layouts.
Properties
| protected bool | $require_login | from interacts_with_auth | |
| protected bool | $require_sesskey | from interacts_with_auth | |
| protected bool | $required_login | from interacts_with_auth | |
| protected array | $capabilities | from interacts_with_auth | |
| Request | $request | from interacts_with_auth | |
| mixed | $course | from interacts_with_page | |
| mixed | $cm | from interacts_with_page | |
| protected object|string|null | $form | from interacts_with_forms | |
| protected mixed | $formparams | from interacts_with_forms | |
| protected null|context | $context | from interacts_with_page | |
| protected string | $page_layout | from interacts_with_page | |
| protected string | $page_title | from interacts_with_page | |
| protected string | $page_heading | from interacts_with_page | |
| protected moodle_url|string|null | $page_url | from interacts_with_page | |
| protected array | $page_navbar | from interacts_with_page | |
| protected string | $admin_section | from interacts_with_page | |
| protected ContainerInterface | $container | from abstract_controller | |
| protected array<string,mixed> | $params | from abstract_controller | |
| protected array<string,mixed> | $payload | from abstract_controller |
Methods
Set if login is required and set related options.
Define the requirement of sesskey validation for non-idempotent requests.
Define the capabilities that the user must have.
Set the form for the controller to handle.
Check if the bound form was submitted and validated.
Return submitted form data when valid, otherwise false.
Check if the form was submitted (regardless of validation).
Internal helper to render the form and return HTML.
Set the context for the controller.
Add an item to the page navbar trail.
Helper to set URL from route name.
Resolves the context if null, based on course/cm properties.
Get the Moodle page URL, resolving defaults when needed.
Set the container for dependency injection.
Inject the current HTTP request instance.
Retrieve a service from the container safely.
Return a generic response based on the provided data and status code.
Return a JSON response.
Check if the incoming request is an Inertia navigation.
Render a Moodle view (HTML response) or widget.
Render a widget using a Moodle renderer.
Generates an Inertia response for the specified component and props.
Generates an Inertia location response.
Render a renderable widget using a Moodle renderer component.
Render content using Moodle mustache templates.
Display an error page with a specific message and status code.
Generates a URL from the given parameters.
Helper to perform a redirect.
Redirect to a named route with fallback support.
No description
Details
in
interacts_with_auth at line 48
void
set_require_login(mixed $course = null, mixed $cm = null)
Set if login is required and set related options.
in
interacts_with_auth at line 58
void
set_require_sesskey(bool $require = true)
Define the requirement of sesskey validation for non-idempotent requests.
in
interacts_with_auth at line 66
void
set_require_capabilities(array $capabilities)
Define the capabilities that the user must have.
in
interacts_with_auth at line 76
protected void
require_login()
Ensure the user is logged in if required.
in
interacts_with_auth at line 97
protected void
check_capabilities()
Check if the user has the required capabilities.
in
interacts_with_forms at line 43
void
set_form(object|string $form, mixed $formparams = null)
Set the form for the controller to handle.
in
interacts_with_forms at line 65
protected bool
handle_form_submission()
Check if the bound form was submitted and validated.
in
interacts_with_forms at line 73
protected mixed
process_form_submission()
Return submitted form data when valid, otherwise false.
in
interacts_with_forms at line 85
protected bool
process_form_cancel()
Determine if the form has been cancelled.
in
interacts_with_forms at line 97
protected bool
is_form_submitted()
Check if the form was submitted (regardless of validation).
in
interacts_with_forms at line 105
protected string
render_form_html()
Internal helper to render the form and return HTML.
in
interacts_with_page at line 58
void
set_context(context|null $context = null)
Set the context for the controller.
in
interacts_with_page at line 66
context
get_context()
Get the resolved context (defaults to system).
in
interacts_with_page at line 74
void
set_page_url(moodle_url|string $url)
Set the page URL.
in
interacts_with_page at line 82
void
set_page_layout(string $layout)
Set Moodle page layout.
in
interacts_with_page at line 90
void
set_page_title(string $title)
Set page title.
in
interacts_with_page at line 98
void
set_page_heading(string $heading)
Set page heading.
in
interacts_with_page at line 106
void
add_page_navbar(array|string $item)
Add an item to the page navbar trail.
in
interacts_with_page at line 114
void
set_url_from_route(string $route, array $parameters = [], int $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH)
Helper to set URL from route name.
in
interacts_with_page at line 129
protected void
resolve_context()
Resolves the context if null, based on course/cm properties.
in
interacts_with_page at line 147
protected void
setup_moodle_page()
Apply all settings to the global $PAGE object.
in
interacts_with_page at line 179
protected moodle_url
get_page_url()
Get the Moodle page URL, resolving defaults when needed.
in
abstract_controller at line 86
void
set_container(ContainerInterface $container)
Set the container for dependency injection.
Called automatically by the HttpKernel during resolution.
in
abstract_controller at line 97
void
set_request(Request $request)
Inject the current HTTP request instance.
in
abstract_controller at line 110
void
handle()
Lifecycle Hook: Execute common setup logic.
Handle the execution of the controller (login, permissions, page settings).
in
abstract_controller at line 129
void
pre_handle()
Pre-handle hook.
Can be overridden by subclasses to add logic before the main action.
in
abstract_controller at line 143
protected mixed
get_service(string $service_name)
Retrieve a service from the container safely.
in
abstract_controller at line 168
protected Response
response(mixed $data, int $status = Response::HTTP_OK)
Return a generic response based on the provided data and status code.
in
abstract_controller at line 185
protected JsonResponse
json_response(mixed $data, int $status = Response::HTTP_OK)
Return a JSON response.
in
abstract_controller at line 195
protected bool
is_json()
Check if the request expects a JSON response.
in
abstract_controller at line 213
protected bool
is_inertia_request()
Check if the incoming request is an Inertia navigation.
in
abstract_controller at line 228
protected Response
render(object|string $content = '', string|null $component = null)
Render a Moodle view (HTML response) or widget.
in
abstract_controller at line 264
protected Response
render_from_widget(string $vue_component, array $props = [], string $component = middag_helper::COMPONENT_NAME)
Render a widget using a Moodle renderer.
in
abstract_controller at line 280
protected Response
inertia(string $component, array $props = [])
Generates an Inertia response for the specified component and props.
in
abstract_controller at line 302
protected Response
inertia_location(string $route, array $params = [])
Generates an Inertia location response.
in
abstract_controller at line 317
protected Response
render_from_renderer(renderable $widget, string $component = middag_helper::COMPONENT_NAME)
Render a renderable widget using a Moodle renderer component.
in
abstract_controller at line 332
protected Response
render_from_template(string $templatename, array $templatecontext = [])
Render content using Moodle mustache templates.
in
abstract_controller at line 350
protected Response
error_page(string $message, int $status = Response::HTTP_BAD_REQUEST)
Display an error page with a specific message and status code.
in
abstract_controller at line 381
protected moodle_url
url_generator(string $route, array $parameters = [], int $reference_type = UrlGeneratorInterface::ABSOLUTE_PATH)
Generates a URL from the given parameters.
in
abstract_controller at line 394
protected RedirectResponse
redirect(moodle_url|string $url, int $status = Response::HTTP_FOUND)
Helper to perform a redirect.
in
abstract_controller at line 412
protected RedirectResponse
redirect_to_route(string $route, array $parameters = [], int $status = Response::HTTP_FOUND)
Redirect to a named route with fallback support.
at line 41
Response
index()
No description