url_support
class url_support
| internal |
Utility functions for Moodle URLs and redirection.
Provides a centralized interface for creating Moodle URLs with proper error handling and consistent parameter management.
Methods
Safely creates a Moodle URL object.
Retrieves a course view URL.
Retrieves a course module (activity) URL.
Retrieves a user profile URL.
Retrieves a pluginfile URL for serving files.
Retrieves a component image URL from the theme.
Retrieves a Moodle admin settings page URL.
Retrieves the site home page URL.
Retrieves the user dashboard URL.
Retrieves a grade report URL.
Converts a relative URL to an absolute URL.
Checks if a URL is external to the current Moodle site.
Redirects the user to a specific URL.
Details
at line 48
static moodle_url
get(moodle_url|string $url, array|null $params = null, string|null $anchor = null, int $strictness = IGNORE_MISSING)
Safely creates a Moodle URL object.
at line 84
static moodle_url
course(int $courseid, array $params = [], string|null $anchor = null)
Retrieves a course view URL.
at line 101
static moodle_url
module(int $cmid, array $params = [], string|null $anchor = null)
Retrieves a course module (activity) URL.
at line 119
static moodle_url
user_profile(int $userid, int|null $courseid = null, array $params = [], string|null $anchor = null)
Retrieves a user profile URL.
at line 151
static moodle_url
pluginfile(int $contextid, string $component, string $filearea, int $itemid, string $filepath, string $filename, bool $forcedownload = false, string|null $preview = null)
Retrieves a pluginfile URL for serving files.
This is the proper way to generate URLs for files stored in Moodle's file storage.
at line 186
static moodle_url
image_url(string $imagename, string $component = middag_helper::COMPONENT_NAME)
Retrieves a component image URL from the theme.
at line 208
static moodle_url
admin_settings(string $section, array $params = [], string|null $anchor = null)
Retrieves a Moodle admin settings page URL.
at line 224
static moodle_url
home(array $params = [], string|null $anchor = null)
Retrieves the site home page URL.
at line 237
static moodle_url
dashboard(array $params = [], string|null $anchor = null)
Retrieves the user dashboard URL.
at line 252
static moodle_url
grade_report(int $courseid, string $report = 'user', array $params = [], string|null $anchor = null)
Retrieves a grade report URL.
at line 271
static string
to_absolute(string $relativeurl)
Converts a relative URL to an absolute URL.
at line 293
static bool
is_external(string $url)
Checks if a URL is external to the current Moodle site.
at line 318
static void
redirect(moodle_url|string $url, string $message = '', int $delay = 0, string $messagetype = 'notifysuccess')
Redirects the user to a specific URL.