AbstractRouter
in package
AbstractYes
Abstract Router class for handling basic routing functionality
Table of Contents
Properties
- $access : mixed
- $controller : mixed
- $model : mixed
- $page : mixed
- $title : mixed
Methods
- __construct() : mixed
- Constructor - sets up routing
- handle_routes() : void
- Main route handler - determines which action to take based on the request
- hook_init() : mixed
- Called when after the framework has been initialized and modules loaded Always called unlike init
- set_handle_routes() : void
- Set variables for routing from controller
Properties
$access
public
mixed
$access
= 'registered'
$controller
public
mixed
$controller
= null
$model
public
mixed
$model
= null
$page
public
mixed
$page
= null
$title
public
mixed
$title
= null
Methods
__construct()
Constructor - sets up routing
public
__construct() : mixed
handle_routes()
Main route handler - determines which action to take based on the request
public
handle_routes() : void
This method automatically calls the appropriate action method based on the 'action' URL parameter. For example, if the URL is '?page=example&action=view', it will call the method 'action_view()'.
IMPORTANT:
- Action methods are automatically called based on the URL parameter 'action'
- Hyphens in the action name are automatically converted to underscores (e.g., 'action=user-profile' will call the method 'action_user_profile()')
- The action name is sanitized to only include lowercase letters, numbers, and underscores
- If no action is specified, 'action_home()' is called by default
- If the specified action method doesn't exist, it redirects to the 404 page
hook_init()
Called when after the framework has been initialized and modules loaded Always called unlike init
public
hook_init() : mixed
set_handle_routes()
Set variables for routing from controller
public
set_handle_routes(mixed $controller) : void
Parameters
- $controller : mixed