trait 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.

Methods

moodle_url
get_url(string $action = 'view', array $params = [])

Get the URL for a specific action on this entity.

moodle_url
get_view_url()

Shortcut for the view URL.

moodle_url
get_edit_url()

Shortcut for the edit URL.

moodle_url
get_webhook_url(string $action, array $params = [])

Generate a webhook URL specific to this entity.

Details

at line 46
moodle_url get_url(string $action = 'view', array $params = [])

Get the URL for a specific action on this entity.

Convention: Route name is "middag.{type}.{action}" Example: $item->get_url('edit') -> route('middag.generic.edit', ['id' => 123])

Parameters

string $action

the action suffix (view, edit, delete) or full route name

array $params

additional parameters

Return Value

moodle_url

at line 71
moodle_url get_view_url()

Shortcut for the view URL.

Return Value

moodle_url

at line 79
moodle_url get_edit_url()

Shortcut for the edit URL.

Return Value

moodle_url

at line 92
moodle_url get_webhook_url(string $action, array $params = [])

Generate a webhook URL specific to this entity.

Parameters

string $action
array $params

Return Value

moodle_url