has_url
Trait has_url.
Provides instance methods for entities to generate their own URLs. Delegates strictly to the central Facade.
Architecture Note: While strict DDD separates routing from entities, in the Moodle/ActiveRecord context, self-generating URLs facilitates template rendering and ease of use.
Table of Contents
Methods
- get_edit_url() : moodle_url
- Shortcut for the edit URL.
- get_url() : moodle_url
- Get the URL for a specific action on this entity.
- get_view_url() : moodle_url
- Shortcut for the view URL.
- get_webhook_url() : moodle_url
- Generate a webhook URL specific to this entity.
Methods
get_edit_url()
Shortcut for the edit URL.
public
get_edit_url() : moodle_url
Return values
moodle_urlget_url()
Get the URL for a specific action on this entity.
public
get_url([string $action = 'view' ][, array<string, mixed> $params = [] ]) : moodle_url
Convention: Route name is "middag.{type}.{action}" Example: $item->get_url('edit') -> route('middag.generic.edit', ['id' => 123])
Parameters
- $action : string = 'view'
-
the action suffix (view, edit, delete) or full route name
- $params : array<string, mixed> = []
-
additional parameters
Return values
moodle_urlget_view_url()
Shortcut for the view URL.
public
get_view_url() : moodle_url
Return values
moodle_urlget_webhook_url()
Generate a webhook URL specific to this entity.
public
get_webhook_url(string $action[, array<string, mixed> $params = [] ]) : moodle_url
Parameters
- $action : string
- $params : array<string, mixed> = []